Skip to content

Commit 8e6c018

Browse files
fix(operator): updated AlertingRule sample to make it comply with the validation we apply (#18671)
1 parent b786095 commit 8e6c018

File tree

4 files changed

+37
-29
lines changed

4 files changed

+37
-29
lines changed

operator/bundle/community-openshift/manifests/loki-operator.clusterserviceversion.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,22 @@ metadata:
1919
{
2020
"alert": "HighPercentageError",
2121
"annotations": {
22-
"summary": "High request latency"
22+
"description": "Application {{ $labels.job }} in namespace example-namespace has an error rate above 5% for more than 10 minutes.",
23+
"summary": "High error rate detected"
2324
},
24-
"expr": "sum(rate({app=\"foo\", env=\"production\"} |= \"error\" [5m])) by (job)\n /\nsum(rate({app=\"foo\", env=\"production\"}[5m])) by (job)\n \u003e 0.05\n",
25+
"expr": "sum(rate({app=\"foo\", env=\"production\", kubernetes_namespace_name=\"example-namespace\"} |= \"error\" [5m])) by (job)\n /\nsum(rate({app=\"foo\", env=\"production\", kubernetes_namespace_name=\"example-namespace\"}[5m])) by (job)\n \u003e 0.05\n",
2526
"for": "10m",
2627
"labels": {
27-
"severity": "page"
28+
"severity": "warning"
2829
}
2930
},
3031
{
3132
"alert": "HttpCredentialsLeaked",
3233
"annotations": {
33-
"message": "{{ $labels.job }} is leaking http basic auth credentials."
34+
"description": "Application {{ $labels.job }} in pod {{ $labels.pod }} is leaking HTTP basic auth credentials in logs.",
35+
"summary": "HTTP credentials leaked in logs"
3436
},
35-
"expr": "sum by (cluster, job, pod) (count_over_time({namespace=\"prod\"} |~ \"http(s?)://(\\\\w+):(\\\\w+)@\" [5m]) \u003e 0)",
37+
"expr": "sum by (cluster, job, pod) (count_over_time({kubernetes_namespace_name=\"example-namespace\"} |~ \"http(s?)://(\\\\w+):(\\\\w+)@\" [5m]) \u003e 0)",
3638
"for": "10m",
3739
"labels": {
3840
"severity": "critical"
@@ -41,7 +43,7 @@ metadata:
4143
]
4244
}
4345
],
44-
"tenantID": "test-tenant"
46+
"tenantID": "application"
4547
}
4648
},
4749
{
@@ -150,7 +152,7 @@ metadata:
150152
categories: OpenShift Optional, Logging & Tracing
151153
certified: "false"
152154
containerImage: docker.io/grafana/loki-operator:0.8.0
153-
createdAt: "2025-06-11T13:21:37Z"
155+
createdAt: "2025-07-31T09:49:50Z"
154156
description: The Community Loki Operator provides Kubernetes native deployment
155157
and management of Loki and related logging components.
156158
features.operators.openshift.io/disconnected: "true"

operator/bundle/community/manifests/loki-operator.clusterserviceversion.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,22 @@ metadata:
1919
{
2020
"alert": "HighPercentageError",
2121
"annotations": {
22-
"summary": "High request latency"
22+
"description": "Application {{ $labels.job }} in namespace example-namespace has an error rate above 5% for more than 10 minutes.",
23+
"summary": "High error rate detected"
2324
},
24-
"expr": "sum(rate({app=\"foo\", env=\"production\"} |= \"error\" [5m])) by (job)\n /\nsum(rate({app=\"foo\", env=\"production\"}[5m])) by (job)\n \u003e 0.05\n",
25+
"expr": "sum(rate({app=\"foo\", env=\"production\", kubernetes_namespace_name=\"example-namespace\"} |= \"error\" [5m])) by (job)\n /\nsum(rate({app=\"foo\", env=\"production\", kubernetes_namespace_name=\"example-namespace\"}[5m])) by (job)\n \u003e 0.05\n",
2526
"for": "10m",
2627
"labels": {
27-
"severity": "page"
28+
"severity": "warning"
2829
}
2930
},
3031
{
3132
"alert": "HttpCredentialsLeaked",
3233
"annotations": {
33-
"message": "{{ $labels.job }} is leaking http basic auth credentials."
34+
"description": "Application {{ $labels.job }} in pod {{ $labels.pod }} is leaking HTTP basic auth credentials in logs.",
35+
"summary": "HTTP credentials leaked in logs"
3436
},
35-
"expr": "sum by (cluster, job, pod) (count_over_time({namespace=\"prod\"} |~ \"http(s?)://(\\\\w+):(\\\\w+)@\" [5m]) \u003e 0)",
37+
"expr": "sum by (cluster, job, pod) (count_over_time({kubernetes_namespace_name=\"example-namespace\"} |~ \"http(s?)://(\\\\w+):(\\\\w+)@\" [5m]) \u003e 0)",
3638
"for": "10m",
3739
"labels": {
3840
"severity": "critical"
@@ -41,7 +43,7 @@ metadata:
4143
]
4244
}
4345
],
44-
"tenantID": "test-tenant"
46+
"tenantID": "application"
4547
}
4648
},
4749
{
@@ -150,7 +152,7 @@ metadata:
150152
categories: OpenShift Optional, Logging & Tracing
151153
certified: "false"
152154
containerImage: docker.io/grafana/loki-operator:0.8.0
153-
createdAt: "2025-06-11T13:21:34Z"
155+
createdAt: "2025-07-31T09:49:48Z"
154156
description: The Community Loki Operator provides Kubernetes native deployment
155157
and management of Loki and related logging components.
156158
operators.operatorframework.io/builder: operator-sdk-unknown

operator/bundle/openshift/manifests/loki-operator.clusterserviceversion.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,22 @@ metadata:
1919
{
2020
"alert": "HighPercentageError",
2121
"annotations": {
22-
"summary": "High request latency"
22+
"description": "Application {{ $labels.job }} in namespace example-namespace has an error rate above 5% for more than 10 minutes.",
23+
"summary": "High error rate detected"
2324
},
24-
"expr": "sum(rate({app=\"foo\", env=\"production\"} |= \"error\" [5m])) by (job)\n /\nsum(rate({app=\"foo\", env=\"production\"}[5m])) by (job)\n \u003e 0.05\n",
25+
"expr": "sum(rate({app=\"foo\", env=\"production\", kubernetes_namespace_name=\"example-namespace\"} |= \"error\" [5m])) by (job)\n /\nsum(rate({app=\"foo\", env=\"production\", kubernetes_namespace_name=\"example-namespace\"}[5m])) by (job)\n \u003e 0.05\n",
2526
"for": "10m",
2627
"labels": {
27-
"severity": "page"
28+
"severity": "warning"
2829
}
2930
},
3031
{
3132
"alert": "HttpCredentialsLeaked",
3233
"annotations": {
33-
"message": "{{ $labels.job }} is leaking http basic auth credentials."
34+
"description": "Application {{ $labels.job }} in pod {{ $labels.pod }} is leaking HTTP basic auth credentials in logs.",
35+
"summary": "HTTP credentials leaked in logs"
3436
},
35-
"expr": "sum by (cluster, job, pod) (count_over_time({namespace=\"prod\"} |~ \"http(s?)://(\\\\w+):(\\\\w+)@\" [5m]) \u003e 0)",
37+
"expr": "sum by (cluster, job, pod) (count_over_time({kubernetes_namespace_name=\"example-namespace\"} |~ \"http(s?)://(\\\\w+):(\\\\w+)@\" [5m]) \u003e 0)",
3638
"for": "10m",
3739
"labels": {
3840
"severity": "critical"
@@ -41,7 +43,7 @@ metadata:
4143
]
4244
}
4345
],
44-
"tenantID": "test-tenant"
46+
"tenantID": "application"
4547
}
4648
},
4749
{
@@ -150,7 +152,7 @@ metadata:
150152
categories: OpenShift Optional, Logging & Tracing
151153
certified: "false"
152154
containerImage: quay.io/openshift-logging/loki-operator:0.1.0
153-
createdAt: "2025-06-11T13:21:40Z"
155+
createdAt: "2025-07-31T09:49:52Z"
154156
description: |
155157
The Loki Operator for OCP provides a means for configuring and managing a Loki stack for cluster logging.
156158
## Prerequisites and Requirements

operator/config/samples/loki_v1_alertingrule.yaml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,28 @@ kind: AlertingRule
33
metadata:
44
name: alertingrule-sample
55
spec:
6-
tenantID: test-tenant
6+
tenantID: application
77
groups:
88
- name: alerting-rules-group
99
interval: 10m
1010
rules:
1111
- alert: HighPercentageError
1212
expr: |
13-
sum(rate({app="foo", env="production"} |= "error" [5m])) by (job)
13+
sum(rate({app="foo", env="production", kubernetes_namespace_name="example-namespace"} |= "error" [5m])) by (job)
1414
/
15-
sum(rate({app="foo", env="production"}[5m])) by (job)
15+
sum(rate({app="foo", env="production", kubernetes_namespace_name="example-namespace"}[5m])) by (job)
1616
> 0.05
1717
for: 10m
1818
labels:
19-
severity: page
19+
severity: warning
2020
annotations:
21-
summary: High request latency
21+
summary: High error rate detected
22+
description: "Application {{ $labels.job }} in namespace example-namespace has an error rate above 5% for more than 10 minutes."
2223
- alert: HttpCredentialsLeaked
23-
annotations:
24-
message: "{{ $labels.job }} is leaking http basic auth credentials."
25-
expr: 'sum by (cluster, job, pod) (count_over_time({namespace="prod"} |~ "http(s?)://(\\w+):(\\w+)@" [5m]) > 0)'
24+
expr: 'sum by (cluster, job, pod) (count_over_time({kubernetes_namespace_name="example-namespace"} |~ "http(s?)://(\\w+):(\\w+)@" [5m]) > 0)'
2625
for: 10m
2726
labels:
2827
severity: critical
28+
annotations:
29+
summary: HTTP credentials leaked in logs
30+
description: "Application {{ $labels.job }} in pod {{ $labels.pod }} is leaking HTTP basic auth credentials in logs."

0 commit comments

Comments
 (0)