Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get storage account used capacity metric #73

Open
mboret opened this issue Nov 12, 2019 · 4 comments
Open

Unable to get storage account used capacity metric #73

mboret opened this issue Nov 12, 2019 · 4 comments

Comments

@mboret
Copy link
Contributor

mboret commented Nov 12, 2019

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&timespan=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&timespan=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

@kad-beumer
Copy link

I have the same issue. Someone found a solution for this?

@gaetanars
Copy link

Same issue. No solution?

@ludydoo
Copy link

ludydoo commented Mar 22, 2021

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

@ludydoo
Copy link

ludydoo commented Mar 22, 2021

#99

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants