Metrics - Get

Retrieve metric data
Gets metric values for a single metric

GET https://api.applicationinsights.io/v1/apps/{appId}/metrics/{metricId}
GET https://api.applicationinsights.io/v1/apps/{appId}/metrics/{metricId}?timespan={timespan}&interval={interval}&aggregation={aggregation}&segment={segment}&top={top}&orderby={orderby}&filter={filter}

URI Parameters

Name In Required Type Description
appId
path True

string

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

metricId
path True

MetricId

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

aggregation
query

MetricsAggregation[]

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.

filter
query

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.

interval
query

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.

orderby
query

string

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

segment
query

MetricsSegment[]

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.

timespan
query

string

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.

top
query

integer

int32

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

Responses

Name Type Description
200 OK

metricsResult

Successful response

Other Status Codes

errorResponse

An error response object.

Security

oauth2

Connect to Azure Application Insights API

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize?resource=https%3A%2F%2Fapi.applicationinsights.io

Scopes

Name Description
user_impersonation impersonate your user account

Examples

intervaledMetric
segmentedIntervaledMetric
simpleMetric

intervaledMetric

Sample request

GET https://api.applicationinsights.io/v1/apps/DEMO_APP/metrics/requests%2Fcount?timespan=P2D&interval=P1D

Sample response

{
  "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
        }
      }
    ]
  }
}

segmentedIntervaledMetric

Sample request

GET https://api.applicationinsights.io/v1/apps/DEMO_APP/metrics/requests%2Fcount?timespan=P2D&interval=P1D&segment=operation/name,request/success

Sample response

{
  "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
          }
        ]
      }
    ]
  }
}

simpleMetric

Sample request

GET https://api.applicationinsights.io/v1/apps/DEMO_APP/metrics/requests%2Fcount

Sample response

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

Definitions

Name Description
errorDetail

Error details.

errorInfo

The code and message for an error.

errorResponse

Error details.

MetricId

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

MetricsAggregation

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.

metricsResult

A metric result.

metricsResultInfo

A metric result data.

MetricsSegment

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.

metricsSegmentInfo

A metric segment

errorDetail

Error details.

Name Type Description
additionalProperties

object

code

string

The error's code.

message

string

A human readable error message.

resources

string[]

Indicates resources which were responsible for the error.

target

string

Indicates which property in the request is responsible for the error.

value

string

Indicates which value in 'target' is responsible for the error.

errorInfo

The code and message for an error.

Name Type Description
additionalProperties

object

code

string

A machine readable error code.

details

errorDetail[]

error details.

innererror

errorInfo

The code and message for an error.
Inner error details if they exist.

message

string

A human readable error message.

errorResponse

Error details.

Name Type Description
error

errorInfo

The code and message for an error.
The error details.

MetricId

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

Value Description
availabilityResults/availabilityPercentage
availabilityResults/duration
billing/telemetryCount
client/networkDuration
client/processingDuration
client/receiveDuration
client/sendDuration
client/totalDuration
customEvents/count
dependencies/count
dependencies/duration
dependencies/failed
exceptions/browser
exceptions/count
exceptions/server
pageViews/count
pageViews/duration
performanceCounters/exceptionsPerSecond
performanceCounters/memoryAvailableBytes
performanceCounters/processCpuPercentage
performanceCounters/processIOBytesPerSecond
performanceCounters/processPrivateBytes
performanceCounters/processorCpuPercentage
performanceCounters/requestExecutionTime
performanceCounters/requestsInQueue
performanceCounters/requestsPerSecond
requests/count
requests/duration
requests/failed
sessions/count
users/authenticated
users/count

MetricsAggregation

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.

Value Description
avg
count
max
min
sum
unique

metricsResult

A metric result.

Name Type Description
value

metricsResultInfo

A metric result data.

metricsResultInfo

A metric result data.

Name Type Description
end

string

Start time of the metric.

interval

string

The interval used to segment the metric data.

segments

metricsSegmentInfo[]

Segmented metric data (if segmented).

start

string

Start time of the metric.

MetricsSegment

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.

Value Description
applicationBuild
applicationVersion
authenticatedOrAnonymousTraffic
browser
browserVersion
city
cloudRoleName
cloudServiceName
continent
countryOrRegion
deploymentId
deploymentUnit
deviceType
environment
hostingLocation
instanceName

metricsSegmentInfo

A metric segment

Name Type Description
end

string

Start time of the metric segment (only when an interval was specified).

segments

metricsSegmentInfo[]

Segmented metric data (if further segmented).

start

string

Start time of the metric segment (only when an interval was specified).