Unable to get storage account used capacity metric
Opened this issue · 4 comments
Hi,
I'm not able to get the Azure storage account usedcapacity metric, the exporter always gives me back 0(should be 181.8MiB).
I can see differences between the request made by Azure portal to get the usedcapacity metric en the one made by Prometheus.
Azure portal:
"/subscriptions/XXXXXXXXX/resourceGroups/rg-dev/providers/Microsoft.Storage/storageAccounts/devwww/providers/microsoft.Insights/metrics?timespan=2019-11-11T15:35:00.000Z/2019-11-12T15:35:00.000Z&interval=FULL&metricnames=UsedCapacity&aggregation=average&metricNamespace=microsoft.storage%2Fstorageaccounts&validatedimensions=false&api-version=2019-07-01"
Prometheus Exporter:
/subscriptions/XXXXXXXXXXXXXX/resourceGroups/rg-dev/providers/Microsoft.Storage/storageAccounts/devwww/providers/microsoft.insights/metrics?aggregation=Total%2CAverage%2CMinimum%2CMaximum&api-version=2018-01-01&metricnames=UsedCapacity×pan=2019-11-12T15%3A41%3A53Z%2F2019-11-12T15%3A42%3A53Z
Prometheus gives me
# HELP usedcapacity_bytes_average usedcapacity_bytes_average
# TYPE usedcapacity_bytes_average gauge
usedcapacity_bytes_average{resource_group="rg-dev",resource_name="devwww"} 0
# HELP usedcapacity_bytes_max usedcapacity_bytes_max
# TYPE usedcapacity_bytes_max gauge
usedcapacity_bytes_max{resource_group="rg-dev",resource_name="devwww"} 0
# HELP usedcapacity_bytes_min usedcapacity_bytes_min
# TYPE usedcapacity_bytes_min gauge
usedcapacity_bytes_min{resource_group="rg-dev",resource_name="devwww"} 0
# HELP usedcapacity_bytes_total usedcapacity_bytes_total
# TYPE usedcapacity_bytes_total gauge
usedcapacity_bytes_total{resource_group="rg-dev",resource_name="devwww"} 0
I've modify the exporter's code to generate a request with parameters like the Azure portal.
/subscriptions/XXXXXXX/resourceGroups/rg-dev/providers/Microsoft.Storage/storageAccounts/probstgwww/providers/microsoft.Insights/metrics?aggregation=average&api-version=2019-07-01&autoadjusttimegrain=true&interval=PT5M&metricNamespace=microsoft.storage%2Fstorageaccounts&metricnames=UsedCapacity×pan=2019-11-12T15%3A36%3A48Z%2F2019-11-12T15%3A37%3A48Z&validatedimensions=false
But the exporter still gives me 0.
My configuration:
credentials:
subscription_id: XXXXXXX
client_id: XXXXXX
client_secret: XXXXXX
tenant_id: XXXXXX
resource_groups:
- resource_group: "rg-dev"
resource_types:
- Microsoft.Storage/storageAccounts
metrics:
- name: "UsedCapacity"
Any idea?
Thanks
I have the same issue. Someone found a solution for this?
Same issue. No solution?
Hi
I've investigated this issue as I need this working as well. I think I found the cause
The problem with this is that the "UsedCapacity" metric seems to be exported at a much slower rate than other metrics. By default, azure_metrics_exporter
uses a range of 1 minute. I think UsedCapacity needs a range of > 1h.
I tried to modify the code so that it queries for a larger interval
func GetTimes() (string, string) {
// Make sure we are using UTC
now := time.Now().UTC()
// Use query delay of 3 minutes when querying for latest metric data
endTime := now.Add(time.Minute * time.Duration(-3)).Format(time.RFC3339)
// ADDED "- time.Hour * 6"
startTime := now.Add(time.Minute * time.Duration(-4) - time.Hour * 6).Format(time.RFC3339)
return endTime, startTime
}
And it does indeed work.
I believe a fix for this would be to include an additional configuration parameter, such as "range_seconds", that would be used to configure this period.
I'm linking the PR