Skip to content

Commit

Permalink
feat(goldpinger): add PrometheusRule. (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
desaintmartin authored Sep 21, 2021
1 parent 649634f commit 9d9c84c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/goldpinger/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ name: goldpinger
sources:
- https://github.com/bloomberg/goldpinger
- https://github.com/okgolove/helm-charts
version: 4.2.1
version: 4.3.0
3 changes: 3 additions & 0 deletions charts/goldpinger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ The following table lists the configurable parameters of the Goldpinger chart an
| `serviceMonitor.honorLabels` | honorLabels chooses the metric's labels on collisions with target labels. | `false`|
| `serviceMonitor.namespace` | namespace where servicemonitor resource should be created, same as Goldpinger if not specified | `` |
| `serviceMonitor.scrapeInterval` | interval between Prometheus scraping | `30s` |
| `prometheusRule.enabled` | Create a custom prometheusRule Resource for scraping metrics using PrometheusOperator | `false` |
| `prometheusRule.namespace` | The namespace in which the prometheusRule will be created | `""` |
| `prometheusRule.rules` | Custom Prometheus rules | `see values.yaml` |

Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,

Expand Down
22 changes: 22 additions & 0 deletions charts/goldpinger/templates/prometheusrule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- if .Values.prometheusRule.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ template "goldpinger.fullname" . }}
{{- if .Values.prometheusRule.namespace }}
namespace: {{ .Values.prometheusRule.namespace }}
{{- else }}
namespace: {{ .Release.Namespace | quote }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "goldpinger.name" . }}
helm.sh/chart: {{ include "goldpinger.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
{{- with .Values.prometheusRule.rules }}
groups:
- name: {{ template "goldpinger.name" $ }}
rules: {{- tpl (toYaml .) $ | nindent 8 }}
{{- end }}
{{- end }}
14 changes: 14 additions & 0 deletions charts/goldpinger/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,17 @@ serviceMonitor:
# namespace: monitoring
interval: 30s
# honorLabels: true

## Custom PrometheusRule to be defined
## ref: https://github.com/coreos/prometheus-operator#customresourcedefinitions
prometheusRule:
enabled: false
rules:
- alert: goldpinger_nodes_unhealthy
expr: sum(goldpinger_nodes_health_total{job={{ template "goldpinger.fullname" . }}, status="unhealthy"})
BY (instance, goldpinger_instance) > 0
for: 5m
annotations:
description: |
Goldpinger instance {{ "{{ $labels.goldpinger_instance }}" }} has been reporting unhealthy nodes for at least 5 minutes.
summary: Instance {{ "{{ $labels.instance }}" }} down

0 comments on commit 9d9c84c

Please sign in to comment.