Skip to content

Commit

Permalink
Merge pull request #116 from djjudas21/prometheus_operator
Browse files Browse the repository at this point in the history
Prometheus Operator support
  • Loading branch information
czerwonk authored Aug 30, 2024
2 parents fbc40fd + 1fb83ef commit 375b125
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
16 changes: 16 additions & 0 deletions dist/charts/ping-exporter/files/prometheus.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
- alert: HighPingLossRatio
expr: round(ping_loss_ratio * 100) > 5
for: 5m
labels:
severity: warning
annotations:
summary: High ping loss ratio for {{ $labels.target }}
description: "Ping loss ratio for {{ $labels.target }} is {{ $value }}%"
- alert: HighPingRtt
expr: round(ping_rtt_mean_seconds * 1000, 0.1) > 100
for: 5m
labels:
severity: warning
annotations:
summary: High ping latency for {{ $labels.target }}
description: "Ping latency for {{ $labels.target }} is {{ $value }} seconds"
14 changes: 14 additions & 0 deletions dist/charts/ping-exporter/templates/prometheusrule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.prometheusRules.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
labels:
prometheus: service-prometheus
role: alert-rules
name: {{ include "ping_exporter.fullname" . }}
spec:
groups:
- name: ping_exporter.rules
rules:
{{ .Files.Get "files/prometheus.rules" }}
{{- end }}
28 changes: 28 additions & 0 deletions dist/charts/ping-exporter/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "ping_exporter.fullname" . }}
labels:
{{- include "ping_exporter.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "ping_exporter.selectorLabels" . | nindent 6 }}
endpoints:
- port: http
interval: 60s
relabelings:
- action: labeldrop
regex: pod
sourceLabels: []
- action: labeldrop
regex: namespace
sourceLabels: []
- action: labeldrop
regex: instance
sourceLabels: []
- action: labeldrop
regex: job
sourceLabels: []
{{- end }}
8 changes: 8 additions & 0 deletions dist/charts/ping-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,11 @@ config:
timeout: 3s
history-size: 42
payload-size: 120

# Create a serviceMonitor resource to be consumed by Prometheus Operator
serviceMonitor:
enabled: false

# Create basic Prometheus alerting rules
prometheusRules:
enabled: false

0 comments on commit 375b125

Please sign in to comment.