{ "swagger": "2.0", "info": { "title": "Monitor Query Metrics", "version": "2024-02-01", "x-typespec-generated": [ { "emitter": "@azure-tools/typespec-autorest" } ] }, "schemes": [ "https" ], "x-ms-parameterized-host": { "hostTemplate": "{endpoint}", "useSchemePrefix": false, "parameters": [ { "name": "endpoint", "in": "path", "description": "The regional endpoint to use, for example https://eastus.metrics.monitor.azure.com. The region should match\nthe region of the requested resources. For global resources, the region should be 'global'.", "required": true, "type": "string", "format": "uri", "x-ms-skip-url-encoding": true } ] }, "produces": [ "application/json" ], "consumes": [ "application/json" ], "security": [ { "OAuth2Auth": [ "https://metrics.monitor.azure.com/.default" ] } ], "securityDefinitions": { "OAuth2Auth": { "type": "oauth2", "flow": "implicit", "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", "scopes": { "https://metrics.monitor.azure.com/.default": "" } } }, "tags": [], "paths": { "/subscriptions/{subscriptionId}/metrics:getBatch": { "post": { "operationId": "Batch", "description": "Lists the metric values for multiple resources.", "parameters": [ { "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" }, { "name": "subscriptionId", "in": "path", "description": "The subscription identifier for the resources in this batch.", "required": true, "type": "string", "format": "uuid" }, { "name": "starttime", "in": "query", "description": "The start time of the query. It is a string in the format\n'yyyy-MM-ddTHH:mm:ss.fffZ'. If you have specified the endtime parameter, then\nthis parameter is required.\nIf only starttime is specified, then endtime defaults to the current time.\nIf no time interval is specified, the default is 1 hour.", "required": false, "type": "string", "x-ms-client-name": "startTime" }, { "name": "endtime", "in": "query", "description": "The end time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'.", "required": false, "type": "string", "x-ms-client-name": "endTime" }, { "name": "interval", "in": "query", "description": "The interval (i.e. timegrain) of the query in ISO 8601 duration format.\nDefaults to PT1M. Special case for 'FULL' value that returns single datapoint\nfor entire time span requested.\n*Examples: PT15M, PT1H, P1D, FULL*", "required": false, "type": "string", "default": "PT1M" }, { "name": "metricnamespace", "in": "query", "description": "Metric namespace that contains the requested metric names.", "required": true, "type": "string", "x-ms-client-name": "metricNamespace" }, { "name": "metricnames", "in": "query", "description": "The names of the metrics (comma separated) to retrieve.", "required": true, "type": "array", "items": { "type": "string" }, "collectionFormat": "csv", "x-ms-client-name": "metricNames" }, { "name": "aggregation", "in": "query", "description": "The list of aggregation types (comma separated) to retrieve. *Examples: average, minimum, maximum*", "required": false, "type": "string" }, { "name": "top", "in": "query", "description": "The maximum number of records to retrieve per resource ID in the request.\nValid only if filter is specified.\nDefaults to 10.", "required": false, "type": "integer", "format": "int32" }, { "name": "orderby", "in": "query", "description": "The aggregation to use for sorting results and the direction of the sort.\nOnly one order can be specified.\n*Examples: sum asc*", "required": false, "type": "string", "x-ms-client-name": "orderBy" }, { "name": "filter", "in": "query", "description": "The filter is used to reduce the set of metric data\nreturned.
Example:
Metric contains metadata A, B and C.
- Return all\ntime series of C where A = a1 and B = b1 or b2
**filter=A eq ‘a1’ and B eq\n‘b1’ or B eq ‘b2’ and C eq ‘*’**
- Invalid variant:
**filter=A eq ‘a1’\nand B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**
This is invalid because the logical\nor operator cannot separate two different metadata names.
- Return all time\nseries where A = a1, B = b1 and C = c1:
**filter=A eq ‘a1’ and B eq ‘b1’ and\nC eq ‘c1’**
- Return all time series where A = a1
**filter=A eq ‘a1’ and\nB eq ‘*’ and C eq ‘*’**.", "required": false, "type": "string" }, { "name": "rollupby", "in": "query", "description": "Dimension name(s) to rollup results by. For example if you only want to see\nmetric values with a filter like 'City eq Seattle or City eq Tacoma' but don't\nwant to see separate values for each city, you can specify 'RollUpBy=City' to\nsee the results for Seattle and Tacoma rolled up into one timeseries.", "required": false, "type": "string", "x-ms-client-name": "rollUpBy" }, { "name": "batchRequest", "in": "body", "description": "Metrics batch body including the list of resource ids", "required": true, "schema": { "$ref": "#/definitions/ResourceIdList" } } ], "responses": { "200": { "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/MetricResultsResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "../../../../../common-types/resource-management/v5/types.json#/definitions/ErrorResponse" } } }, "x-ms-examples": { "Query Azure Cache for Redis metrics for multiple resources": { "$ref": "./examples/MetricBatchExample2.json" }, "Query Storage metrics for multiple resources": { "$ref": "./examples/MetricBatchExample.json" } } } } }, "definitions": { "LocalizableString": { "type": "object", "description": "The localizable string class.", "properties": { "value": { "type": "string", "description": "The invariant value." }, "localizedValue": { "type": "string", "description": "The display name." } }, "required": [ "value" ] }, "MetadataValue": { "type": "object", "description": "Represents a metric metadata value.", "properties": { "name": { "$ref": "#/definitions/LocalizableString", "description": "The name of the metadata." }, "value": { "type": "string", "description": "The value of the metadata." } } }, "Metric": { "type": "object", "description": "The result data of a query.", "properties": { "id": { "type": "string", "description": "The metric Id." }, "type": { "type": "string", "description": "The resource type of the metric resource." }, "name": { "$ref": "#/definitions/LocalizableString", "description": "The name and the display name of the metric, i.e. it is localizable string." }, "displayDescription": { "type": "string", "description": "Detailed description of this metric." }, "errorCode": { "type": "string", "description": "'Success' or the error details on query failures for this metric." }, "errorMessage": { "type": "string", "description": "Error message encountered querying this specific metric." }, "unit": { "$ref": "#/definitions/MetricUnit", "description": "The unit of the metric." }, "timeseries": { "type": "array", "description": "The time series returned when a data query is performed.", "items": { "$ref": "#/definitions/TimeSeriesElement" }, "x-ms-identifiers": [] } }, "required": [ "id", "type", "name", "unit", "timeseries" ] }, "MetricResultsResponse": { "type": "object", "description": "The metrics result for a resource.", "properties": { "values": { "type": "array", "description": "The collection of metric data responses per resource, per metric.", "items": { "$ref": "#/definitions/MetricResultsResponseValuesItem" } } } }, "MetricResultsResponseValuesItem": { "type": "object", "description": "The metric data response for a resource.", "properties": { "starttime": { "type": "string", "description": "The start time, in datetime format, for which the data was retrieved." }, "endtime": { "type": "string", "description": "The end time, in datetime format, for which the data was retrieved." }, "interval": { "type": "string", "description": "The interval (window size) for which the metric data was returned in ISO 8601\nduration format with a special case for 'FULL' value that returns single\ndatapoint for entire time span requested (*Examples: PT15M, PT1H, P1D, FULL*).\nThis may be adjusted and different from what was originally requested if\nAutoAdjustTimegrain=true is specified." }, "namespace": { "type": "string", "description": "The namespace of the metrics been queried" }, "resourceregion": { "type": "string", "description": "The region of the resource been queried for metrics." }, "resourceid": { "type": "string", "description": "The resource that has been queried for metrics." }, "value": { "type": "array", "description": "The value of the collection.", "items": { "$ref": "#/definitions/Metric" } } }, "required": [ "starttime", "endtime", "value" ] }, "MetricUnit": { "type": "string", "description": "The unit of the metric.", "enum": [ "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond" ], "x-ms-enum": { "name": "MetricUnit", "modelAsString": true, "values": [ { "name": "Count", "value": "Count", "description": "Unit of raw quantity." }, { "name": "Bytes", "value": "Bytes", "description": "Unit of memory in bytes." }, { "name": "Seconds", "value": "Seconds", "description": "Unit of time in seconds." }, { "name": "CountPerSecond", "value": "CountPerSecond", "description": "Rate unit of raw quantity per second." }, { "name": "BytesPerSecond", "value": "BytesPerSecond", "description": "Rate unit of memory in bytes per second." }, { "name": "Percent", "value": "Percent", "description": "Percentage unit." }, { "name": "MilliSeconds", "value": "MilliSeconds", "description": "Unit of time in 1/1000th of a second." }, { "name": "ByteSeconds", "value": "ByteSeconds", "description": "Unit of data transfer or storage. It is the size of the data in bytes\nmultiplied by the time it takes to transfer or store the data in seconds." }, { "name": "Unspecified", "value": "Unspecified", "description": "No specified unit." }, { "name": "Cores", "value": "Cores", "description": "Unit of processing power." }, { "name": "MilliCores", "value": "MilliCores", "description": "Unit of processing power in 1/1000th of a CPU core." }, { "name": "NanoCores", "value": "NanoCores", "description": "Unit of processing power in one billionth of a CPU core." }, { "name": "BitsPerSecond", "value": "BitsPerSecond", "description": "Rate unit of binary digits per second." } ] } }, "MetricValue": { "type": "object", "description": "Represents a metric value.", "properties": { "timeStamp": { "type": "string", "format": "date-time", "description": "The timestamp for the metric value in ISO 8601 format." }, "average": { "type": "number", "format": "double", "description": "The average value in the time range." }, "minimum": { "type": "number", "format": "double", "description": "The least value in the time range." }, "maximum": { "type": "number", "format": "double", "description": "The greatest value in the time range." }, "total": { "type": "number", "format": "double", "description": "The sum of all of the values in the time range." }, "count": { "type": "number", "format": "double", "description": "The number of samples in the time range. Can be used to determine the number of\nvalues that contributed to the average value." } }, "required": [ "timeStamp" ] }, "ResourceIdList": { "type": "object", "description": "The comma separated list of resource IDs to query metrics for.", "properties": { "resourceids": { "type": "array", "description": "The list of resource IDs to query metrics for.", "items": { "type": "string", "format": "arm-id", "description": "A type definition that refers the id to an Azure Resource Manager resource." } } } }, "TimeSeriesElement": { "type": "object", "description": "A time series result type. The discriminator value is always TimeSeries in this\ncase.", "properties": { "metadatavalues": { "type": "array", "description": "The metadata values returned if $filter was specified in the call.", "items": { "$ref": "#/definitions/MetadataValue" }, "x-ms-identifiers": [ "name" ] }, "data": { "type": "array", "description": "An array of data points representing the metric values. This is only returned\nif a result type of data is specified.", "items": { "$ref": "#/definitions/MetricValue" }, "x-ms-identifiers": [ "timeStamp" ] } } } }, "parameters": { "Azure.Core.Foundations.ApiVersionParameter": { "name": "api-version", "in": "query", "description": "The API version to use for this operation.", "required": true, "type": "string", "minLength": 1, "x-ms-parameter-location": "method", "x-ms-client-name": "apiVersion" } } }