# Analytics # Reports ## Table `client.DNS.Analytics.Reports.Get(ctx, params) (*Report, error)` **get** `/zones/{zone_id}/dns_analytics/report` Retrieves a list of summarised aggregate metrics over a given time period. See [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) for detailed information about the available query parameters. ### Parameters - `params AnalyticsReportGetParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Dimensions param.Field[string]` Query param: A comma-separated list of dimensions to group results by. - `Filters param.Field[string]` Query param: Segmentation filter in 'attribute operator value' format. - `Limit param.Field[int64]` Query param: Limit number of returned metrics. - `Metrics param.Field[string]` Query param: A comma-separated list of metrics to query. - `Since param.Field[Time]` Query param: Start date and time of requesting data period in ISO 8601 format. - `Sort param.Field[string]` Query param: A comma-separated list of dimensions to sort by, where each dimension may be prefixed by - (descending) or + (ascending). - `Until param.Field[Time]` Query param: End date and time of requesting data period in ISO 8601 format. ### Returns - `type Report struct{…}` - `Data []ReportData` Array with one row per combination of dimension values. - `Dimensions []string` Array of dimension values, representing the combination of dimension values corresponding to this row. - `Metrics []float64` Array with one item per requested metric. Each item is a single value. - `DataLag float64` Number of seconds between current time and last processed event, in another words how many seconds of data could be missing. - `Max unknown` Maximum results for each metric (object mapping metric names to values). Currently always an empty object. - `Min unknown` Minimum results for each metric (object mapping metric names to values). Currently always an empty object. - `Query ReportQuery` - `Dimensions []string` Array of dimension names. - `Limit int64` Limit number of returned metrics. - `Metrics []string` Array of metric names. - `Since Time` Start date and time of requesting data period in ISO 8601 format. - `Until Time` End date and time of requesting data period in ISO 8601 format. - `Filters string` Segmentation filter in 'attribute operator value' format. - `Sort []string` Array of dimensions to sort by, where each dimension may be prefixed by - (descending) or + (ascending). - `Rows float64` Total number of rows in the result. - `Totals unknown` Total results for metrics across all data (object mapping metric names to values). ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/dns" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) report, err := client.DNS.Analytics.Reports.Get(context.TODO(), dns.AnalyticsReportGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", report.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": [ "NODATA" ], "metrics": [ 0 ] } ], "data_lag": 60, "max": {}, "min": {}, "query": { "dimensions": [ "responseCode", "queryName" ], "limit": 100, "metrics": [ "queryCount", "responseTimeAvg" ], "since": "2023-11-11T12:00:00Z", "until": "2023-11-11T13:00:00Z", "filters": "responseCode==NOERROR,queryType==A", "sort": [ "+responseCode", "-queryName" ] }, "rows": 100, "totals": {} } } ``` ## Domain Types ### Report - `type Report struct{…}` - `Data []ReportData` Array with one row per combination of dimension values. - `Dimensions []string` Array of dimension values, representing the combination of dimension values corresponding to this row. - `Metrics []float64` Array with one item per requested metric. Each item is a single value. - `DataLag float64` Number of seconds between current time and last processed event, in another words how many seconds of data could be missing. - `Max unknown` Maximum results for each metric (object mapping metric names to values). Currently always an empty object. - `Min unknown` Minimum results for each metric (object mapping metric names to values). Currently always an empty object. - `Query ReportQuery` - `Dimensions []string` Array of dimension names. - `Limit int64` Limit number of returned metrics. - `Metrics []string` Array of metric names. - `Since Time` Start date and time of requesting data period in ISO 8601 format. - `Until Time` End date and time of requesting data period in ISO 8601 format. - `Filters string` Segmentation filter in 'attribute operator value' format. - `Sort []string` Array of dimensions to sort by, where each dimension may be prefixed by - (descending) or + (ascending). - `Rows float64` Total number of rows in the result. - `Totals unknown` Total results for metrics across all data (object mapping metric names to values). # Bytimes ## By Time `client.DNS.Analytics.Reports.Bytimes.Get(ctx, params) (*ByTime, error)` **get** `/zones/{zone_id}/dns_analytics/report/bytime` Retrieves a list of aggregate metrics grouped by time interval. See [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) for detailed information about the available query parameters. ### Parameters - `params AnalyticsReportBytimeGetParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Dimensions param.Field[string]` Query param: A comma-separated list of dimensions to group results by. - `Filters param.Field[string]` Query param: Segmentation filter in 'attribute operator value' format. - `Limit param.Field[int64]` Query param: Limit number of returned metrics. - `Metrics param.Field[string]` Query param: A comma-separated list of metrics to query. - `Since param.Field[Time]` Query param: Start date and time of requesting data period in ISO 8601 format. - `Sort param.Field[string]` Query param: A comma-separated list of dimensions to sort by, where each dimension may be prefixed by - (descending) or + (ascending). - `TimeDelta param.Field[AnalyticsReportBytimeGetParamsTimeDelta]` Query param: Unit of time to group data by. - `const AnalyticsReportBytimeGetParamsTimeDeltaAll AnalyticsReportBytimeGetParamsTimeDelta = "all"` - `const AnalyticsReportBytimeGetParamsTimeDeltaAuto AnalyticsReportBytimeGetParamsTimeDelta = "auto"` - `const AnalyticsReportBytimeGetParamsTimeDeltaYear AnalyticsReportBytimeGetParamsTimeDelta = "year"` - `const AnalyticsReportBytimeGetParamsTimeDeltaQuarter AnalyticsReportBytimeGetParamsTimeDelta = "quarter"` - `const AnalyticsReportBytimeGetParamsTimeDeltaMonth AnalyticsReportBytimeGetParamsTimeDelta = "month"` - `const AnalyticsReportBytimeGetParamsTimeDeltaWeek AnalyticsReportBytimeGetParamsTimeDelta = "week"` - `const AnalyticsReportBytimeGetParamsTimeDeltaDay AnalyticsReportBytimeGetParamsTimeDelta = "day"` - `const AnalyticsReportBytimeGetParamsTimeDeltaHour AnalyticsReportBytimeGetParamsTimeDelta = "hour"` - `const AnalyticsReportBytimeGetParamsTimeDeltaDekaminute AnalyticsReportBytimeGetParamsTimeDelta = "dekaminute"` - `const AnalyticsReportBytimeGetParamsTimeDeltaMinute AnalyticsReportBytimeGetParamsTimeDelta = "minute"` - `Until param.Field[Time]` Query param: End date and time of requesting data period in ISO 8601 format. ### Returns - `type ByTime struct{…}` - `Data []ByTimeData` Array with one row per combination of dimension values. - `Dimensions []string` Array of dimension values, representing the combination of dimension values corresponding to this row. - `Metrics [][]float64` Array with one item per requested metric. Each item is an array of values, broken down by time interval. - `DataLag float64` Number of seconds between current time and last processed event, in another words how many seconds of data could be missing. - `Max unknown` Maximum results for each metric (object mapping metric names to values). Currently always an empty object. - `Min unknown` Minimum results for each metric (object mapping metric names to values). Currently always an empty object. - `Query ByTimeQuery` - `Dimensions []string` Array of dimension names. - `Limit int64` Limit number of returned metrics. - `Metrics []string` Array of metric names. - `Since Time` Start date and time of requesting data period in ISO 8601 format. - `TimeDelta ByTimeQueryTimeDelta` Unit of time to group data by. - `const ByTimeQueryTimeDeltaAll ByTimeQueryTimeDelta = "all"` - `const ByTimeQueryTimeDeltaAuto ByTimeQueryTimeDelta = "auto"` - `const ByTimeQueryTimeDeltaYear ByTimeQueryTimeDelta = "year"` - `const ByTimeQueryTimeDeltaQuarter ByTimeQueryTimeDelta = "quarter"` - `const ByTimeQueryTimeDeltaMonth ByTimeQueryTimeDelta = "month"` - `const ByTimeQueryTimeDeltaWeek ByTimeQueryTimeDelta = "week"` - `const ByTimeQueryTimeDeltaDay ByTimeQueryTimeDelta = "day"` - `const ByTimeQueryTimeDeltaHour ByTimeQueryTimeDelta = "hour"` - `const ByTimeQueryTimeDeltaDekaminute ByTimeQueryTimeDelta = "dekaminute"` - `const ByTimeQueryTimeDeltaMinute ByTimeQueryTimeDelta = "minute"` - `Until Time` End date and time of requesting data period in ISO 8601 format. - `Filters string` Segmentation filter in 'attribute operator value' format. - `Sort []string` Array of dimensions to sort by, where each dimension may be prefixed by - (descending) or + (ascending). - `Rows float64` Total number of rows in the result. - `TimeIntervals [][]Time` Array of time intervals in the response data. Each interval is represented as an array containing two values: the start time, and the end time. - `Totals unknown` Total results for metrics across all data (object mapping metric names to values). ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/dns" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) byTime, err := client.DNS.Analytics.Reports.Bytimes.Get(context.TODO(), dns.AnalyticsReportBytimeGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) 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": [ "NODATA" ], "metrics": [ [ 0 ] ] } ], "data_lag": 60, "max": {}, "min": {}, "query": { "dimensions": [ "responseCode", "queryName" ], "limit": 100, "metrics": [ "queryCount", "responseTimeAvg" ], "since": "2023-11-11T12:00:00Z", "time_delta": "hour", "until": "2023-11-11T13:00:00Z", "filters": "responseCode==NOERROR,queryType==A", "sort": [ "+responseCode", "-queryName" ] }, "rows": 100, "time_intervals": [ [ "2023-11-11T12:00:00Z" ] ], "totals": {} } } ``` ## Domain Types ### By Time - `type ByTime struct{…}` - `Data []ByTimeData` Array with one row per combination of dimension values. - `Dimensions []string` Array of dimension values, representing the combination of dimension values corresponding to this row. - `Metrics [][]float64` Array with one item per requested metric. Each item is an array of values, broken down by time interval. - `DataLag float64` Number of seconds between current time and last processed event, in another words how many seconds of data could be missing. - `Max unknown` Maximum results for each metric (object mapping metric names to values). Currently always an empty object. - `Min unknown` Minimum results for each metric (object mapping metric names to values). Currently always an empty object. - `Query ByTimeQuery` - `Dimensions []string` Array of dimension names. - `Limit int64` Limit number of returned metrics. - `Metrics []string` Array of metric names. - `Since Time` Start date and time of requesting data period in ISO 8601 format. - `TimeDelta ByTimeQueryTimeDelta` Unit of time to group data by. - `const ByTimeQueryTimeDeltaAll ByTimeQueryTimeDelta = "all"` - `const ByTimeQueryTimeDeltaAuto ByTimeQueryTimeDelta = "auto"` - `const ByTimeQueryTimeDeltaYear ByTimeQueryTimeDelta = "year"` - `const ByTimeQueryTimeDeltaQuarter ByTimeQueryTimeDelta = "quarter"` - `const ByTimeQueryTimeDeltaMonth ByTimeQueryTimeDelta = "month"` - `const ByTimeQueryTimeDeltaWeek ByTimeQueryTimeDelta = "week"` - `const ByTimeQueryTimeDeltaDay ByTimeQueryTimeDelta = "day"` - `const ByTimeQueryTimeDeltaHour ByTimeQueryTimeDelta = "hour"` - `const ByTimeQueryTimeDeltaDekaminute ByTimeQueryTimeDelta = "dekaminute"` - `const ByTimeQueryTimeDeltaMinute ByTimeQueryTimeDelta = "minute"` - `Until Time` End date and time of requesting data period in ISO 8601 format. - `Filters string` Segmentation filter in 'attribute operator value' format. - `Sort []string` Array of dimensions to sort by, where each dimension may be prefixed by - (descending) or + (ascending). - `Rows float64` Total number of rows in the result. - `TimeIntervals [][]Time` Array of time intervals in the response data. Each interval is represented as an array containing two values: the start time, and the end time. - `Totals unknown` Total results for metrics across all data (object mapping metric names to values).