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.

Intermittent fatal errors: InvalidOperationException: Sequence contains no matching element

See original GitHub issue

Report

We have some metrics that scrape fine >99% of the time, but encounter an FTL error in the scraper code a few times per day for some reason. It’s just a couple failed scrapes here and there, but it would be nice to know what condition causes this, and hopefully there is a way to improve it.

Example configuration that works >99% of the time

          - name: azure_redis_respond_errortype_errors
            description: "Errors."
            resourceType: RedisCache
            azureMetricConfiguration:
              metricName: errors	
              aggregation:
                type: Maximum
              dimension:
                name: ErrorType
            resourceDiscoveryGroups:
            - name: our-resource-group

Here’s the error that gets logged when the scrape fails:

[00:25:01 FTL] Failed to scrape resource for metric 'azure_redis_respond_errortype_errors'
System.InvalidOperationException: Sequence contains no matching element
   at System.Linq.ThrowHelper.ThrowNoMatchException()
   at Promitor.Core.Metrics.MeasuredMetric.CreateForDimension(Nullable`1 value, String dimensionName, TimeSeriesElement timeseries) in /src/Promitor.Core/MeasuredMetric.cs:line 68
   at Promitor.Integrations.AzureMonitor.AzureMonitorClient.QueryMetricAsync(String metricName, String metricDimension, AggregationType aggregationType, TimeSpan aggregationInterval, String resourceId, String metricFilter, Nullable`1 metricLimit) in /src/Promitor.Integrations.AzureMonitor/AzureMonitorClient.cs:line 117
   at Promitor.Core.Scraping.AzureMonitorScraper`1.ScrapeResourceAsync(String subscriptionId, ScrapeDefinition`1 scrapeDefinition, TResourceDefinition resourceDefinition, AggregationType aggregationType, TimeSpan aggregationInterval) in /src/Promitor.Core.Scraping/AzureMonitorScraper.cs:line 72
   at Promitor.Core.Scraping.Scraper`1.ScrapeAsync(ScrapeDefinition`1 scrapeDefinition) in /src/Promitor.Core.Scraping/Scraper.cs:line 103

Expected Behavior

Properly defined metrics should work consistently when Azure Monitor itself is in good condition.

Actual Behavior

Properly defined metrics experience intermittent fatal errors on scrapes, just a few per day always.

Steps to Reproduce the Problem

  1. I provided a metric definition in the report section.
  2. You could stand up an Azure Redis Cache to run that metric configuration against. Unfortunately, you would have to wait 24 hours to catch a few occurrences of the error.

Component

Scraper

Version

v2.9.1

Configuration

Configuration:

          - name: azure_redis_respond_errortype_errors
            description: "Errors."
            resourceType: RedisCache
            azureMetricConfiguration:
              metricName: errors	
              aggregation:
                type: Maximum
              dimension:
                name: ErrorType
            resourceDiscoveryGroups:
            - name: our-resource-group

Logs

[00:25:01 FTL] Failed to scrape resource for metric 'azure_redis_respond_errortype_errors'
System.InvalidOperationException: Sequence contains no matching element
   at System.Linq.ThrowHelper.ThrowNoMatchException()
   at Promitor.Core.Metrics.MeasuredMetric.CreateForDimension(Nullable`1 value, String dimensionName, TimeSeriesElement timeseries) in /src/Promitor.Core/MeasuredMetric.cs:line 68
   at Promitor.Integrations.AzureMonitor.AzureMonitorClient.QueryMetricAsync(String metricName, String metricDimension, AggregationType aggregationType, TimeSpan aggregationInterval, String resourceId, String metricFilter, Nullable`1 metricLimit) in /src/Promitor.Integrations.AzureMonitor/AzureMonitorClient.cs:line 117
   at Promitor.Core.Scraping.AzureMonitorScraper`1.ScrapeResourceAsync(String subscriptionId, ScrapeDefinition`1 scrapeDefinition, TResourceDefinition resourceDefinition, AggregationType aggregationType, TimeSpan aggregationInterval) in /src/Promitor.Core.Scraping/AzureMonitorScraper.cs:line 72
   at Promitor.Core.Scraping.Scraper`1.ScrapeAsync(ScrapeDefinition`1 scrapeDefinition) in /src/Promitor.Core.Scraping/Scraper.cs:line 103

Platform

Microsoft Azure

Contact Details

No response

Issue Analytics

  • State:closed
  • Created 3 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
gburton1commented, Jun 29, 2023

We will start looking into this over the next two weeks to see if we can improve the handling in this method.

0reactions
tomkerkhovecommented, Jun 23, 2023

Please give me some time as I maintain more than just Promitor so I cannot guarantee a response within 1-2 days 😃

I think the exception is fairly clear and the CreateForDimension method needs to be improved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Sequence contains no matching element
I have an asp.net application in which I am using linq for data manipulation. While running, I get the exception "Sequence contains no...
Read more >
Sequence Contains No Matching Element: Solved
Sequence contains no matching element is an error message from a C-Sharp application that occurs when a sequence (a collection of items, such...
Read more >
InvalidOperationException "sequence contains no ...
File a bug Since migrating to EFCore 6 I'm getting an InvalidOperationException with the following code, I'm not 100% sure what the issue...
Read more >
Sequence contains no matching element Error
Hi, I am getting "Sequence contains no matching element" error and the same query works in Kusto. ... InvalidOperationException at System.Linq.Enumerable.
Read more >
Sequence contains no matching element
Greeted this morning with data refresh errors. I went into Power Query and removed the offending step (so I thought). Clicked "Close and....
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