Skip to content

Commit

Permalink
Add prometheus-operator alerts support for manager (open-telemetry#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
Allex1 authored Jul 11, 2022
1 parent 7ba70b1 commit ffe5495
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/opentelemetry-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: opentelemetry-operator
version: 0.9.0
version: 0.9.1
description: OpenTelemetry Operator Helm chart for Kubernetes
type: application
home: https://opentelemetry.io/
Expand Down
18 changes: 18 additions & 0 deletions charts/opentelemetry-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ Expand the name of the chart.
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "opentelemetry-operator.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
Expand Down
37 changes: 37 additions & 0 deletions charts/opentelemetry-operator/templates/prometheusrule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{- if and .Values.manager.prometheusRule.enabled .Values.manager.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ include "opentelemetry-operator.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "opentelemetry-operator.labels" . | nindent 4 }}
{{- range $key, $value := .Values.manager.prometheusRule.extraLabels }}
{{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
{{- end }}
spec:
groups:
{{- if .Values.manager.prometheusRule.groups }}
{{- toYaml .Values.manager.prometheusRule.groups | nindent 4 }}
{{- end }}
{{- if .Values.manager.prometheusRule.defaultRules.enabled }}
- name: managerRules
rules:
- alert: ReconcileErrors
expr: rate(controller_runtime_reconcile_total{result="error"}[5m]) > 0
for: 5m
labels:
severity: warning
annotations:
description: '{{`Reconciliation errors for {{ $labels.controller }} is increasing and has now reached {{ humanize $value }} `}}'
runbook_url: 'Check manager logs for reasons why this might happen'
- alert: WorkqueueDepth
expr: workqueue_depth > 0
for: 5m
labels:
severity: warning
annotations:
description: '{{`Queue depth for {{ $labels.name }} has reached {{ $value }} `}}'
runbook_url: 'Check manager logs for reasons why this might happen'
{{- end }}
{{- end }}
11 changes: 11 additions & 0 deletions charts/opentelemetry-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ manager:
metricsEndpoints:
- port: metrics

prometheusRule:
enabled: false
groups: []
# Create default rules for monitoring the manager
defaultRules:
enabled: false

# additional labels for the PrometheusRule
extraLabels: {}


## List of additional cli arguments to configure the manager
## for example: --target-allocator-image, --labels, etc.
extraArgs: []
Expand Down

0 comments on commit ffe5495

Please sign in to comment.