Skip to content

feat(example,metrics): kube-state-metrics to monitor custom resource … #10277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packaging/examples/metrics/kube-state-metrics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Custom resource monitoring

## Usage

For deploying the monitoring of custom resources (CR) the [kube-state-metrics Helm chart](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-state-metrics) is used.
This assumes that [Prometheus Operator](https://github.com/prometheus-operator/prometheus-operator) is used.

```
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm upgrade --install [RELEASE_NAME] prometheus-community/kube-state-metrics -f kube-state-metrics-values.yaml
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# https://github.com/prometheus-community/helm-charts/blob/main/charts/kube-state-metrics/values.yaml
prometheus:
monitor:
enabled: true
collectors: []
extraArgs:
- --custom-resource-state-only=true
rbac:
extraRules:
- apiGroups:
- kafka.strimzi.io
resources:
- kafkatopics
- kafkausers
verbs: [ "list", "watch" ]
customResourceState:
enabled: true
config:
spec:
resources:
- groupVersionKind:
group: kafka.strimzi.io
version: v1beta2
kind: KafkaTopic
metricNamePrefix: strimzi_kafka_topic
metrics:
- name: "resource_info"
help: "The current state of a Strimzi kafka topic resource"
each:
type: Info
info:
labelsFromPath:
name: [ metadata, name ]
labelsFromPath:
exported_namespace: [ metadata, namespace ]
partitions: [ spec, partitions ]
replicas: [ spec, replicas ]
ready: [ status, conditions, "[type=Ready]", status ]
generation: [ status, observedGeneration ]
topicId: [ status, topicId ]
topicName: [ status, topicName ]
- groupVersionKind:
group: kafka.strimzi.io
version: v1beta2
kind: KafkaUser
metricNamePrefix: strimzi_kafka_user
metrics:
- name: "resource_info"
help: "The current state of a Strimzi kafka user resource"
each:
type: Info
info:
labelsFromPath:
name: [ metadata, name ]
labelsFromPath:
exported_namespace: [ metadata, namespace ]
ready: [ status, conditions, "[type=Ready]", status ]
deprecated: [ status, conditions, "[reason=DeprecatedFields]", type ]
secret: [ status, secret ]
generation: [ status, observedGeneration ]
username: [ status, username ]
extraManifests:
- apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: strimzi-kube-state-metrics
spec:
groups:
- name: strimzi-kube-state-metrics
rules:
- alert: KafkaUserDeprecated
expr: strimzi_kafka_user_resource_info{deprecated="Warning"}
for: 15m
labels:
severity: warning
annotations:
message: 'Strimzi Kafka User {{`{{ $labels.username }}`}} has a deprecated configuration'
- alert: KafkaUserNotReady
expr: strimzi_kafka_user_resource_info{ready!="True"}
for: 15m
labels:
severity: warning
annotations:
message: 'Strimzi Kafka User {{`{{ $labels.username }}`}} is not ready'
- alert: KafkaTopicNotReady
expr: strimzi_kafka_topic_resource_info{ready!="True"}
for: 15m
labels:
severity: warning
annotations:
message: 'Strimzi Kafka Topic {{`{{ $labels.topicName }}`}} is not ready'
Loading