Skip to content
Start here

Get analytics summary

client.Spectrum.Analytics.Events.Summaries.Get(ctx, params) (*AnalyticsEventSummaryGetResponse, error)
GET/zones/{zone_id}/spectrum/analytics/events/summary

Retrieves a list of summarised aggregate metrics over a given time period.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Analytics Read
ParametersExpand Collapse
params AnalyticsEventSummaryGetParams
ZoneID param.Field[string]

Path param: Identifier.

maxLength32
Dimensions param.Field[[]Dimension]optional

Query param: Can be used to break down the data by given attributes. Options are:

DimensionNameExample
eventConnection Eventconnect, progress, disconnect, originError, clientFiltered
appIDApplication ID40d67c87c6cd4b889a4fd57805225e85
coloNameColo NameSFO
ipVersionIP version used by the client4, 6.
const DimensionEvent Dimension = "event"
const DimensionAppID Dimension = "appID"
const DimensionColoName Dimension = "coloName"
const DimensionIPVersion Dimension = "ipVersion"
Filters param.Field[string]optional

Query param: Used to filter rows by one or more dimensions. Filters can be combined using OR and AND boolean logic. AND takes precedence over OR in all the expressions. The OR operator is defined using a comma (,) or OR keyword surrounded by whitespace. The AND operator is defined using a semicolon (;) or AND keyword surrounded by whitespace. Note that the semicolon is a reserved character in URLs (rfc1738) and needs to be percent-encoded as %3B. Comparison options are:

OperatorNameURL Encoded
==Equals%3D%3D
!=Does not equals!%3D
>Greater Than%3E
<Less Than%3C
>=Greater than or equal to%3E%3D
<=Less than or equal to%3C%3D
Metrics param.Field[[]AnalyticsEventSummaryGetParamsMetric]optional

Query param: One or more metrics to compute. Options are:

MetricNameExampleUnit
countCount of total events1000Count
bytesIngressSum of ingress bytes1000Sum
bytesEgressSum of egress bytes1000Sum
durationAvgAverage connection duration1.0Time in milliseconds
durationMedianMedian connection duration1.0Time in milliseconds
duration90th90th percentile connection duration1.0Time in milliseconds
duration99th99th percentile connection duration1.0Time in milliseconds.
const AnalyticsEventSummaryGetParamsMetricCount AnalyticsEventSummaryGetParamsMetric = "count"
const AnalyticsEventSummaryGetParamsMetricBytesIngress AnalyticsEventSummaryGetParamsMetric = "bytesIngress"
const AnalyticsEventSummaryGetParamsMetricBytesEgress AnalyticsEventSummaryGetParamsMetric = "bytesEgress"
const AnalyticsEventSummaryGetParamsMetricDurationAvg AnalyticsEventSummaryGetParamsMetric = "durationAvg"
const AnalyticsEventSummaryGetParamsMetricDurationMedian AnalyticsEventSummaryGetParamsMetric = "durationMedian"
const AnalyticsEventSummaryGetParamsMetricDuration90th AnalyticsEventSummaryGetParamsMetric = "duration90th"
const AnalyticsEventSummaryGetParamsMetricDuration99th AnalyticsEventSummaryGetParamsMetric = "duration99th"
Since param.Field[Time]optional

Query param: Start of time interval to query, defaults to until - 6 hours. Timestamp must be in RFC3339 format and uses UTC unless otherwise specified.

formatdate-time
Sort param.Field[[]string]optional

Query param: The sort order for the result set; sort fields must be included in metrics or dimensions.

Until param.Field[Time]optional

Query param: End of time interval to query, defaults to current time. Timestamp must be in RFC3339 format and uses UTC unless otherwise specified.

formatdate-time
ReturnsExpand Collapse
type AnalyticsEventSummaryGetResponse struct{…}
Data []AnalyticsEventSummaryGetResponseData

List of columns returned by the analytics query.

Dimensions []stringoptional
Metrics AnalyticsEventSummaryGetResponseDataMetricsUnionoptional
One of the following:
type AnalyticsEventSummaryGetResponseDataMetricsArray []float64
type AnalyticsEventSummaryGetResponseDataMetricsArray [][]float64
DataLag float64

Number of seconds between current time and last processed event, i.e. how many seconds of data could be missing.

minimum0
Max map[string, float64]

Maximum result for each selected metrics across all data.

Min map[string, float64]

Minimum result for each selected metrics across all data.

Query AnalyticsEventSummaryGetResponseQuery
Dimensions []Dimensionoptional

Can be used to break down the data by given attributes. Options are:

DimensionNameExample
eventConnection Eventconnect, progress, disconnect, originError, clientFiltered
appIDApplication ID40d67c87c6cd4b889a4fd57805225e85
coloNameColo NameSFO
ipVersionIP version used by the client4, 6.
One of the following:
const DimensionEvent Dimension = "event"
const DimensionAppID Dimension = "appID"
const DimensionColoName Dimension = "coloName"
const DimensionIPVersion Dimension = "ipVersion"
Filters stringoptional

