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.

Name Type Description
availabilityResults/availabilityPercentage

string

availabilityResults/duration

string

billing/telemetryCount

string

client/networkDuration

string

client/processingDuration

string

client/receiveDuration

string

client/sendDuration

string

client/totalDuration

string

customEvents/count

string

dependencies/count

string

dependencies/duration

string

dependencies/failed

string

exceptions/browser

string

exceptions/count

string

exceptions/server

string

pageViews/count

string

pageViews/duration

string

performanceCounters/exceptionsPerSecond

string

performanceCounters/memoryAvailableBytes

string

performanceCounters/processCpuPercentage

string

performanceCounters/processIOBytesPerSecond

string

performanceCounters/processPrivateBytes

string

performanceCounters/processorCpuPercentage

string

performanceCounters/requestExecutionTime

string

performanceCounters/requestsInQueue

string

performanceCounters/requestsPerSecond

string

requests/count

string

requests/duration

string

requests/failed

string

sessions/count

string

users/authenticated

string

users/count

string

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.

Name Type Description
avg

string

count

string

max

string

min

string

sum

string

unique

string

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.

Name Type Description
applicationBuild

string

applicationVersion

string

authenticatedOrAnonymousTraffic

string

browser

string

browserVersion

string

city

string

cloudRoleName

string

cloudServiceName

string

continent

string

countryOrRegion

string

deploymentId

string

deploymentUnit

string

deviceType

string

environment

string

hostingLocation

string

instanceName

string

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).