Skip to content

fix: export scrape_errors_total for related job filters#915

Merged
burningalchemist merged 1 commit intomasterfrom
fix/filter-scrape-errors-per-job
Mar 2, 2026
Merged

fix: export scrape_errors_total for related job filters#915
burningalchemist merged 1 commit intomasterfrom
fix/filter-scrape-errors-per-job

Conversation

@burningalchemist
Copy link
Owner

@burningalchemist burningalchemist commented Mar 2, 2026

resolves #903

This pull request introduces improved job filter handling and error reporting in the SQL exporter, as well as several code quality enhancements. The main changes include making job filter validation stricter, filtering metrics based on job filters, and updating logging and utility functions for clarity and robustness.

Job filter handling and error reporting:

  • The SetJobFilters method now validates job names, returns errors for invalid filters, and is updated to return an error instead of silently failing. The HTTP handler responds with a 400 error if invalid filters are provided. [1] [2]
  • In single target mode, job filters are ignored, and appropriate warnings are logged.

Metrics filtering:

  • Added the FilterScrapeErrorsTotal method to the Exporter interface and implementation, which filters the scrape_errors_total metric family to only include metrics for jobs specified in the job filters. This is now applied in the HTTP handler. [1] [2] [3]

Logging and code quality improvements:

  • Improved logging statements for better readability and context, especially in the caching collector and error scenarios. [1] [2] [3] [4]
  • Refactored utility functions: parseContextLog now handles invalid items more gracefully and uses strings.SplitSeq; TrimMissingCtx simplified to use strings.TrimPrefix. [1] [2]

General refactoring:

  • Updated function signatures for clarity and consistency, including changes to how targets and jobs are constructed and initialized. [1] [2] [3]

@burningalchemist burningalchemist force-pushed the fix/filter-scrape-errors-per-job branch 2 times, most recently from 8cade38 to ec1be8b Compare March 2, 2026 13:31
chore: string formatting

fix: only include scrape_errors_total for related job filters

revert: custom registry (in a separate pr)
@burningalchemist burningalchemist force-pushed the fix/filter-scrape-errors-per-job branch from ec1be8b to 0e666bf Compare March 2, 2026 13:38
@burningalchemist burningalchemist changed the title fix: only include scrape_errors_total for related job filters fix: export scrape_errors_total for related job filters Mar 2, 2026
@burningalchemist burningalchemist merged commit 6a1b08c into master Mar 2, 2026
4 checks passed
@burningalchemist burningalchemist deleted the fix/filter-scrape-errors-per-job branch March 2, 2026 13:42
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

Successfully merging this pull request may close these issues.

Feature request: Filter scrape_errors_total per job

1 participant