> ## Documentation Index
> Fetch the complete documentation index at: https://gcore.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Get CDN metrics



## OpenAPI

````yaml /api-reference/services_documented/cdn_api.yaml post /cdn/advanced/v1/metrics
openapi: 3.1.0
info:
  title: Gcore OpenAPI – CDN API
  description: >-
    This OpenAPI is an aggregated OpenAPI specification that unifies all Gcore
    products into a single file. It covers Cloud, CDN, DNS, WAAP, DDoS
    Protection, Object Storage, Streaming, and FastEdge services.
  version: '2026-05-14T07:00:22.640261+00:00'
servers:
  - url: https://api.gcore.com
security:
  - APIKey: []
tags:
  - name: CDN service
    description: Information about the current state of the CDN service in your account.
    x-displayName: CDN service
  - name: CDN resources
    x-displayName: CDN resources
  - name: Origins
    x-displayName: Origins
  - name: Rules
    description: >-
      Rules allow to set up custom settings for certain file types or paths.

      By default, the rule inherits all options values from the related CDN
      resource.


      Each option in rule settings can be in one of the following states:

      - **Inherit** - Option is not added to the rule. Option inherits its value
      from the CDN resource settings. In this case, the option value is
      **null**.

      - **ON** - Option is added to the rule and enabled. Option values
      configured in the rule will override values from the CDN resource
      settings.

      - **OFF** - Option is added to the rule and disabled. Option will be
      turned off.
    x-displayName: Rules
  - name: Rule templates
    x-displayName: Rule templates
  - name: SSL certificates
    x-displayName: SSL certificates
  - name: Let's Encrypt certificates
    x-displayName: Let's Encrypt certificates
  - name: CA certificates
    x-displayName: CA certificates
  - name: CDN activity logs
    description: |-
      Get the history of users requests to CDN.
      It contains requests made both via the API and via the control panel.

      The following methods are not tracked in the activity logs:
      - HEAD
      - OPTIONS
    x-displayName: CDN activity logs
  - name: Log viewer
    description: >-
      Log viewer provides you with general information about CDN operation. This
      information does not contain all possible

      sets of fields and restricted by time. To receive full data, use Logs
      Uploader.
    x-displayName: Log viewer
  - name: Logs uploader
    description: >-
      Logs uploader allows you to upload logs with desired format to desired
      storages.


      Consists of three main parts:

      - **Policies** - rules that define which logs are uploaded and how they
      are uploaded.

      - **Targets** - destinations where logs are uploaded.

      - **Configs** - combinations of logs uploader policies, targets and
      resources to which they are applied.
    x-displayName: Logs uploader
  - name: Tools
    x-displayName: Tools
  - name: CDN Statistics
    description: >-
      Consumption statistics is updated in near real-time as a standard
      practice.

      However, the frequency of updates can vary, but they are typically
      available within a 24-hour period.

      Exceptions, such as maintenance periods, may delay data beyond 24 hours
      until servers resume and fill in the missing statistics.
    x-displayName: Statistics
  - name: Advanced analytics
    description: >-
      Advanced analytics allows to get statistics about unique visitors,
      traffic, and requests for countries, directories, browsers, devices, and
      operation systems for up to 90 days starting from today.


      Advanced analytics API is based on the [GraphQL
      framework](https://graphql.org/).


      Advanced analytics API has one single endpoint:

       https://api.gcore.com/cdn/advanced/v2/query

      You can pass the query parameters as a JSON object in the payload of a
      POST request to this endpoint.

      You can use curl to make requests to the Advanced analytics API.
      Alternatively, you can use a GraphQL client

      to construct queries and pass requests to the Advanced analytics API.


      You can write queries in GraphQL much like in SQL: specify the data set
      (CDN resource), the metrics

      to retrieve (such as unique visitors and traffic), and filter or group by
      dimensions (for example, a country).
    x-displayName: Advanced analytics
  - name: Origin shielding
    x-displayName: Origin shielding
  - name: IP addresses list
    x-displayName: IP addresses list
  - name: Purge history
    x-displayName: Purge history
paths:
  /cdn/advanced/v1/metrics:
    post:
      tags:
        - CDN Statistics
      summary: Get CDN metrics
      operationId: get-cdn-metrics
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AdvancedMetricsRequest'
      responses:
        '200':
          description: Successful.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AdvancedMetricsResponse'
        '400':
          description: Request body contains invalid parameters or values.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AdvancedMetricsErrBadResponse'
        '500':
          description: Failed to get CDN metrics.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AdvancedMetricsErrResponse'
      x-codeSamples:
        - lang: Python
          source: |-
            import os
            from gcore import Gcore

            client = Gcore(
                api_key=os.environ.get("GCORE_API_KEY"),  # This is the default and can be omitted
            )
            cdn_metrics = client.cdn.metrics.list(
                from_="2021-06-14T00:00:00Z",
                metrics=["edge_status_2xx", "edge_status_3xx", "edge_status_4xx", "edge_status_5xx"],
                to="2021-06-15T00:00:00Z",
            )
            print(cdn_metrics.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/G-Core/gcore-go\"\n\t\"github.com/G-Core/gcore-go/cdn\"\n\t\"github.com/G-Core/gcore-go/option\"\n)\n\nfunc main() {\n\tclient := gcore.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tcdnMetrics, err := client.CDN.Metrics.List(context.TODO(), cdn.MetricListParams{\n\t\tFrom:    \"2021-06-14T00:00:00Z\",\n\t\tMetrics: []string{\"edge_status_2xx\", \"edge_status_3xx\", \"edge_status_4xx\", \"edge_status_5xx\"},\n\t\tTo:      \"2021-06-15T00:00:00Z\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", cdnMetrics.Data)\n}\n"
