question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pass `aws_dimension_select` filter values in `ListMetricsRequest`.

See original GitHub issue

Currently, we use aws_dimension_select values to filter out metrics after we list all the metrics with given dimensions. The scarpe becomes time consuming when there more metrics with a given dimension… for example dynamodb SuccessfulRequestLatency metric with TableName, Operation as dimensions. There are around 6k metrics and scare takes around 5min. But, Here we are intrested in getting metrics for a single table even if specify the table name in aws_dimension_select it stll takes same amount of time due to below reason.

In getDimensions() (line 211) function, while creating the ListMetricsRequest object we just add dimension Name but not the filter Value even if they are specified as part of aws_dimension_select.

      for (String dimension: rule.awsDimensions) {
        dimensionFilters.add(new DimensionFilter().withName(dimension));
      }

and filter out it afterwards in useMetric() function. I don’t what is the intention doing this way.

We can reduce the scrape time by passing the filter values in the scrape request itself. Something like below.

        for (String dimension: rule.awsDimensions) {
            if (rule.awsDimensionSelect != null && rule.awsDimensionSelect.get(dimension) != null) {
                List<String> filterValues = rule.awsDimensionSelect.get(dimension);
                for (String value : filterValues) {
                    dimensionFilters.add(new DimensionFilter().withName(dimension).withValue(value));
                }
            }
            else {
                dimensionFilters.add(new DimensionFilter().withName(dimension));
            }
        }

after the above changes my scrape took under a sec from 5 min. That’s a drastic improvement.

If the maintainers feel this is a valid issue I can raise a PR with this changes.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
brian-brazilcommented, Nov 1, 2018

Unlike Go, Java regexes do support negative lookaheads so I don’t see a need to add more options for something that’s already possible.

0reactions
brian-brazilcommented, Nov 27, 2019

This was done.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ListMetricsRequest (AWS SDK for Java - 1.12.357)
To filter the results to show only metrics that have had data points published in the past three hours, specify this parameter with...
Read more >
ListMetricsRequest (AWS SDK for Java - 2.18.35)
To filter the results to show only metrics that have had data points published in the past three hours, specify this parameter with...
Read more >
com.amazonaws.services.cloudwatch.model ... - Tabnine
ListMetricsRequest.withDimensions(...) · * <p> · * The dimensions to filter against. · * </p> · * <p> · * <b>NOTE:</b> This method appends...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found