azure-metrics-exporter
azure-metrics-exporter copied to clipboard
Exporting monitoring metrics
Hi, I was wondering if there is a way to export specific monitoring metrics from Azure. For example, I want to export the metrics of MICROSOFT.COMPUTE/SNAPSHOTS/WRITE
My questions are:
- Can I simply export metrics directly from azure without providing a VM address?
- If I can run it only based on VM, does it mean that I have to install the exporter on each VM?
In the README file, most of the times the target is:
- targets: ["azure-metrics:8080"] What is the definition of "azure-metrics"? Do I have to define somewhere the URL for the azure-metrics?
you can export all metrics which are available here: https://learn.microsoft.com/en-us/azure/azure-monitor/essentials/metrics-supported
For VMs you can find all available metrics here: https://learn.microsoft.com/en-us/azure/azure-monitor/essentials/metrics-supported#microsoftcomputevirtualmachines
the exporter is just a client for Azure Monitor API so if you can see the metrics in Azure Portal you can also export them.
The normal way is to run the exporter in Kubernetes or on a VM together with Prometheus. So the address to the exporter depends where you run it (in Kubernetes use cluster.local address or when it's a standalone VM you point it to the IP of the VM).
If you're searching for more detailed VM metrics you might want to check either:
- https://github.com/prometheus/node_exporter (linux)
- https://github.com/prometheus-community/windows_exporter (windows)
these exporters have to be installed on every VM
We have several exporters including node_exporter, but this is not enough for us.
So for your answer, we run the azure exporter on a container together with the prometheus container on the same VM (not on Kubernetes yet), so the target will be "localhost:8080" ?
Here is what I did (its a copy paste from your readme file, just with my subscription and target:
- job_name: azure-metrics-keyvault
scrape_interval: 1m
metrics_path: /probe/metrics/list
params:
name: ["azure_metric_keyvault"]
subscription:
- XXXXXX filter: ["resourceType eq 'Microsoft.KeyVault/vaults'"] metric:
- Availability
- ServiceApiHit
- ServiceApiLatency interval: ["PT15M"] timespan: ["PT15M"] aggregation:
- average
- total static_configs:
- targets: ["localhost:8080"]
depends if you expose the exporter's port using docker and how you run prometheus (because localhost depends what localhost is from prometheus view).
In general:
You don't have to expose any ports for azure-metrics-exporter, you can run it besides prometheus using eg. docker-compose and then use the name of the container as target eg: azure-metrics-exporter:8080 if the container is named azure-metrics-exporter.
the exporter is just a client for Azure Monitor API so if you can see the metrics in Azure Portal you can also export them.
That's not quite right. There are metrics (also available in the portal) that cannot be obtained by the client and these return an error e.g.
Resource type: Microsoft.ApiManagement/service not enabled for Cross Resource metricsResource type: Microsoft.ServiceBus/Namespaces not enabled for Cross Resource metrics- etc
Therefore this approach does not work with all resource types and sadly Azure does not document which resource types do or do not work.
@mblaschke
Since you are attempting to list at the subscription scope: https://learn.microsoft.com/en-us/rest/api/monitor/metrics/list-at-subscription-scope?view=rest-monitor-2023-10-01&tabs=HTTP
This means the request is scoped to the subscription level and uses a filter to sort out all the resource Ids that the metrics would belong to.
However, many resource types have not onboarded to being able to have their metrics queried in this way and the error we have received is indicating that e.g. Microsoft.ApiManagement/service resources are not yet able to be queried using this feature.
Can you at least confirm or deny? I would be grateful for at least this answer.
These resources instead require their metrics to be queried at the individual resource Id scope, or to instead be queried using the Metrics Data Plane (Batch) API that can list multiple resources at once regardless: Metrics Batch - Batch - REST API (Azure Monitor) | Microsoft Learn