diff --git a/dist/charts/ping-exporter/files/prometheus.rules b/dist/charts/ping-exporter/files/prometheus.rules new file mode 100644 index 0000000..9f574fc --- /dev/null +++ b/dist/charts/ping-exporter/files/prometheus.rules @@ -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" diff --git a/dist/charts/ping-exporter/templates/prometheusrule.yaml b/dist/charts/ping-exporter/templates/prometheusrule.yaml new file mode 100644 index 0000000..5b2677d --- /dev/null +++ b/dist/charts/ping-exporter/templates/prometheusrule.yaml @@ -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 }} diff --git a/dist/charts/ping-exporter/templates/servicemonitor.yaml b/dist/charts/ping-exporter/templates/servicemonitor.yaml new file mode 100644 index 0000000..86ae438 --- /dev/null +++ b/dist/charts/ping-exporter/templates/servicemonitor.yaml @@ -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 }} diff --git a/dist/charts/ping-exporter/values.yaml b/dist/charts/ping-exporter/values.yaml index 3429316..1fe3a1f 100644 --- a/dist/charts/ping-exporter/values.yaml +++ b/dist/charts/ping-exporter/values.yaml @@ -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