Used to filter rows by one or more dimensions. Filters can be combined using OR and AND boolean logic. AND takes precedence over OR in all the expressions. The OR operator is defined using a comma (,) or OR keyword surrounded by whitespace. The AND operator is defined using a semicolon (;) or AND keyword surrounded by whitespace. Note that the semicolon is a reserved character in URLs (rfc1738) and needs to be percent-encoded as %3B. Comparison options are:

OperatorNameURL Encoded
==Equals%3D%3D
!=Does not equals!%3D
>Greater Than%3E
<Less Than%3C
>=Greater than or equal to%3E%3D
<=Less than or equal to%3C%3D
Limit float64optional

Limit number of returned metrics.

Metrics []AnalyticsEventSummaryGetResponseQueryMetricoptional

One or more metrics to compute. Options are:

MetricNameExampleUnit
countCount of total events1000Count
bytesIngressSum of ingress bytes1000Sum
bytesEgressSum of egress bytes1000Sum
durationAvgAverage connection duration1.0Time in milliseconds
durationMedianMedian connection duration1.0Time in milliseconds
duration90th90th percentile connection duration1.0Time in milliseconds
duration99th99th percentile connection duration1.0Time in milliseconds.
One of the following:
const AnalyticsEventSummaryGetResponseQueryMetricCount AnalyticsEventSummaryGetResponseQueryMetric = "count"
const AnalyticsEventSummaryGetResponseQueryMetricBytesIngress AnalyticsEventSummaryGetResponseQueryMetric = "bytesIngress"
const AnalyticsEventSummaryGetResponseQueryMetricBytesEgress AnalyticsEventSummaryGetResponseQueryMetric = "bytesEgress"
const AnalyticsEventSummaryGetResponseQueryMetricDurationAvg AnalyticsEventSummaryGetResponseQueryMetric = "durationAvg"
const AnalyticsEventSummaryGetResponseQueryMetricDurationMedian AnalyticsEventSummaryGetResponseQueryMetric = "durationMedian"
const AnalyticsEventSummaryGetResponseQueryMetricDuration90th AnalyticsEventSummaryGetResponseQueryMetric = "duration90th"
const AnalyticsEventSummaryGetResponseQueryMetricDuration99th AnalyticsEventSummaryGetResponseQueryMetric = "duration99th"
Since Timeoptional

Start of time interval to query, defaults to until - 6 hours. Timestamp must be in RFC3339 format and uses UTC unless otherwise specified.

formatdate-time
Sort []stringoptional

The sort order for the result set; sort fields must be included in metrics or dimensions.

Until Timeoptional

End of time interval to query, defaults to current time. Timestamp must be in RFC3339 format and uses UTC unless otherwise specified.

formatdate-time
Rows float64

Total number of rows in the result.

minimum0
Totals map[string, float64]

Total result for each selected metrics across all data.

TimeIntervals [][]Timeoptional

List of time interval buckets: [start, end]

Get analytics summary

package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/option"
  "github.com/cloudflare/cloudflare-go/spectrum"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  summary, err := client.Spectrum.Analytics.Events.Summaries.Get(context.TODO(), spectrum.AnalyticsEventSummaryGetParams{
    ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", summary.Data)
}
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "data": [
      {
        "dimensions": [
          "string"
        ],
        "metrics": [
          0
        ]
      }
    ],
    "data_lag": 3,
    "max": {
      "bytesEgress": 100,
      "bytesIngress": 50
    },
    "min": {
      "bytesEgress": 100,
      "bytesIngress": 50
    },
    "query": {
      "dimensions": [
        "event",
        "appID"
      ],
      "filters": "event==disconnect%20AND%20coloName!=SFO",
      "limit": 0,
      "metrics": [
        "count",
        "bytesIngress"
      ],
      "since": "2014-01-01T05:20:00.12345Z",
      "sort": [
        "+count",
        "-bytesIngress"
      ],
      "until": "2014-01-01T05:20:00.12345Z"
    },
    "rows": 5,
    "totals": {
      "bytesEgress": 100,
      "bytesIngress": 50
    },
    "time_intervals": [
      [
        "2014-01-01T05:20:00.12345Z"
      ]
    ]
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "data": [
      {
        "dimensions": [
          "string"
        ],
        "metrics": [
          0
        ]
      }
    ],
    "data_lag": 3,
    "max": {
      "bytesEgress": 100,
      "bytesIngress": 50
    },
    "min": {
      "bytesEgress": 100,
      "bytesIngress": 50
    },
    "query": {
      "dimensions": [
        "event",
        "appID"
      ],
      "filters": "event==disconnect%20AND%20coloName!=SFO",
      "limit": 0,
      "metrics": [
        "count",
        "bytesIngress"
      ],
      "since": "2014-01-01T05:20:00.12345Z",
      "sort": [
        "+count",
        "-bytesIngress"
      ],
      "until": "2014-01-01T05:20:00.12345Z"
    },
    "rows": 5,
    "totals": {
      "bytesEgress": 100,
      "bytesIngress": 50
    },
    "time_intervals": [
      [
        "2014-01-01T05:20:00.12345Z"
      ]
    ]
  }
}