Skip to content

Caching context deadline exceeded result #354

@Maros112358

Description

@Maros112358

Describe the bug
When context deadline is exceeded while using min_interval > 0, the sql_exporter caches the failed result.

To Reproduce
Steps to reproduce the behavior:
1, use the config below
2, go to /metrics
3, wait for timeout → scrape_duration 10 seconds + context deadline exceeded
4, refresh the page → scrape duration under 1 second + context deadline exceeded

Expected behavior
I expect sql_exporter to try to query the database again when the context deadline was exceeded during the last query.

Configuration

jobs:
  - job_name: my_job
    collectors: [mssql_timeout]
    static_configs:
      - targets:
          'my_target': 'my_connection_string'
collectors:
  - collector_name: mssql_timeout
    metrics:
      - metric_name: timeout_metrics
        type: gauge
        help: 'wait for 3 minutes'
        values: [xxx]
        query: |
          WAITFOR DELAY '00:03:00';

Additional context
First scrape:

# HELP scrape_duration_seconds How long it took to scrape the target in seconds
# TYPE scrape_duration_seconds gauge
scrape_duration_seconds{job="my_job",target="my_target"} 10.040869167
# HELP scrape_errors_total Total number of scrape errors per job, target, collector and query
# TYPE scrape_errors_total counter
scrape_errors_total{collector="mssql_timeout",job="my_job",query="timeout_metrics",target="my_target"} 10
# HELP up 1 if the target is reachable, or 0 if the scrape failed
# TYPE up gauge
up{job="my_job",target="my_target"} 1

Second scrape:

# HELP scrape_duration_seconds How long it took to scrape the target in seconds
# TYPE scrape_duration_seconds gauge
scrape_duration_seconds{job="my_job",target="my_target"} 0.374500292
# HELP scrape_errors_total Total number of scrape errors per job, target, collector and query
# TYPE scrape_errors_total counter
scrape_errors_total{collector="mssql_timeout",job="my_job",query="timeout_metrics",target="my_target"} 11
# HELP up 1 if the target is reachable, or 0 if the scrape failed
# TYPE up gauge
up{job="my_job",target="my_target"} 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions