swagger: "2.0"
schemes:
  - https
host: management.azure.com
info:
  title: MonitorManagementClient
  version: 2018-01-01
  x-apisguru-categories:
    - cloud
  x-logo:
    url: https://api.apis.guru/v2/cache/logo/https_assets.onestore.ms_cdnfiles_onestorerolling-1606-01000_shell_v3_images_logo_microsoft.png
  x-ms-code-generation-settings:
    name: MonitorManagementClient
  x-origin:
    - format: swagger
      url: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/metrics_API.json
      version: "2.0"
  x-preferred: true
  x-providerName: azure.com
  x-serviceName: monitor-metrics_API
  x-tags:
    - Azure
    - Microsoft
consumes:
  - application/json
produces:
  - application/json
securityDefinitions:
  azure_auth:
    authorizationUrl: https://login.microsoftonline.com/common/oauth2/authorize
    description: Azure Active Directory OAuth2 Flow
    flow: implicit
    scopes:
      user_impersonation: impersonate your user account
    type: oauth2
security:
  - azure_auth:
      - user_impersonation
parameters:
  AggregationsParameter:
    description: The list of aggregation types (comma separated) to retrieve.
    in: query
    name: aggregation
    required: false
    type: string
    x-ms-parameter-location: method
  ApiVersionParameter:
    description: Client Api Version.
    in: query
    name: api-version
    required: true
    type: string
  IntervalParameter:
    description: The interval (i.e. timegrain) of the query.
    format: duration
    in: query
    name: interval
    required: false
    type: string
    x-ms-parameter-location: method
  MetricNamesParameter:
    description: The names of the metrics (comma separated) to retrieve.
    in: query
    name: metricnames
    required: false
    type: string
    x-ms-parameter-location: method
  MetricNamespaceParameter:
    description: Metric namespace to query metric definitions for.
    in: query
    name: metricnamespace
    required: false
    type: string
    x-ms-parameter-location: method
  OrderByParameter:
    description: |-
      The aggregation to use for sorting results and the direction of the sort.
      Only one order can be specified.
      Examples: sum asc.
    in: query
    name: orderby
    required: false
    type: string
    x-ms-parameter-location: method
  ResourceUriParameter:
    description: The identifier of the resource.
    in: path
    name: resourceUri
    required: true
    type: string
    x-ms-parameter-location: method
    x-ms-skip-url-encoding: true
  ResultTypeParameter:
    description: Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's description for details.
    enum:
      - Data
      - Metadata
    in: query
    name: resultType
    required: false
    type: string
    x-ms-enum:
      modelAsString: false
      name: ResultType
    x-ms-parameter-location: method
  TimespanParameter:
    description: The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'.
    in: query
    name: timespan
    required: false
    type: string
    x-ms-parameter-location: method
  TopParameter:
    description: |-
      The maximum number of records to retrieve.
      Valid only if $filter is specified.
      Defaults to 10.
    format: int32
    in: query
    name: top
    required: false
    type: integer
    x-ms-parameter-location: method
paths:
  "/{resourceUri}/providers/microsoft.insights/metrics":
    get:
      description: "**Lists the metric values for a resource**."
      operationId: Metrics_List
      parameters:
        - $ref: "#/parameters/ResourceUriParameter"
        - $ref: "#/parameters/TimespanParameter"
        - $ref: "#/parameters/IntervalParameter"
        - $ref: "#/parameters/MetricNamesParameter"
        - $ref: "#/parameters/AggregationsParameter"
        - $ref: "#/parameters/TopParameter"
        - $ref: "#/parameters/OrderByParameter"
        - description: The **$filter** is used to reduce the set of metric data returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series of C where A = a1 and B = b1 or b2<br>**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**<br>- Invalid variant:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**.
          in: query
          name: $filter
          required: false
          type: string
        - $ref: "#/parameters/ResultTypeParameter"
        - $ref: "#/parameters/ApiVersionParameter"
        - $ref: "#/parameters/MetricNamespaceParameter"
      responses:
        "200":
          description: Successful request to get the list of metric values.
          schema:
            $ref: "#/definitions/Response"
        default:
          description: Error response describing why the operation failed.
          schema:
            $ref: "#/definitions/ErrorResponse"
      tags:
        - Metrics
      x-ms-examples:
        Get Metric for data:
          parameters:
            $filter: BlobType eq '*'
            aggregation: Average,count
            api-version: 2018-01-01
            interval: PT1M
            metric: BlobCapacity
            metricnamespace: Microsoft.Storage/storageAccounts/blobServices
            orderby: Average asc
            resourceUri: subscriptions/b324c52b-4073-4807-93af-e07d289c093e/resourceGroups/test/providers/Microsoft.Storage/storageAccounts/larryshoebox/blobServices/default
            timespan: 2017-04-14T02:20:00Z/2017-04-14T04:20:00Z
            top: 3
          responses:
            "200":
              body:
                cost: 0
                interval: PT1M
                namespace: Microsoft.Storage/storageAccounts/blobServices
                resourceregion: eastus2
                timespan: 2017-04-14T02:20:00Z/2017-04-14T04:20:00Z
                value:
                  - id: /subscriptions/b324c52b-4073-4807-93af-e07d289c093e/resourceGroups/test/providers/Microsoft.Storage/storageAccounts/larryshoebox/blobServices/default/providers/Microsoft.Insights/metrics/BlobCapacity
                    name:
                      localizedValue: Blob Capacity
                      value: BlobCapacity
                    timeseries:
                      - data:
                          - count: 0
                            timeStamp: 2017-04-14T02:20:00Z
                          - count: 0
                            timeStamp: 2017-04-14T02:21:00Z
                          - count: 0
                            timeStamp: 2017-04-14T02:22:00Z
                          - average: 0
                            count: 1
                            timeStamp: 2017-04-14T02:23:00Z
                        metadatavalues:
                          - name:
                              localizedValue: blobtype
                              value: blobtype
                            value: PageBlob
                      - data:
                          - count: 0
                            timeStamp: 2017-04-14T02:20:00Z
                          - count: 0
                            timeStamp: 2017-04-14T02:21:00Z
                          - count: 0
                            timeStamp: 2017-04-14T02:22:00Z
                          - average: 245
                            count: 1
                            timeStamp: 2017-04-14T02:23:00Z
                        metadatavalues:
                          - name:
                              localizedValue: blobtype
                              value: blobtype
                            value: BlockBlob
                    type: Microsoft.Insights/metrics
                    unit: Bytes
        Get Metric for metadata:
          parameters:
            $filter: BlobType eq '*'
            aggregation: Average,count
            api-version: 2018-01-01
            interval: PT1M
            metric: BlobCapacity
            metricnamespace: Microsoft.Storage/storageAccounts/blobServices
            orderby: Average asc
            resourceUri: subscriptions/b324c52b-4073-4807-93af-e07d289c093e/resourceGroups/test/providers/Microsoft.Storage/storageAccounts/larryshoebox/blobServices/default
            resulttype: metadata
            timespan: 2017-04-14T02:20:00Z/2017-04-14T04:20:00Z
            top: 3
          responses:
            "200":
              body:
                namespace: Microsoft.Storage/storageAccounts/blobServices
                resourceregion: eastus2
                timespan: 2017-04-14T02:20:00Z/2017-04-14T04:20:00Z
                value:
                  - id: /subscriptions/b324c52b-4073-4807-93af-e07d289c093e/resourceGroups/test/providers/Microsoft.Storage/storageAccounts/larryshoebox/blobServices/default/providers/Microsoft.Insights/metrics/BlobCapacity
                    name:
                      localizedValue: Blob Capacity
                      value: BlobCapacity
                    timeseries:
                      - metadatavalues:
                          - name:
                              localizedValue: blobtype
                              value: blobtype
                            value: BlockBlob
                      - metadatavalues:
                          - name:
                              localizedValue: blobtype
                              value: blobtype
                            value: PageBlob
                    type: Microsoft.Insights/metrics
                    unit: Bytes
      x-ms-odata: "#/definitions/MetadataValue"
