# Analytics # Aggregates # Currents ## Get current aggregated analytics `client.Spectrum.Analytics.Aggregates.Currents.Get(ctx, params) (*[]AnalyticsAggregateCurrentGetResponse, error)` **get** `/zones/{zone_id}/spectrum/analytics/aggregate/current` Retrieves analytics aggregated from the last minute of usage on Spectrum applications underneath a given zone. ### Parameters - `params AnalyticsAggregateCurrentGetParams` - `ZoneID param.Field[string]` Path param: Identifier. - `AppID param.Field[string]` Query param: Comma-delimited list of Spectrum Application Id(s). If provided, the response will be limited to Spectrum Application Id(s) that match. - `ColoName param.Field[string]` Query param: Co-location identifier. ### Returns - `type AnalyticsAggregateCurrentGetResponseEnvelopeResult []AnalyticsAggregateCurrentGetResponse` - `AppID string` Application identifier. - `BytesEgress float64` Number of bytes sent - `BytesIngress float64` Number of bytes received - `Connections float64` Number of connections - `DurationAvg float64` Average duration of connections ### Example ```go 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"), ) currents, err := client.Spectrum.Analytics.Aggregates.Currents.Get(context.TODO(), spectrum.AnalyticsAggregateCurrentGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", currents) } ``` #### Response ```json { "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": [ { "appID": "023e105f4ecef8ad9ca31a8372d0c353", "bytesEgress": 0, "bytesIngress": 0, "connections": 0, "durationAvg": 0 } ] } ``` # Events ## Domain Types ### Dimension - `type Dimension string` - `const DimensionEvent Dimension = "event"` - `const DimensionAppID Dimension = "appID"` - `const DimensionColoName Dimension = "coloName"` - `const DimensionIPVersion Dimension = "ipVersion"` # Bytimes ## Get analytics by time `client.Spectrum.Analytics.Events.Bytimes.Get(ctx, params) (*AnalyticsEventBytimeGetResponse, error)` **get** `/zones/{zone_id}/spectrum/analytics/events/bytime` Retrieves a list of aggregate metrics grouped by time interval. ### Parameters - `params AnalyticsEventBytimeGetParams` - `ZoneID param.Field[string]` Path param: Identifier. - `TimeDelta param.Field[AnalyticsEventBytimeGetParamsTimeDelta]` Query param: Used to select time series resolution. - `const AnalyticsEventBytimeGetParamsTimeDeltaYear AnalyticsEventBytimeGetParamsTimeDelta = "year"` - `const AnalyticsEventBytimeGetParamsTimeDeltaQuarter AnalyticsEventBytimeGetParamsTimeDelta = "quarter"` - `const AnalyticsEventBytimeGetParamsTimeDeltaMonth AnalyticsEventBytimeGetParamsTimeDelta = "month"` - `const AnalyticsEventBytimeGetParamsTimeDeltaWeek AnalyticsEventBytimeGetParamsTimeDelta = "week"` - `const AnalyticsEventBytimeGetParamsTimeDeltaDay AnalyticsEventBytimeGetParamsTimeDelta = "day"` - `const AnalyticsEventBytimeGetParamsTimeDeltaHour AnalyticsEventBytimeGetParamsTimeDelta = "hour"` - `const AnalyticsEventBytimeGetParamsTimeDeltaDekaminute AnalyticsEventBytimeGetParamsTimeDelta = "dekaminute"` - `const AnalyticsEventBytimeGetParamsTimeDeltaMinute AnalyticsEventBytimeGetParamsTimeDelta = "minute"` - `Dimensions param.Field[[]Dimension]` Query param: Can be used to break down the data by given attributes. Options are: | Dimension | Name | Example | | --------- | ----------------------------- | ---------------------------------------------------------- | | event | Connection Event | connect, progress, disconnect, originError, clientFiltered | | appID | Application ID | 40d67c87c6cd4b889a4fd57805225e85 | | coloName | Colo Name | SFO | | ipVersion | IP version used by the client | 4, 6. | - `const DimensionEvent Dimension = "event"` - `const DimensionAppID Dimension = "appID"` - `const DimensionColoName Dimension = "coloName"` - `const DimensionIPVersion Dimension = "ipVersion"` - `Filters param.Field[string]` 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: | Operator | Name | URL 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[[]AnalyticsEventBytimeGetParamsMetric]` Query param: One or more metrics to compute. Options are: | Metric | Name | Example | Unit | | -------------- | ----------------------------------- | ------- | --------------------- | | count | Count of total events | 1000 | Count | | bytesIngress | Sum of ingress bytes | 1000 | Sum | | bytesEgress | Sum of egress bytes | 1000 | Sum | | durationAvg | Average connection duration | 1.0 | Time in milliseconds | | durationMedian | Median connection duration | 1.0 | Time in milliseconds | | duration90th | 90th percentile connection duration | 1.0 | Time in milliseconds | | duration99th | 99th percentile connection duration | 1.0 | Time in milliseconds. | - `const AnalyticsEventBytimeGetParamsMetricCount AnalyticsEventBytimeGetParamsMetric = "count"` - `const AnalyticsEventBytimeGetParamsMetricBytesIngress AnalyticsEventBytimeGetParamsMetric = "bytesIngress"` - `const AnalyticsEventBytimeGetParamsMetricBytesEgress AnalyticsEventBytimeGetParamsMetric = "bytesEgress"` - `const AnalyticsEventBytimeGetParamsMetricDurationAvg AnalyticsEventBytimeGetParamsMetric = "durationAvg"` - `const AnalyticsEventBytimeGetParamsMetricDurationMedian AnalyticsEventBytimeGetParamsMetric = "durationMedian"` - `const AnalyticsEventBytimeGetParamsMetricDuration90th AnalyticsEventBytimeGetParamsMetric = "duration90th"` - `const AnalyticsEventBytimeGetParamsMetricDuration99th AnalyticsEventBytimeGetParamsMetric = "duration99th"` - `Since param.Field[Time]` 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. - `Sort param.Field[[]string]` Query param: The sort order for the result set; sort fields must be included in `metrics` or `dimensions`. - `Until param.Field[Time]` Query param: End of time interval to query, defaults to current time. Timestamp must be in RFC3339 format and uses UTC unless otherwise specified. ### Returns - `type AnalyticsEventBytimeGetResponse struct{…}` - `Data []AnalyticsEventBytimeGetResponseData` List of columns returned by the analytics query. - `Dimensions []string` - `Metrics AnalyticsEventBytimeGetResponseDataMetricsUnion` - `type AnalyticsEventBytimeGetResponseDataMetricsArray []float64` - `type AnalyticsEventBytimeGetResponseDataMetricsArray [][]float64` - `DataLag float64` Number of seconds between current time and last processed event, i.e. how many seconds of data could be missing. - `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 AnalyticsEventBytimeGetResponseQuery` - `Dimensions []Dimension` Can be used to break down the data by given attributes. Options are: | Dimension | Name | Example | | --------- | ----------------------------- | ---------------------------------------------------------- | | event | Connection Event | connect, progress, disconnect, originError, clientFiltered | | appID | Application ID | 40d67c87c6cd4b889a4fd57805225e85 | | coloName | Colo Name | SFO | | ipVersion | IP version used by the client | 4, 6. | - `const DimensionEvent Dimension = "event"` - `const DimensionAppID Dimension = "appID"` - `const DimensionColoName Dimension = "coloName"` - `const DimensionIPVersion Dimension = "ipVersion"` - `Filters string` 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: | Operator | Name | URL 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 float64` Limit number of returned metrics. - `Metrics []AnalyticsEventBytimeGetResponseQueryMetric` One or more metrics to compute. Options are: | Metric | Name | Example | Unit | | -------------- | ----------------------------------- | ------- | --------------------- | | count | Count of total events | 1000 | Count | | bytesIngress | Sum of ingress bytes | 1000 | Sum | | bytesEgress | Sum of egress bytes | 1000 | Sum | | durationAvg | Average connection duration | 1.0 | Time in milliseconds | | durationMedian | Median connection duration | 1.0 | Time in milliseconds | | duration90th | 90th percentile connection duration | 1.0 | Time in milliseconds | | duration99th | 99th percentile connection duration | 1.0 | Time in milliseconds. | - `const AnalyticsEventBytimeGetResponseQueryMetricCount AnalyticsEventBytimeGetResponseQueryMetric = "count"` - `const AnalyticsEventBytimeGetResponseQueryMetricBytesIngress AnalyticsEventBytimeGetResponseQueryMetric = "bytesIngress"` - `const AnalyticsEventBytimeGetResponseQueryMetricBytesEgress AnalyticsEventBytimeGetResponseQueryMetric = "bytesEgress"` - `const AnalyticsEventBytimeGetResponseQueryMetricDurationAvg AnalyticsEventBytimeGetResponseQueryMetric = "durationAvg"` - `const AnalyticsEventBytimeGetResponseQueryMetricDurationMedian AnalyticsEventBytimeGetResponseQueryMetric = "durationMedian"` - `const AnalyticsEventBytimeGetResponseQueryMetricDuration90th AnalyticsEventBytimeGetResponseQueryMetric = "duration90th"` - `const AnalyticsEventBytimeGetResponseQueryMetricDuration99th AnalyticsEventBytimeGetResponseQueryMetric = "duration99th"` - `Since Time` Start of time interval to query, defaults to `until` - 6 hours. Timestamp must be in RFC3339 format and uses UTC unless otherwise specified. - `Sort []string` The sort order for the result set; sort fields must be included in `metrics` or `dimensions`. - `Until Time` End of time interval to query, defaults to current time. Timestamp must be in RFC3339 format and uses UTC unless otherwise specified. - `Rows float64` Total number of rows in the result. - `Totals map[string, float64]` Total result for each selected metrics across all data. - `TimeIntervals [][]Time` List of time interval buckets: [start, end] ### Example ```go 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"), ) bytime, err := client.Spectrum.Analytics.Events.Bytimes.Get(context.TODO(), spectrum.AnalyticsEventBytimeGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), TimeDelta: cloudflare.F(spectrum.AnalyticsEventBytimeGetParamsTimeDeltaMinute), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", bytime.Data) } ``` #### Response ```json { "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" ] ] } } ``` # Summaries ## 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. ### Parameters - `params AnalyticsEventSummaryGetParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Dimensions param.Field[[]Dimension]` Query param: Can be used to break down the data by given attributes. Options are: | Dimension | Name | Example | | --------- | ----------------------------- | ---------------------------------------------------------- | | event | Connection Event | connect, progress, disconnect, originError, clientFiltered | | appID | Application ID | 40d67c87c6cd4b889a4fd57805225e85 | | coloName | Colo Name | SFO | | ipVersion | IP version used by the client | 4, 6. | - `const DimensionEvent Dimension = "event"` - `const DimensionAppID Dimension = "appID"` - `const DimensionColoName Dimension = "coloName"` - `const DimensionIPVersion Dimension = "ipVersion"` - `Filters param.Field[string]` 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: | Operator | Name | URL 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]` Query param: One or more metrics to compute. Options are: | Metric | Name | Example | Unit | | -------------- | ----------------------------------- | ------- | --------------------- | | count | Count of total events | 1000 | Count | | bytesIngress | Sum of ingress bytes | 1000 | Sum | | bytesEgress | Sum of egress bytes | 1000 | Sum | | durationAvg | Average connection duration | 1.0 | Time in milliseconds | | durationMedian | Median connection duration | 1.0 | Time in milliseconds | | duration90th | 90th percentile connection duration | 1.0 | Time in milliseconds | | duration99th | 99th percentile connection duration | 1.0 | Time 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]` 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. - `Sort param.Field[[]string]` Query param: The sort order for the result set; sort fields must be included in `metrics` or `dimensions`. - `Until param.Field[Time]` Query param: End of time interval to query, defaults to current time. Timestamp must be in RFC3339 format and uses UTC unless otherwise specified. ### Returns - `type AnalyticsEventSummaryGetResponse struct{…}` - `Data []AnalyticsEventSummaryGetResponseData` List of columns returned by the analytics query. - `Dimensions []string` - `Metrics AnalyticsEventSummaryGetResponseDataMetricsUnion` - `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. - `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 []Dimension` Can be used to break down the data by given attributes. Options are: | Dimension | Name | Example | | --------- | ----------------------------- | ---------------------------------------------------------- | | event | Connection Event | connect, progress, disconnect, originError, clientFiltered | | appID | Application ID | 40d67c87c6cd4b889a4fd57805225e85 | | coloName | Colo Name | SFO | | ipVersion | IP version used by the client | 4, 6. | - `const DimensionEvent Dimension = "event"` - `const DimensionAppID Dimension = "appID"` - `const DimensionColoName Dimension = "coloName"` - `const DimensionIPVersion Dimension = "ipVersion"` - `Filters string` 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: | Operator | Name | URL 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 float64` Limit number of returned metrics. - `Metrics []AnalyticsEventSummaryGetResponseQueryMetric` One or more metrics to compute. Options are: | Metric | Name | Example | Unit | | -------------- | ----------------------------------- | ------- | --------------------- | | count | Count of total events | 1000 | Count | | bytesIngress | Sum of ingress bytes | 1000 | Sum | | bytesEgress | Sum of egress bytes | 1000 | Sum | | durationAvg | Average connection duration | 1.0 | Time in milliseconds | | durationMedian | Median connection duration | 1.0 | Time in milliseconds | | duration90th | 90th percentile connection duration | 1.0 | Time in milliseconds | | duration99th | 99th percentile connection duration | 1.0 | Time in milliseconds. | - `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 Time` Start of time interval to query, defaults to `until` - 6 hours. Timestamp must be in RFC3339 format and uses UTC unless otherwise specified. - `Sort []string` The sort order for the result set; sort fields must be included in `metrics` or `dimensions`. - `Until Time` End of time interval to query, defaults to current time. Timestamp must be in RFC3339 format and uses UTC unless otherwise specified. - `Rows float64` Total number of rows in the result. - `Totals map[string, float64]` Total result for each selected metrics across all data. - `TimeIntervals [][]Time` List of time interval buckets: [start, end] ### Example ```go 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) } ``` #### Response ```json { "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" ] ] } } ```