你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Metrics - List

Lists资源的指标值

GET https://management.azure.com/{resourceUri}/providers/Microsoft.Insights/metrics?api-version=2023-10-01
GET https://management.azure.com/{resourceUri}/providers/Microsoft.Insights/metrics?timespan={timespan}&interval={interval}&metricnames={metricnames}&aggregation={aggregation}&top={top}&orderby={orderby}&$filter={$filter}&resultType={resultType}&api-version=2023-10-01&metricnamespace={metricnamespace}&AutoAdjustTimegrain={AutoAdjustTimegrain}&ValidateDimensions={ValidateDimensions}&rollupby={rollupby}

URI 参数

名称 必需 类型 说明
resourceUri
path True

string

资源的标识符。

api-version
query True

string

要用于此操作的 API 版本。

$filter
query

string

$filter用于减少返回的指标数据集。
例如:
指标包含元数据 A、B 和 C。
- 返回 C 的所有时序,其中 A = a1 且 B = b1 或 b2
$filter=A eq 'a1' and B eq 'b1' 或 B eq 'b2' and C eq '*'
- 变体无效:
$filter=A eq 'a1' and B eq 'b1' and C eq '*' 或 B = 'b2'
这无效,因为逻辑 或 运算符无法分隔两个不同的元数据名称。
- 返回 A = a1、B = b1 且 C = c1 的所有时序:
$filter=A eq 'a1' and B eq 'b1' and C eq 'c1'
- 返回 A = a1 的所有时序
$filter=A eq 'a1' and B eq '' and C eq ''

aggregation
query

string

聚合类型列表 (逗号分隔) 进行检索。 示例:平均值、最小值、最大值

AutoAdjustTimegrain
query

boolean

设置为 true 时,如果此指标不支持传入的时间跨度,API 将使用最接近支持的时间跨度返回结果。 如果设置为 false,则返回无效时间跨度参数的错误。 默认为 false。

interval
query

string

间隔 (即 ISO 8601 持续时间格式的查询的 timegrain) 。 默认为 PT1M。 针对请求的整个时间跨度返回单个数据点的“FULL”值的特殊情况。 示例:PT15M、PT1H、P1D、FULL

metricnames
query

string

要检索的指标名称 (逗号分隔) 。

metricnamespace
query

string

所需指标所在的指标命名空间。

orderby
query

string

用于对结果和排序方向进行排序的聚合。 只能指定一个订单。 示例:sum asc

resultType
query

ResultType

减少收集的数据集。 允许的语法取决于 操作。 有关详细信息,请参阅操作的说明。

rollupby
query

string

维度名称 (汇总结果) 。 例如,如果只想查看带有筛选器(如“城市 eq Seattle 或 City eq Tacoma”)的指标值,但不想查看每个城市的单独值,则可以指定“RollUpBy=City”以查看西雅图和 Tacoma 的结果汇总为一个时间序。

timespan
query

string

查询的时间跨度。 它是具有以下格式的字符串“startDateTime_ISO/endDateTime_ISO”。

top
query

integer

int32

请求中每个资源 ID 要检索的最大记录数。 仅当指定了筛选器时有效。 默认值为 10。

ValidateDimensions
query

boolean

设置为 false 时,将忽略无效的筛选器参数值。 设置为 true 时,将返回无效筛选器参数的错误。 默认为 true。

响应

名称 类型 说明
200 OK

Response

获取指标值列表的请求成功。

Other Status Codes

ErrorResponse

描述操作失败原因的错误响应。

安全性

azure_auth

Azure Active Directory OAuth2 流

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

名称 说明
user_impersonation 模拟用户帐户

示例

Get Metric for data
Get Metric for metadata
Get Metric with error

Get Metric for data

Sample Request

GET https://management.azure.com/subscriptions/1f3fa6d2-851c-4a91-9087-1a050f3a9c38/resourceGroups/todking/providers/Microsoft.Storage/storageAccounts/tkfileserv/blobServices/default/providers/Microsoft.Insights/metrics?timespan=2021-04-20T09:00:00.000Z/2021-04-20T14:00:00.000Z&interval=PT6H&metricnames=BlobCount,BlobCapacity&aggregation=average,minimum,maximum&top=5&orderby=average asc&$filter=Tier eq '*'&api-version=2023-10-01&metricnamespace=Microsoft.Storage/storageAccounts/blobServices&AutoAdjustTimegrain=True&ValidateDimensions=False

Sample Response

