webdevops / azure-metrics-exporter

Azure Monitor metrics exporter for Prometheus with dimension support, template engine and ServiceDiscovery
MIT License
118 stars 24 forks source link

metricsFilter only export the first filter as "dimension" #58

Open chris8205 opened 11 months ago

chris8205 commented 11 months ago

possible to "change" the metricsFilter to put the filtered dimension value also as dedicated "key-value pair" ex. metricFilter: ["HttpStatusGroup eq '*'","BackendPool eq '*'"]

actual result is like

- azure_metrics_name{aggregation="average", container="azure-metrics-exporter", **dimension="2xx"**, endpoint="http-metrics", instance="xxx.xxx.xxx.xxx:8080", interval="PT1M", job="amex", metric="BackendResponseStatus", namespace="k8s-system", pod="xxxxxxxxx-tnskx", resourceGroup="xxxxxx-rg", resourceID="/subscriptions/xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/xxxxxxx-rg/providers/microsoft.network/applicationgateways/xxxxxxxxx-agw-01", resourceName="xxxxxxxxxxxx-agw-01", service="amex", subscriptionID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", subscriptionName="[xxxxx] XXXXX", timespan="PT1M", unit="Count"}

--> dimension:"2xx"

is it possible to enhance it with

ex:

- azure_metrics_name{aggregation="average", container="azure-metrics-exporter", **httpstatusgroup="2xx", backendpool="<backendpoolname>"**, endpoint="http-metrics", instance="xxx.xxx.xxx.xxx:8080", interval="PT1M", job="amex", metric="BackendResponseStatus", namespace="k8s-system", pod="xxxxxxxxx-tnskx", resourceGroup="xxxxxx-rg", resourceID="/subscriptions/xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/xxxxxxx-rg/providers/microsoft.network/applicationgateways/xxxxxxxxx-agw-01", resourceName="xxxxxxxxxxxx-agw-01", service="amex", subscriptionID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", subscriptionName="[xxxxx] XXXXX", timespan="PT1M", unit="Count"}

so its possible to create metrics more "flexible" but can be filtered

or create a "dimension" selector to select one or more dimension(s) to export

chris8205 commented 11 months ago

info: possible microsoft doesn't return all dimensions per default no dimensions can be retourned. and if metricsFilter is set only one of these filters are returned as "dimension" so "decode" steps only in "single-dimension" and returns the value as ' dimension="" '

i suggest to remove the "dimension" prefix and return always the key-name without any pre- or suffix

mblaschke commented 8 months ago

you can query mutiple dimensions using ["HttpStatusGroup eq '*' and BackendPool eq '*'"]. that's the format of the Azure Metrics API.

Keep in mind that you set metricTop to a higher value as you might get many results.