Skip to content

Commit 12c4d9f

Browse files
sradcoCursor AI Agent
andcommitted
k8s: add alert listing/query and filter primitives
Add PrometheusAlerts implementation with: - Alert fetching from platform and user-workload Prometheus/Thanos - Rule group fetching with namespace-scoped Thanos tenancy queries - State-based filtering (firing, pending, silenced) - Label-based flat filtering with key=value matching - TLS transport with service CA for in-cluster communication Signed-off-by: avlitman <alitman@redhat.com> Signed-off-by: Shirly Radco <sradco@redhat.com> Signed-off-by: machadovilaca <machadovilaca@gmail.com> Co-authored-by: Cursor AI Agent <cursor-ai@users.noreply.github.com> Made-with: Cursor
1 parent 0480720 commit 12c4d9f

3 files changed

Lines changed: 1006 additions & 7 deletions

File tree

pkg/k8s/const.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,33 @@ package k8s
22

33
const (
44
ClusterMonitoringNamespace = "openshift-monitoring"
5+
6+
PlatformRouteNamespace = "openshift-monitoring"
7+
PlatformRouteName = "prometheus-k8s"
8+
PlatformAlertmanagerRouteName = "alertmanager-main"
9+
UserWorkloadRouteNamespace = "openshift-user-workload-monitoring"
10+
UserWorkloadRouteName = "prometheus-user-workload"
11+
UserWorkloadAlertmanagerRouteName = "alertmanager-user-workload"
12+
PrometheusAlertsPath = "/v1/alerts"
13+
PrometheusRulesPath = "/v1/rules"
14+
AlertmanagerAlertsPath = "/api/v2/alerts"
15+
UserWorkloadAlertmanagerPort = 9095
16+
UserWorkloadPrometheusServiceName = "prometheus-user-workload-web"
17+
UserWorkloadPrometheusPort = 9090
18+
19+
ThanosQuerierNamespace = "openshift-monitoring"
20+
ThanosQuerierServiceName = "thanos-querier"
21+
ThanosQuerierTenancyRulesPortName = "tenancy-rules"
22+
DefaultThanosQuerierTenancyRulesPort = 9093
23+
ThanosQuerierTenancyAlertsPath = "/api/v1/alerts"
24+
ThanosQuerierTenancyRulesPath = "/api/v1/rules"
25+
ServiceCAPath = "/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt"
26+
27+
AlertSourceLabel = "openshift_io_alert_source"
28+
AlertSourcePlatform = "platform"
29+
AlertSourceUser = "user"
30+
AlertBackendLabel = "openshift_io_alert_backend"
31+
AlertBackendAM = "alertmanager"
32+
AlertBackendProm = "prometheus"
33+
AlertBackendThanos = "thanos"
534
)

0 commit comments

Comments
 (0)