{
  "cost": 598,
  "timespan": "2021-04-20T09:00:00Z/2021-04-20T14:00:00Z",
  "interval": "PT1H",
  "value": [
    {
      "id": "/subscriptions/1f3fa6d2-851c-4a91-9087-1a050f3a9c38/resourceGroups/todking/providers/Microsoft.Storage/storageAccounts/tkfileserv/blobServices/default/providers/Microsoft.Insights/metrics/BlobCount",
      "type": "Microsoft.Insights/metrics",
      "name": {
        "value": "BlobCount",
        "localizedValue": "Blob Count"
      },
      "displayDescription": "The number of blob objects stored in the storage account.",
      "unit": "Count",
      "timeseries": [
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Hot"
            }
          ],
          "data": [
            {
              "timeStamp": "2021-04-20T09:00:00Z",
              "average": 7,
              "minimum": 7,
              "maximum": 7
            },
            {
              "timeStamp": "2021-04-20T10:00:00Z",
              "average": 7,
              "minimum": 7,
              "maximum": 7
            },
            {
              "timeStamp": "2021-04-20T11:00:00Z",
              "average": 7,
              "minimum": 7,
              "maximum": 7
            },
            {
              "timeStamp": "2021-04-20T12:00:00Z",
              "average": 7,
              "minimum": 7,
              "maximum": 7
            },
            {
              "timeStamp": "2021-04-20T13:00:00Z",
              "average": 7,
              "minimum": 7,
              "maximum": 7
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Standard"
            }
          ],
          "data": [
            {
              "timeStamp": "2021-04-20T09:00:00Z",
              "average": 2,
              "minimum": 2,
              "maximum": 2
            },
            {
              "timeStamp": "2021-04-20T10:00:00Z",
              "average": 2,
              "minimum": 2,
              "maximum": 2
            },
            {
              "timeStamp": "2021-04-20T11:00:00Z",
              "average": 2,
              "minimum": 2,
              "maximum": 2
            },
            {
              "timeStamp": "2021-04-20T12:00:00Z",
              "average": 2,
              "minimum": 2,
              "maximum": 2
            },
            {
              "timeStamp": "2021-04-20T13:00:00Z",
              "average": 2,
              "minimum": 2,
              "maximum": 2
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Cool"
            }
          ],
          "data": [
            {
              "timeStamp": "2021-04-20T09:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T10:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T11:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T12:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T13:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Archive"
            }
          ],
          "data": [
            {
              "timeStamp": "2021-04-20T09:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T10:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T11:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T12:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T13:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Untiered"
            }
          ],
          "data": [
            {
              "timeStamp": "2021-04-20T09:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T10:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T11:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T12:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T13:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            }
          ]
        }
      ],
      "errorCode": "Success"
    },
    {
      "id": "/subscriptions/1f3fa6d2-851c-4a91-9087-1a050f3a9c38/resourceGroups/todking/providers/Microsoft.Storage/storageAccounts/tkfileserv/blobServices/default/providers/Microsoft.Insights/metrics/BlobCapacity",
      "type": "Microsoft.Insights/metrics",
      "name": {
        "value": "BlobCapacity",
        "localizedValue": "Blob Capacity"
      },
      "displayDescription": "The amount of storage used by the storage account’s Blob service in bytes.",
      "unit": "Bytes",
      "timeseries": [
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Standard"
            }
          ],
          "data": [
            {
              "timeStamp": "2021-04-20T09:00:00Z",
              "average": 621492,
              "minimum": 621492,
              "maximum": 621492
            },
            {
              "timeStamp": "2021-04-20T10:00:00Z",
              "average": 621492,
              "minimum": 621492,
              "maximum": 621492
            },
            {
              "timeStamp": "2021-04-20T11:00:00Z",
              "average": 621492,
              "minimum": 621492,
              "maximum": 621492
            },
            {
              "timeStamp": "2021-04-20T12:00:00Z",
              "average": 621492,
              "minimum": 621492,
              "maximum": 621492
            },
            {
              "timeStamp": "2021-04-20T13:00:00Z",
              "average": 621492,
              "minimum": 621492,
              "maximum": 621492
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Hot"
            }
          ],
          "data": [
            {
              "timeStamp": "2021-04-20T09:00:00Z",
              "average": 4733,
              "minimum": 4733,
              "maximum": 4733
            },
            {
              "timeStamp": "2021-04-20T10:00:00Z",
              "average": 4733,
              "minimum": 4733,
              "maximum": 4733
            },
            {
              "timeStamp": "2021-04-20T11:00:00Z",
              "average": 4733,
              "minimum": 4733,
              "maximum": 4733
            },
            {
              "timeStamp": "2021-04-20T12:00:00Z",
              "average": 4733,
              "minimum": 4733,
              "maximum": 4733
            },
            {
              "timeStamp": "2021-04-20T13:00:00Z",
              "average": 4733,
              "minimum": 4733,
              "maximum": 4733
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Archive"
            }
          ],
          "data": [
            {
              "timeStamp": "2021-04-20T09:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T10:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T11:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T12:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T13:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Untiered"
            }
          ],
          "data": [
            {
              "timeStamp": "2021-04-20T09:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T10:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T11:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T12:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T13:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Cool"
            }
          ],
          "data": [
            {
              "timeStamp": "2021-04-20T09:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T10:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T11:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T12:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T13:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            }
          ]
        }
      ],
      "errorCode": "Success"
    }
  ],
  "namespace": "microsoft.storage/storageaccounts/blobservices",
  "resourceregion": "westus2"
}