components:
  schemas:
    AdvancedMetricsRequest:
      type: object
      required:
        - metrics
        - from
        - to
      minProperties: 1
      properties:
        metrics:
          type: array
          minLength: 1
          example:
            - edge_status_2xx
            - edge_status_3xx
            - edge_status_4xx
            - edge_status_5xx
          items:
            type: string
          description: >-
            Possible values:

            - **`edge_bandwidth`** - Bandwidth from client to CDN (bit/s.)

            - **`edge_requests`** - Number of requests per interval
            (requests/s.)

            - **`edge_requests_total`** - Total number of requests per interval.

            - **`edge_status_1xx`** - Number of 1xx status codes from edge.

            - **`edge_status_200`** - Number of 200 status codes from edge.

            - **`edge_status_204`** - Number of 204 status codes from edge.

            - **`edge_status_206`** - Number of 206 status codes from edge.

            - **`edge_status_2xx`** - Number of 2xx status codes from edge.

            - **`edge_status_301`** - Number of 301 status codes from edge.

            - **`edge_status_302`** - Number of 302 status codes from edge.

            - **`edge_status_304`** - Number of 304 status codes from edge.

            - **`edge_status_3xx`** - Number of 3xx status codes from edge.

            - **`edge_status_400`** - Number of 400 status codes from edge.

            - **`edge_status_401`** - Number of 401 status codes from edge.

            - **`edge_status_403`** - Number of 403 status codes from edge.

            - **`edge_status_404`** - Number of 404 status codes from edge.

            - **`edge_status_416`** - Number of 416 status codes from edge.

            - **`edge_status_429`** - Number of 429 status codes from edge.

            - **`edge_status_4xx`** - Number of 4xx status codes from edge.

            - **`edge_status_500`** - Number of 500 status codes from edge.

            - **`edge_status_501`** - Number of 501 status codes from edge.

            - **`edge_status_502`** - Number of 502 status codes from edge.

            - **`edge_status_503`** - Number of 503 status codes from edge.

            - **`edge_status_504`** - Number of 504 status codes from edge.

            - **`edge_status_505`** - Number of 505 status codes from edge.

            - **`edge_status_5xx`** - Number of 5xx status codes from edge.

            - **`edge_hit_ratio`** - Percent of cache hits (0.0 - 1.0).

            - **`edge_hit_bytes`** - Number of bytes sent back when cache hits.

            - **`origin_bandwidth`** - Bandwidth from CDN to Origin (bit/s.)

            - **`origin_requests`** - Number of requests per interval
            (requests/s.)

            - **`origin_status_1xx`** - Number of 1xx status from origin.

            - **`origin_status_200`** - Number of 200 status from origin.

            - **`origin_status_204`** - Number of 204 status from origin.

            - **`origin_status_206`** - Number of 206 status from origin.

            - **`origin_status_2xx`** - Number of 2xx status from origin.

            - **`origin_status_301`** - Number of 301 status from origin.

            - **`origin_status_302`** - Number of 302 status from origin.

            - **`origin_status_304`** - Number of 304 status from origin.

            - **`origin_status_3xx`** - Number of 3xx status from origin.

            - **`origin_status_400`** - Number of 400 status from origin.

            - **`origin_status_401`** - Number of 401 status from origin.

            - **`origin_status_403`** - Number of 403 status from origin.

            - **`origin_status_404`** - Number of 404 status from origin.

            - **`origin_status_416`** - Number of 416 status from origin.

            - **`origin_status_429`** - Number of 426 status from origin.

            - **`origin_status_4xx`** - Number of 4xx status from origin.

            - **`origin_status_500`** - Number of 500 status from origin.

            - **`origin_status_501`** - Number of 501 status from origin.

            - **`origin_status_502`** - Number of 502 status from origin.

            - **`origin_status_503`** - Number of 503 status from origin.

            - **`origin_status_504`** - Number of 504 status from origin.

            - **`origin_status_505`** - Number of 505 status from origin.

            - **`origin_status_5xx`** - Number of 5xx status from origin.

            - **`edge_download_speed`** - Download speed from edge in KB/s
            (includes only requests that status was in the range [200, 300].)

            - **`origin_download_speed`** - Download speed from origin in KB/s
            (includes only requests that status was in the range [200, 300].)
        from:
          type: string
          example: '2021-06-14T00:00:00Z'
          description: >-
            Beginning period to fetch metrics (ISO 8601/RFC 3339 format, UTC.)


            Examples:

            - 2021-06-14T00:00:00Z

            - 2021-06-14T00:00:00.000Z


            The total number of points, which is determined as the difference
            between "from" and "to" divided by "granularity", cannot exceed
            1440.

            Exception: "speed" metrics are limited to 72 points.
        to:
          type: string
          example: '2021-06-15T00:00:00Z'
          description: >-
            Specifies ending period to fetch metrics (ISO 8601/RFC 3339 format,
            UTC)


            Examples:

            - 2021-06-15T00:00:00Z

            - 2021-06-15T00:00:00.000Z


            The total number of points, which is determined as the difference
            between "from" and "to" divided by "granularity", cannot exceed
            1440.

            Exception: "speed" metrics are limited to 72 points.
        group_by:
          type: array
          example:
            - cname
          items:
            type: string
          description: >-
            Output data grouping.


            Possible values:

            - **resource** - Data is grouped by CDN resource.

            - **cname** - Data is grouped by common names.

            - **region** – Data is grouped by regions (continents.) Available
            for "speed" metrics only.

            - **isp** - Data is grouped by ISP names. Available for "speed"
            metrics only.
        granularity:
          type: string
          default: PT1M
          format: P(n)Y(n)M(n)DT(n)H(n)M)
          example: P1D
          description: >-
            Duration of the time blocks into which the data is divided. The
            value must correspond to the ISO 8601 period format.


            Examples:

            - P1D

            - PT5M


            Notes:

            - The total number of points, which is determined as the difference
            between "from" and "to" divided by "granularity", cannot exceed
            1440.

            Exception: "speed" metrics are limited to 72 points.

            - For "speed" metrics the value must be a multiple of 5.
        filter_by:
          type: array
          description: Each item represents one filter statement.
          items:
            type: object
            required:
              - field
              - op
              - values
            properties:
              field:
                type: string
                example: resource
                description: >-
                  Defines the parameters by that data can be filtered.


                  Possible values:

                  - **resource** - Data is filtered by CDN resource ID.

                  - **cname** - Data is filtered by common name.

                  - **region** - Data is filtered by region (continent.)
                  Available for "speed" metrics only.

                  - **isp** - Data is filtered by ISP name. Available for
                  "speed" metrics only.
              op:
                type: string
                example: eq
                description: |-
                  Comparison operator to be applied.

                  Possible values:
                  - **in** - 'IN' operator.
                  - **`not_in`** - 'NOT IN' operator.
                  - **gt** - '>' operator.
                  - **gte** - '>=' operator.
                  - **lt** - '<' operator.
                  - **lte** - '<=' operator.
                  - **eq** - '==' operator.
                  - **ne** - '!=' operator.
                  - **like** - 'LIKE' operator.
                  - **`not_like`** - 'NOT LIKE' operator.
              values:
                type: array
                minLength: 1
                description: Contains one or more values to be compared against.
                example:
                  - 1234
                items:
                  oneOf:
                    - type: number
                    - type: string
    AdvancedMetricsResponse:
      properties:
        data:
          oneOf:
            - $ref: '#/components/schemas/AdvancedMetricsResponseValues'
            - $ref: '#/components/schemas/AdvancedMetricsResponseGroups'
          description: >-
            If no grouping was requested then "data" holds an array of metric
            values.

            If at least one field is specified in "group_by" then "data" is an
            object whose properties are groups, which may include other groups;

            the last group will hold array of metrics values.
      example:
        data:
          - edge_status_2xx: 21095299
            timestamp: 1623159320
          - edge_download_speed:
              0_250k: '0'
              250k_500k: '0'
              500k_750k: '0'
              750k_1M: '0'
              1M_2M: '0.09091'
              2M_3M: '0.1818'
              3M_4M: '0.1818'
              4M+: '0.5455'
            timestamp: 1623159380
    AdvancedMetricsErrBadResponse:
      properties:
        status:
          type: integer
          description: Contains HTTP status code.
        message:
          type: string
          description: This message describes error if body in your request is invalid.
      example:
        status: 400
        message: >-
          validation failure list:\ngroup_by.0 in body should be one of
          [resource cname]
    AdvancedMetricsErrResponse:
      properties:
        status:
          type: integer
          description: Contains HTTP status code.
        message:
          type: string
          description: This message describes error.
      example:
        status: 500
        message: Internal Server Error
    AdvancedMetricsResponseValues:
      type: array
      description: List of requested metrics sorted by timestamp in ascending order.
      items:
        minProperties: 2
        properties:
          timestamp:
            type: integer
            format: int64
            description: Start timestamp of interval.
          metric:
            type: number
            description: Metrics value.
      example:
        - edge_status_2xx: 21095299
          timestamp: 1623159320
        - edge_status_2xx: 62616980
          timestamp: 1623159380
    AdvancedMetricsResponseGroups:
      type: object
      minProperties: 1
      properties:
        group:
          description: Grouped metrics in accordance to "group_by" parameter.
          oneOf:
            - $ref: '#/components/schemas/AdvancedMetricsResponseValues'
      example:
        data:
          test.domain.com:
            - edge_status_2xx: 21095299
              timestamp: 1623159320
            - edge_status_2xx: 62616980
              timestamp: 1623159380
  securitySchemes:
    APIKey:
      description: >-
        API key for authentication. Make sure to include the word `apikey`,
        followed by a single space and then your token.

        Example: `apikey 1234$abcdef`
      type: apiKey
      in: header
      name: Authorization

````