definitions:
  ErrorResponse:
    description: Describes the format of Error response.
    properties:
      code:
        description: Error code
        type: string
      message:
        description: Error message indicating why the operation failed.
        type: string
    type: object
  LocalizableString:
    description: The localizable string class.
    properties:
      localizedValue:
        description: the locale specific value.
        type: string
      value:
        description: the invariant value.
        type: string
    required:
      - value
  MetadataValue:
    description: Represents a metric metadata value.
    properties:
      name:
        $ref: "#/definitions/LocalizableString"
        description: the name of the metadata.
      value:
        description: the value of the metadata.
        type: string
  Metric:
    description: The result data of a query.
    properties:
      id:
        description: the metric Id.
        type: string
      name:
        $ref: "#/definitions/LocalizableString"
        description: the name and the display name of the metric, i.e. it is localizable string.
      timeseries:
        description: the time series returned when a data query is performed.
        items:
          $ref: "#/definitions/TimeSeriesElement"
        type: array
      type:
        description: the resource type of the metric resource.
        type: string
      unit:
        $ref: "#/definitions/Unit"
        description: the unit of the metric.
    required:
      - id
      - type
      - name
      - unit
      - timeseries
    type: object
  MetricValue:
    description: Represents a metric value.
    properties:
      average:
        description: the average value in the time range.
        format: double
        type: number
      count:
        description: the number of samples in the time range. Can be used to determine the number of values that contributed to the average value.
        format: double
        type: number
      maximum:
        description: the greatest value in the time range.
        format: double
        type: number
      minimum:
        description: the least value in the time range.
        format: double
        type: number
      timeStamp:
        description: the timestamp for the metric value in ISO 8601 format.
        format: date-time
        type: string
      total:
        description: the sum of all of the values in the time range.
        format: double
        type: number
    required:
      - timeStamp
  Response:
    description: The response to a metrics query.
    properties:
      cost:
        description: The integer value representing the cost of the query, for data case.
        format: int32
        minimum: 0
        type: number
      interval:
        description: The interval (window size) for which the metric data was returned in.  This may be adjusted in the future and returned back from what was originally requested.  This is not present if a metadata request was made.
        format: duration
        type: string
      namespace:
        description: The namespace of the metrics been queried
        type: string
      resourceregion:
        description: The region of the resource been queried for metrics.
        type: string
      timespan:
        description: The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'.  This may be adjusted in the future and returned back from what was originally requested.
        type: string
      value:
        description: the value of the collection.
        items:
          $ref: "#/definitions/Metric"
        type: array
    required:
      - timespan
      - value
    type: object
  TimeSeriesElement:
    description: A time series result type. The discriminator value is always TimeSeries in this case.
    properties:
      data:
        description: An array of data points representing the metric values.  This is only returned if a result type of data is specified.
        items:
          $ref: "#/definitions/MetricValue"
        type: array
      metadatavalues:
        description: the metadata values returned if $filter was specified in the call.
        items:
          $ref: "#/definitions/MetadataValue"
        type: array
    type: object
  Unit:
    description: the unit of the metric.
    enum:
      - Count
      - Bytes
      - Seconds
      - CountPerSecond
      - BytesPerSecond
      - Percent
      - MilliSeconds
      - ByteSeconds
      - Unspecified
      - Cores
      - MilliCores
      - NanoCores
      - BitsPerSecond
    type: string
    x-ms-enum:
      modelAsString: false
      name: Unit