Get Metric for metadata

Sample Request

GET https://management.azure.com/subscriptions/1f3fa6d2-851c-4a91-9087-1a050f3a9c38/resourceGroups/todking/providers/Microsoft.Storage/storageAccounts/tkfileserv/blobServices/default/providers/Microsoft.Insights/metrics?timespan=2017-04-14T02:20:00Z/2017-04-14T04:20:00Z&$filter=Tier eq '*'&api-version=2023-10-01&metricnamespace=Microsoft.Storage/storageAccounts/blobServices

Sample Response

{
  "timespan": "2021-04-15T02:18:00Z/2021-04-22T02:18:00Z",
  "interval": "PT1H",
  "value": [
    {
      "id": "/subscriptions/1f3fa6d2-851c-4a91-9087-1a050f3a9c38/resourceGroups/todking/providers/Microsoft.Storage/storageAccounts/tkfileserv/blobServices/default/providers/Microsoft.Insights/metrics/BlobCount",
      "type": "Microsoft.Insights/metrics",
      "name": {
        "value": "BlobCount",
        "localizedValue": "Blob Count"
      },
      "displayDescription": "The number of blob objects stored in the storage account.",
      "unit": "Count",
      "timeseries": [
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Cool"
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Archive"
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Standard"
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Untiered"
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Hot"
            }
          ]
        }
      ]
    }
  ],
  "namespace": "microsoft.storage/storageaccounts/blobservices",
  "resourceregion": "westus2"
}

Get Metric with error

Sample Request

GET https://management.azure.com/subscriptions/ac41e21f-afd6-4a79-8070-f01eba278f97/resourceGroups/todking/providers/Microsoft.DocumentDb/databaseAccounts/tk-cosmos-mongo/providers/Microsoft.Insights/metrics?timespan=2021-06-07T21:51:00Z/2021-06-08T01:51:00Z&interval=FULL&metricnames=MongoRequestsCount,MongoRequests&aggregation=average&api-version=2023-10-01&metricnamespace=microsoft.documentdb/databaseaccounts&AutoAdjustTimegrain=True&ValidateDimensions=False

Sample Response

{
  "cost": 239,
  "timespan": "2021-06-07T21:51:00Z/2021-06-08T01:51:00Z",
  "interval": "PT4H",
  "value": [
    {
      "id": "/subscriptions/ac41e21f-afd6-4a79-8070-f01eba278f97/resourceGroups/todking/providers/Microsoft.DocumentDb/databaseAccounts/tk-cosmos-mongo/providers/Microsoft.Insights/metrics/MongoRequestsCount",
      "type": "Microsoft.Insights/metrics",
      "name": {
        "value": "MongoRequestsCount",
        "localizedValue": "(deprecated) Mongo Request Rate"
      },
      "unit": "CountPerSecond",
      "timeseries": [],
      "errorMessage": "Sampling type is not found. Metric:CosmosDBCustomer,AzureMonitor,MongoRequests, SamplingType:NullableAverage.",
      "errorCode": "InvalidSamplingType"
    },
    {
      "id": "/subscriptions/ac41e21f-afd6-4a79-8070-f01eba278f97/resourceGroups/todking/providers/Microsoft.DocumentDb/databaseAccounts/tk-cosmos-mongo/providers/Microsoft.Insights/metrics/MongoRequests",
      "type": "Microsoft.Insights/metrics",
      "name": {
        "value": "MongoRequests",
        "localizedValue": "Mongo Requests"
      },
      "displayDescription": "Number of Mongo Requests Made",
      "unit": "Count",
      "timeseries": [
        {
          "metadatavalues": [],
          "data": [
            {
              "timeStamp": "2021-06-07T21:51:00Z",
              "average": 0
            }
          ]
        }
      ],
      "errorCode": "Success"
    }
  ],
  "namespace": "microsoft.documentdb/databaseaccounts",
  "resourceregion": "westus2"
}

