Skip to content

fix(prometheus): add Thanos Querier compatibility mode#6482

Open
ykd007 wants to merge 2 commits into
keephq:mainfrom
ykd007:fix/thanos-compatibility
Open

fix(prometheus): add Thanos Querier compatibility mode#6482
ykd007 wants to merge 2 commits into
keephq:mainfrom
ykd007:fix/thanos-compatibility

Conversation

@ykd007
Copy link
Copy Markdown

@ykd007 ykd007 commented May 14, 2026

Problem

Connecting Keep's Prometheus provider to a Thanos Querier fails with:

prometheus scopes are invalid: { "connectivity": "'NoneType' object is not iterable" }

This happens because Thanos Querier does not implement /api/v1/alerts (that endpoint only exists on Prometheus's built-in rules evaluator / Alertmanager). Keep's connectivity check and alert polling both hit that endpoint unconditionally.

Closes #6474

Solution

Adds a thanos_compatible: bool flag (default False) to PrometheusProviderAuthConfig. When enabled:

  • Connectivity check uses /api/v1/rules?type=alert instead of /api/v1/alerts
  • Alert polling uses /api/v1/rules?type=alert which Thanos supports and which returns full alert data including annotations, state (firing/pending), activeAt, and labels
  • Fingerprints are computed as MD5 of sorted label JSON (same approach used elsewhere in the codebase)
  • Fully backward compatible — existing Prometheus configs with thanos_compatible: false (default) are unchanged

Testing

Set thanos_compatible: true in provider auth config when connecting to a Thanos Querier URL.

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. Provider Providers related issues labels May 14, 2026
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Provider Providers related issues size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[➕ Feature]: Add thanos compatibility

2 participants