Retrieve metric data

Gets metric values for a single metric

HTTP request

GET /v1/apps/{appId}/metrics/{metricId}

Security

Type Description
API key

Pass the API key via an X-Api-Key custom header or an api_key query parameter. [More info about authorization]

Basic Auth

Use the API key as either username or password with normal HTTP basic auth [More info about authorization]

Azure AAD Auth

Pass the AAD auth token in the 'Authorization' header. [More info about authorization]

URL parameters

Name Value Description
appId string

ID of the application. This is Application ID from the API Access settings blade in the Azure portal.

metricId string

ID of the metric. This is either a standard AI metric, or an application-specific custom metric.

Query parameters

Name Value Description
timespan string (interval)

The timespan over which to retrieve metric values. This is an ISO8601 time period value. If timespan is omitted, a default time range of PT12H ("last 12 hours") is used. The actual timespan that is queried may be adjusted by the server based. In all cases, the actual time span used for the query is included in the response.

interval string (duration)

The time interval to use when retrieving metric values. This is an ISO8601 duration. If interval is omitted, the metric value is aggregated across the entire timespan. If interval is supplied, the server may adjust the interval to a more appropriate size based on the timespan used for the query. In all cases, the actual interval used for the query is included in the response.

aggregation array (csv)

The aggregation to use when computing the metric values. To retrieve more than one aggregation at a time, separate them with a comma. If no aggregation is specified, then the default aggregation for the metric is used.

segment array (csv)

The name of the dimension to segment the metric values by. This dimension must be applicable to the metric you are retrieving. To segment by more than one dimension at a time, separate them with a comma (,). In this case, the metric data will be segmented in the order the dimensions are listed in the parameter.

top integer (int32)

The number of segments to return. This value is only valid when segment is specified.

orderby string

The aggregation function and direction to sort the segments by. This value is only valid when segment is specified.

filter string

An expression used to filter the results. This value should be a valid OData filter expression where the keys of each clause should be applicable dimensions for the metric you are retrieving.

Responses

Status Code Description
200 Successful response
400 Bad Request. The request was invalid; can be caused by a bad API request body, or errors in the Analytics query in the request
401 Unauthorized. No authentication was provided; authenticate and re-issue the API call
402 Payment required (the app is not in a required pricing tier)
403 Forbidden. Authentication was provided, but the caller did not have the necessary permissions
404 Invalid appId or metricId
429 Too many requests
500 Internal Server Error. The service experienced an unexpected error while processing the request
502 Bad Gateway. A downstream service dependency experienced an internal service error while processing the request
503 Service unavailable
504 Gateway Timeout. A downstream service dependency timed out while processing the request

Examples


Gets request count metric

Parameters:

{
  "appId": "DEMO_APP",
  "metricId": "requests%2Fcount"
}

Response:

{
  "body": {
    "value": {
      "start": "2016-01-01T02:00:00.000Z",
      "end": "2016-01-03T02:00:00.000Z",
      "requests/count": {
        "sum": 23
      }
    }
  }
}

Gets intervaled request count metric

Parameters:

{
  "appId": "DEMO_APP",
  "metricId": "requests%2Fcount",
  "timespan": "P2D",
  "interval": "P1D"
}

Response:

{
  "body": {
    "value": {
      "start": "2018-02-04T10:01:35.086Z",
      "end": "2018-02-06T10:01:35.086Z",
      "interval": "P1D",
      "segments": [
        {
          "start": "2018-02-04T10:01:35.086Z",
          "end": "2018-02-05T00:00:00.000Z",
          "requests/count": {
            "sum": 4927
          }
        },
        {
          "start": "2018-02-05T00:00:00.000Z",
          "end": "2018-02-06T00:00:00.000Z",
          "requests/count": {
            "sum": 8460
          }
        },
        {
          "start": "2018-02-06T00:00:00.000Z",
          "end": "2018-02-06T10:01:35.086Z",
          "requests/count": {
            "sum": 3743
          }
        }
      ]
    }
  }
}

Gets intervaled and segmented metric

Parameters:

{
  "appId": "DEMO_APP",
  "metricId": "requests%2Fcount",
  "timespan": "P2D",
  "interval": "P1D",
  "segment": "operation/name,request/success"
}

Response:

{
  "body": {
    "value": {
      "start": "2018-10-22T10:40:09.065Z",
      "end": "2018-10-22T22:40:09.065Z",
      "segments": [
        {
          "operation/name": "GET Home/Index",
          "segments": [
            {
              "requests/count": null,
              "sum": 156483,
              "request/success": false
            },
            {
              "requests/count": null,
              "sum": 3795,
              "request/success": true
            }
          ]
        },
        {
          "operation/name": "GET /",
          "segments": [
            {
              "requests/count": null,
              "sum": 34168,
              "request/success": false
            },
            {
              "requests/count": null,
              "sum": 12,
              "request/success": true
            }
          ]
        },
        {
          "operation/name": "GET /FabrikamProd/Content/fonts/segoewp-light-webfont.eot",
          "segments": [
            {
              "requests/count": null,
              "sum": 9378,
              "request/success": true
            }
          ]
        },
        {
          "operation/name": "GET /FabrikamProd/Content/fonts/segoewp-webfont.eot",
          "segments": [
            {
              "requests/count": null,
              "sum": 9370,
              "request/success": true
            }
          ]
        },
        {
          "operation/name": "GET ServiceTickets/Details",
          "segments": [
            {
              "requests/count": null,
              "sum": 1989,
              "request/success": false
            },
            {
              "requests/count": null,
              "sum": 14,
              "request/success": true
            }
          ]
        },
        {
          "operation/name": "GET ServiceTickets/Index",
          "segments": [
            {
              "requests/count": null,
              "sum": 1991,
              "request/success": true
            }
          ]
        },
        {
          "operation/name": "GET Employees/Index",
          "segments": [
            {
              "requests/count": null,
              "sum": 1990,
              "request/success": true
            }
          ]
        },
        {
          "operation/name": "GET ServiceTickets/GetLogEntries",
          "segments": [
            {
              "requests/count": null,
              "sum": 1985,
              "request/success": true
            }
          ]
        },
        {
          "operation/name": "GET Employees/Details",
          "segments": [
            {
              "requests/count": null,
              "sum": 663,
              "request/success": false
            },
            {
              "requests/count": null,
              "sum": 663,
              "request/success": true
            }
          ]
        },
        {
          "operation/name": "GET Reports/Index",
          "segments": [
            {
              "requests/count": null,
              "sum": 1086,
              "request/success": true
            }
          ]
        }
      ]
    }
  }
}