定义

名称 说明
ErrorAdditionalInfo

资源管理错误附加信息。

ErrorResponse

错误响应

LocalizableString

可本地化的字符串类。

MetadataValue

表示指标元数据值。

Metric

查询的结果数据。

MetricUnit

指标的单位。

MetricValue

表示指标值。

Response

对指标查询的响应。

ResultType

减少收集的数据集。 允许的语法取决于 操作。 有关详细信息,请参阅操作的说明。

TimeSeriesElement

时序结果类型。 在这种情况下,鉴别器值始终为 TimeSeries。

ErrorAdditionalInfo

资源管理错误附加信息。

名称 类型 说明
info

object

其他信息。

type

string

其他信息类型。

ErrorResponse

错误响应

名称 类型 说明
additionalInfo

ErrorAdditionalInfo[]

错误附加信息。

code

string

错误代码。

details

ErrorResponse[]

错误详细信息。

message

string

错误消息。

target

string

错误目标。

LocalizableString

可本地化的字符串类。

名称 类型 说明
localizedValue

string

显示名称。

value

string

固定值。

MetadataValue

表示指标元数据值。

名称 类型 说明
name

LocalizableString

元数据的名称。

value

string

元数据的值。

Metric

查询的结果数据。

名称 类型 说明
displayDescription

string

此指标的详细说明。

errorCode

string

“成功”或有关此指标的查询失败的错误详细信息。

errorMessage

string

查询此特定指标时遇到错误消息。

id

string

指标 ID。

name

LocalizableString

指标的名称和显示名称,即它是可本地化的字符串。

timeseries

TimeSeriesElement[]

执行数据查询时返回的时序。

type

string

指标资源的资源类型。

unit

MetricUnit

指标的单位。

MetricUnit

指标的单位。

名称 类型 说明
BitsPerSecond

string

每秒二进制数字的速率单位。

ByteSeconds

string

数据传输或存储单位。 它是数据的大小(以字节为单位)乘以传输或存储数据所需的时间(以秒为单位)。

Bytes

string

内存单位(以字节为单位)。

BytesPerSecond

string

内存单位的速率(以字节/秒为单位)。

Cores

string

处理能力单位。

Count

string

原始数量单位。

CountPerSecond

string

每秒原始数量的速率单位。

MilliCores

string

CPU 内核的 1/1000 的处理能力单位。

MilliSeconds

string

以 1/1000 秒为单位的时间单位。

NanoCores

string

CPU 内核的十亿分之一的处理能力单位。

Percent

string

百分比单位。

Seconds

string

时间单位(以秒为单位)。

Unspecified

string

未指定单位。

MetricValue

表示指标值。

名称 类型 说明
average

number

时间范围内的平均值。

count

number

时间范围内的样本数。 可用于确定与平均值有关的值数。

maximum

number

时间范围内的最大值。

minimum

number

时间范围内的最小值。

timeStamp

string

ISO 8601 格式的指标值的时间戳。

total

number

时间范围内所有值的总和。

Response

对指标查询的响应。

名称 类型 说明
cost

number

表示查询的相对成本的整数值。

interval

string

间隔 (窗口大小) ,其中指标数据以 ISO 8601 持续时间格式返回,“FULL”值的特殊情况,该值返回请求的整个时间跨度的单一数据点 (示例:PT15M、PT1H、P1D、FULL) 。 如果指定了 AutoAdjustTimegrain=true,这可能会进行调整,并且不同于最初请求的内容。 如果发出元数据请求,则不存在此请求。

namespace

string

正在查询的指标的命名空间

resourceregion

string

要查询指标的资源的区域。

timespan

string

检索数据的时间跨度。 其值由两个连接在一起的日期/时间组成,用“/”分隔。 将来可能会对此进行调整,并从最初请求的内容返回。

value

Metric[]

集合的值。

ResultType

减少收集的数据集。 允许的语法取决于 操作。 有关详细信息,请参阅操作的说明。

名称 类型 说明
Data

string

Metadata

string

TimeSeriesElement

时序结果类型。 在这种情况下,鉴别器值始终为 TimeSeries。

名称 类型 说明
data

MetricValue[]

表示指标值的数据点数组。 仅当指定了数据的结果类型时,才会返回此值。

metadatavalues

MetadataValue[]

如果在调用中指定了$filter,则返回的元数据值。