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

How can I support this filter by RateLimitKey? #62

Open
callumj opened this issue Sep 13, 2023 · 2 comments
Open

How can I support this filter by RateLimitKey? #62

callumj opened this issue Sep 13, 2023 · 2 comments

Comments

@callumj
Copy link

callumj commented Sep 13, 2023

I want to break down BlockedCalls and Latency for a CognitiveServices metric by RateLimitKey which I have confirmed is possible via the ARM library:

res, err := client.List(ctx, "subscriptions/<SUB_ID>/resourceGroups/<GROUP>/providers/Microsoft.CognitiveServices/accounts/<ACCOUNT>", &armmonitor.MetricsClientListOptions{
		Interval:        to.Ptr("PT1M"),
		Metricnames:     to.Ptr("BlockedCalls,Latency"),
		Aggregation:     to.Ptr("Average"),
		Filter:          to.Ptr("RatelimitKey eq '*'"),
		ResultType:      nil,
		Metricnamespace: to.Ptr("Microsoft.CognitiveServices/accounts"),
	})

Translating this into:

- job_name: azure-metrics-cognitive-accounts-blocked-calls
  scrape_interval: 30s
  metrics_path: /probe/metrics/scrape
  params:
    name: ["microsoft_cognitive_services_accounts_blocked_calls"]
    subscription:
      - "<SUB_ID>"
    target:
      - "subscriptions/<SUB_ID>/resourceGroups/<GROUP>/providers/Microsoft.CognitiveServices/accounts/<ACCOUNT>",
    metricNamespace: ["Microsoft.CognitiveServices/accounts"]
    filter: ["RatelimitKey eq '*'"]
    metric:
    - BlockedCalls
    interval: ["PT1M"]
    timespan: ["PT1M"]
    aggregation:
    - total
  static_configs:
  - targets: ["localhost:8080"]

ends up with an error

{
  "error": {
    "code": "InvalidFilterInQueryString",
    "message": "Invalid $filter 'RatelimitKey eq '*'' specified in the query string."
  }
}

Presumably because it first wants to scrape the subscription list using FindSubscriptionResources. But I should not need that right?

@callumj callumj changed the title How can I break this filter by RateLimitKey? How can I support this filter by RateLimitKey? Sep 13, 2023
@mblaschke
Copy link
Member

can you try it with metricTop: ["10"]? so you get the top 10 from the filter?

it's difficult to find the correct values, but it helps you to query the metrics via Azure portal and use the browser console to check what values are sent.

@mblaschke
Copy link
Member

if you only want to get metrics from one resource you should use /probe/metrics/resource

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

2 participants