zmoog / public-notes

Apache License 2.0
0 stars 1 forks source link

Figure out how to query Azure Monitor using the Azure CLI #21

Open zmoog opened 1 year ago

zmoog commented 1 year ago

I want to query the Cassandra related metrics using the Azure CLI.

zmoog commented 1 year ago

Log into the right tenant:

az login --tenant <tenant id>
$ az monitor metrics --help

Group
    az monitor metrics : View Azure resource metrics.

Subgroups:
    alert                     : Manage near-realtime metric alert rules.

Commands:
    list                      : List the metric values for a resource.
    list-definitions          : List the metric definitions for the resource.
    list-namespaces [Preview] : List the metric namespaces for the resource.

To search AI knowledge base for examples, use: az find "az monitor metrics"
zmoog commented 1 year ago
$ az monitor metrics list \
  --metrics CassandraConnectionClosures \
  --dimension ClosureReason \
  --resource "/subscriptions/21251715-1da6-4e71-b2e0-639b1f0b7cf5/resourceGroups/my-rg/providers/Microsoft.DocumentDB/databaseAccounts/abc"
{
  "cost": 59,
  "interval": "0:01:00",
  "namespace": "Microsoft.DocumentDB/databaseAccounts",
  "resourceregion": "westus",
  "timespan": "2023-03-08T10:03:52Z/2023-03-08T11:03:52Z",
  "value": [
    {
      "displayDescription": "Number of Cassandra connections that were closed, reported at a 1 minute granularity",
      "errorCode": "Success",
      "errorMessage": null,
      "id": "/subscriptions/21251715-1da6-4e71-b2e0-639b1f0b7cf5/resourceGroups/my-rg/providers/Microsoft.DocumentDB/databaseAccounts/my-rg/providers/Microsoft.Insights/metrics/CassandraConnectionClosures",
      "name": {
        "localizedValue": "Cassandra Connection Closures",
        "value": "CassandraConnectionClosures"
      },
      "resourceGroup": "my-rg",
      "timeseries": [],
      "type": "Microsoft.Insights/metrics",
      "unit": "Count"
    }
  ]
}