{
  "schemaVersion": 1,
  "snapshotDate": "2026-10-23",
  "slug": "reference-dev-azure-monitor-metrics-query",
  "title": "Azure Monitor Query Resource Metrics",
  "section": "Library asset reference",
  "description": "Query Resource Metrics for the explicitly selected Azure scope. Returns one bounded page or selected resource metadata.",
  "kind": "node",
  "url": "/wiki/reference-dev-azure-monitor-metrics-query/",
  "markdown": "/wiki/reference-dev-azure-monitor-metrics-query/index.md",
  "json": "/wiki/reference-dev-azure-monitor-metrics-query/index.json",
  "headings": [
    {
      "id": "operation-arguments",
      "title": "Operation arguments",
      "depth": 2
    },
    {
      "id": "catalog-identity",
      "title": "Catalog identity",
      "depth": 2
    },
    {
      "id": "inputs",
      "title": "Inputs",
      "depth": 2
    },
    {
      "id": "outputs",
      "title": "Outputs",
      "depth": 2
    },
    {
      "id": "configuration-schema",
      "title": "Configuration schema",
      "depth": 2
    },
    {
      "id": "provider-operation-contract",
      "title": "Provider operation contract",
      "depth": 2
    },
    {
      "id": "source-and-installed-versions",
      "title": "Source and installed versions",
      "depth": 2
    }
  ],
  "sources": [
    "../OpenNodeFlow-Library/work/catalog-all.mjs",
    "../OpenNodeFlow-Library/work/azure-pack-consolidation-20261022/catalog-policy.mjs",
    "../OpenNodeFlow-Library/work/developer-packs-20261022/catalog.mjs",
    "shared/seed.ts",
    "shared/storage-library.ts",
    "shared/variable-library.ts",
    "shared/control-flow.ts",
    "shared/remote-routes.ts",
    "server/runtime-library.ts",
    "shared/error-library.ts",
    "shared/storage-model.ts",
    "shared/builtin-documentation.ts"
  ],
  "family": "azure-monitor",
  "pack": "pack_azure",
  "contract": {
    "key": "dev.azure-monitor.metrics-query",
    "slug": "dev-azure-monitor-metrics-query",
    "name": "Azure Monitor Query Resource Metrics",
    "kind": "node",
    "family": "azure-monitor",
    "packId": "pack_azure",
    "category": "Developer integrations",
    "description": "Query Resource Metrics for the explicitly selected Azure scope. Returns one bounded page or selected resource metadata.",
    "inputs": [
      {
        "id": "exec",
        "name": "Execute",
        "type": "control",
        "typeName": "Control",
        "required": false
      },
      {
        "id": "resourceUri",
        "name": "ResourceUri",
        "type": "string",
        "typeName": "Text",
        "required": false
      },
      {
        "id": "metricnames",
        "name": "Metricnames",
        "type": "string",
        "typeName": "Text",
        "required": false
      },
      {
        "id": "timespan",
        "name": "Timespan",
        "type": "string",
        "typeName": "Text",
        "required": false
      },
      {
        "id": "interval",
        "name": "Interval",
        "type": "string",
        "typeName": "Text",
        "required": false
      },
      {
        "id": "aggregation",
        "name": "Aggregation",
        "type": "string",
        "typeName": "Text",
        "required": false
      }
    ],
    "outputs": [
      {
        "id": "next",
        "name": "Next",
        "type": "control",
        "typeName": "Control",
        "required": false
      },
      {
        "id": "status",
        "name": "Status",
        "type": "number",
        "typeName": "Number",
        "required": true
      },
      {
        "id": "request_id",
        "name": "Request Id",
        "type": "string",
        "typeName": "Text",
        "required": false
      },
      {
        "id": "operation_url",
        "name": "Operation Url",
        "type": "string",
        "typeName": "Text",
        "required": false
      },
      {
        "id": "items",
        "name": "Items",
        "type": "@dev.azure-monitor.type.metric-list",
        "typeName": "Azure Metric List",
        "typeKey": "dev.azure-monitor.type.metric-list",
        "typeVersion": 1,
        "required": true
      },
      {
        "id": "count",
        "name": "Count",
        "type": "number",
        "typeName": "Number",
        "required": true
      },
      {
        "id": "has_more",
        "name": "Has More",
        "type": "boolean",
        "typeName": "Boolean",
        "required": true
      },
      {
        "id": "continuation",
        "name": "Continuation",
        "type": "string",
        "typeName": "Text",
        "required": false
      },
      {
        "id": "error",
        "name": "On error",
        "type": "control",
        "typeName": "Control",
        "required": false
      }
    ],
    "configSchema": {
      "type": "object",
      "properties": {
        "baseUrl": {
          "type": "string",
          "maxLength": 2000
        },
        "allowHttp": {
          "type": "boolean",
          "default": false
        },
        "tokenSecret": {
          "type": "string",
          "maxLength": 120
        },
        "username": {
          "type": "string",
          "maxLength": 160
        },
        "usernameSecret": {
          "type": "string",
          "maxLength": 120
        },
        "passwordSecret": {
          "type": "string",
          "maxLength": 120
        },
        "requestTimeoutMs": {
          "type": "integer",
          "minimum": 100,
          "maximum": 120000,
          "default": 15000
        },
        "maxBytes": {
          "type": "integer",
          "minimum": 1024,
          "maximum": 3000000,
          "default": 1048576
        },
        "maxPages": {
          "type": "integer",
          "minimum": 1,
          "maximum": 20,
          "default": 1
        },
        "maxItems": {
          "type": "integer",
          "minimum": 1,
          "maximum": 5000,
          "default": 1000
        },
        "confirmWrites": {
          "type": "boolean",
          "default": false
        }
      },
      "additionalProperties": true
    },
    "documentation": "Query Resource Metrics for the explicitly selected Azure scope. Returns one bounded page or selected resource metadata.\n\nGET {resourceUri*}/providers/Microsoft.Insights/metrics. Read operation.\n\nInputs: resourceUri (optional), metricnames (optional), timespan (optional), interval (optional), aggregation (optional). Missing inputs may come from the selected connection profile config or explicit node defaults. Outputs: status, request_id, operation_url, items, count, has_more, continuation. Optional outputs are absent when the provider omits them. HTTP202 is acceptance, not completed work; operation_url exposes a same-origin asynchronous status URL when supplied.\n\nSetup: configure baseUrl (https://management.azure.com), bearer credentials through encrypted secret names or Connections. Default secret name: AZURE_ARM_ACCESS_TOKEN. Connection credentials accessToken/apiKey or username/password are resolved at execution. Never put credentials in literal inputs, baseUrl or logs. Required access: Azure RBAC for the selected resource; bearer token audience https://management.azure.com/.default. No keys or connection strings are requested.\n\nBounds: requestTimeoutMs=15000 (100..120000), maxBytes=1048576 (1024..3000000), maxItems=1000 (1..5000), maxPages=1 (1..20). One bounded request; use the provider-specific explicit paging inputs where offered. HTTPS is required; private HTTP needs allowHttp=true. TLS validation remains enabled. Redirects, cross-origin/escaped continuation URLs and repeated continuations fail. No implicit retries. Error text contains provider/status only, never raw response bodies or credentials. Reconcile an uncertain external action before another attempt.\n\nSynthetic example inputs:\n\n```json\n{\n  \"resourceUri\": \"/subscriptions/00000000-0000-4000-8000-000000000001/resourceGroups/sample-rg/providers/Microsoft.Compute/virtualMachines/sample-vm\",\n  \"metricnames\": \"Percentage CPU\",\n  \"timespan\": \"2026-01-01T00:00:00Z/2026-01-01T01:00:00Z\",\n  \"interval\": \"PT1M\",\n  \"aggregation\": \"Average\"\n}\n```\n\nThis example is documentation, not a run. \n\nSource: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/monitor/resource-manager/Microsoft.Insights/Insights/stable/2023-10-01/metrics_API.json",
    "runtime": "javascript",
    "tags": [
      "azure-monitor",
      "developer-packs",
      "read"
    ],
    "source": "developer-catalog",
    "operation": {
      "key": "metrics-query",
      "method": "GET",
      "path": "{resourceUri*}/providers/Microsoft.Insights/metrics",
      "effect": "read",
      "description": "Query Resource Metrics for the explicitly selected Azure scope. Returns one bounded page or selected resource metadata.",
      "scopes": "Azure RBAC for the selected resource; bearer token audience https://management.azure.com/.default. No keys or connection strings are requested.",
      "arguments": {
        "resourceUri": {
          "type": "string",
          "required": true,
          "description": ""
        },
        "metricnames": {
          "type": "string",
          "required": true,
          "description": ""
        },
        "timespan": {
          "type": "string",
          "required": true,
          "description": ""
        },
        "interval": {
          "type": "string",
          "description": "",
          "default": "PT1M"
        },
        "aggregation": {
          "type": "string",
          "description": "",
          "default": "Average"
        }
      },
      "response": {
        "kind": "list",
        "path": [
          "value"
        ],
        "type": "metric"
      },
      "sampleInputs": {
        "resourceUri": "/subscriptions/00000000-0000-4000-8000-000000000001/resourceGroups/sample-rg/providers/Microsoft.Compute/virtualMachines/sample-vm",
        "metricnames": "Percentage CPU",
        "timespan": "2026-01-01T00:00:00Z/2026-01-01T01:00:00Z",
        "interval": "PT1M",
        "aggregation": "Average"
      },
      "sampleResponse": {
        "cost": 0,
        "timespan": "2026-01-01T00:00:00Z/2026-01-01T01:00:00Z",
        "value": [
          {
            "id": "/subscriptions/00000000-0000-4000-8000-000000000001/resourceGroups/sample-rg/providers/Microsoft.Compute/virtualMachines/sample-vm/providers/Microsoft.Insights/metrics/Percentage CPU",
            "type": "Microsoft.Insights/metrics",
            "name": {
              "value": "Percentage CPU",
              "localizedValue": "Percentage CPU"
            },
            "unit": "Percent",
            "timeseries": [
              {
                "metadatavalues": [],
                "data": [
                  {
                    "timeStamp": "2026-01-01T00:00:00Z",
                    "average": 5.5
                  }
                ]
              }
            ],
            "errorCode": "Success"
          }
        ]
      },
      "sources": [
        "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/monitor/resource-manager/Microsoft.Insights/Insights/stable/2023-10-01/metrics_API.json"
      ]
    }
  }
}
