Skip to content

Fix VictoriaMetrics URL handling in alert history queries#6432

Open
evkuzin wants to merge 1 commit into
prymitive:mainfrom
evkuzin:fix_victoriametrics
Open

Fix VictoriaMetrics URL handling in alert history queries#6432
evkuzin wants to merge 1 commit into
prymitive:mainfrom
evkuzin:fix_victoriametrics

Conversation

@evkuzin

@evkuzin evkuzin commented Oct 8, 2025

Copy link
Copy Markdown

Problem
The alert history functionality was incorrectly constructing API URLs when using VictoriaMetrics generator URLs. VictoriaMetrics provides generator URLs with tenant-specific UI paths like:

http://victoriametrics/select/0/vmui/#/?g0.expr=...

The code was directly using these URLs as the base for Prometheus API client calls, resulting in malformed API endpoints:
❌ /select/0/vmui/api/v1/labels
❌ /select/0/vmui/api/v1/query_range
where the correct ones will be
✅ /select/0/prometheus/api/v1/labels
✅ /select/0/prometheus/api/v1/query_range

Solution
Enhanced the countAlerts function in alert_history.go to intelligently parse generator URLs and extract the correct API base URL
Added URL parsing logic to extract appropriate API base URLs from generator URLs
Added VictoriaMetrics-specific tenant path handling
Maintained backward compatibility for standard Prometheus deployments
Added debug logging to track URL transformations

@evkuzin evkuzin requested a review from prymitive as a code owner October 8, 2025 17:41
@evkuzin evkuzin force-pushed the fix_victoriametrics branch 2 times, most recently from 9ffbed3 to 572116c Compare October 8, 2025 17:53
@evkuzin evkuzin force-pushed the fix_victoriametrics branch from 572116c to 8d2e32c Compare October 8, 2025 17:56
@evkuzin

evkuzin commented Oct 8, 2025

Copy link
Copy Markdown
Author

hm, no, wait. I need to handle path a bit better. Let me work on it a bit more.

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.

1 participant