Skip to content
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

fix(monitoring): add and fix definitions for service monitors #25

Merged
merged 1 commit into from
Oct 9, 2023
Merged
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
2 changes: 1 addition & 1 deletion charts/deep-distributed/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.12
version: 0.0.13

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
2 changes: 1 addition & 1 deletion charts/deep-distributed/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ Installed components:
* query-frontend ({{.Values.queryFrontend.replicas}})
* compactor ({{.Values.compactor.replicas}})
{{- if .Values.gateway.enabled}}
* gateway -{{- if .Values.gateway.traefik.enabled}} {{- .Values.gateway.traefik.host}} {{- end}} {{- if .Values.gateway.ingress.enabled}}{{- with (index .Values.gateway.ingress.hosts 0)}}{{ .host}}{{- end}}{{- end}} ({{.Values.gateway.replicas}})
* gateway {{- if .Values.gateway.traefik.enabled}} {{- .Values.gateway.traefik.host}} {{- end}} {{- if .Values.gateway.ingress.enabled}}{{- with (index .Values.gateway.ingress.hosts 0)}}{{ .host}}{{- end}}{{- end}} ({{.Values.gateway.replicas}})
{{- end}}
7 changes: 7 additions & 0 deletions charts/deep-distributed/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,10 @@ Return the appropriate apiVersion for PodDisruptionBudget.
{{- print "policy/v1beta1" -}}
{{- end -}}
{{- end -}}

{{/*
Cluster name that shows up in dashboard metrics
*/}}
{{- define "deep.clusterName" -}}
{{ (include "deep.calculatedConfig" . | fromYaml).cluster_name | default .Release.Name }}
{{- end -}}
4 changes: 2 additions & 2 deletions charts/deep-distributed/templates/lib/service-monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Params:
memberlist = true/false, whether component is part of memberlist
*/}}
{{- define "deep.lib.serviceMonitor" -}}
{{- with .ctx.Values.metaMonitoring.serviceMonitor }}
{{- if .enabled }}
{{- if .ctx.Values.monitoring.enabled }}
{{- with .ctx.Values.monitoring.serviceMonitor }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
Expand Down
7 changes: 4 additions & 3 deletions charts/deep-distributed/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -961,11 +961,12 @@ serviceAccount:
# -- Annotations for the service account
annotations: {}

metaMonitoring:
## This config controls the deployment of Pod/Service Monitors to connect Deep to Prometheus for metric gathering
monitoring:
# Is monitoring active, set to true to deploy the service monitor
enabled: false
# ServiceMonitor configuration
serviceMonitor:
# -- If enabled, ServiceMonitor resources for Prometheus Operator are created
enabled: false
# -- Alternative namespace for ServiceMonitor resources
namespace: null
# -- Namespace selector for ServiceMonitor resources
Expand Down
2 changes: 1 addition & 1 deletion charts/deep/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.0.1
version: 1.0.2

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
8 changes: 8 additions & 0 deletions charts/deep/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,11 @@ Return if ingress supports pathType.
{{- define "deep.ingress.supportsPathType" -}}
{{- or (eq (include "deep.ingress.isStable" .) "true") (and (eq (include "deep.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) }}
{{- end }}


{{/*
Cluster name that shows up in dashboard metrics
*/}}
{{- define "deep.clusterName" -}}
{{ (include "deep.calculatedConfig" . | fromYaml).cluster_name | default .Release.Name }}
{{- end -}}
64 changes: 64 additions & 0 deletions charts/deep/templates/serviceMonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{{- if .Values.monitoring.enabled }}
{{- with .Values.monitoring.serviceMonitor }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "deep.fullname" $ }}
namespace: {{ .namespace | default $.Release.Namespace | quote }}
labels:
{{- include "deep.labels" (dict "ctx" $) | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
namespaceSelector:
{{- if .namespaceSelector }}
{{- toYaml .namespaceSelector | nindent 4 }}
{{- else }}
matchNames:
- {{ $.Release.Namespace }}
{{- end }}
selector:
matchLabels:
{{- include "deep.selectorLabels" (dict "ctx" $) | nindent 6 }}
matchExpressions:
- key: prometheus.io/service-monitor
operator: NotIn
values:
- "false"
endpoints:
- port: api
{{- with .interval }}
interval: {{ . }}
{{- end }}
{{- with .scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
relabelings:
- sourceLabels: [job]
replacement: "{{ include "deep.fullname" $ }}"
targetLabel: job
{{- if kindIs "string" .clusterLabel }}
- replacement: "{{ .clusterLabel | default (include "deep.clusterName" $) }}"
targetLabel: cluster
{{- end }}
{{- with .relabelings }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .metricRelabelings }}
metricRelabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .scheme }}
scheme: {{ . }}
{{- end }}
{{- with .tlsConfig }}
tlsConfig:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end -}}
{{- end -}}
30 changes: 30 additions & 0 deletions charts/deep/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -404,3 +404,33 @@ serviceAccount:
# -- Labels for the service account
labels: {}
automountServiceAccountToken: true


## This config controls the deployment of Pod/Service Monitors to connect Deep to Prometheus for metric gathering
monitoring:
# Is monitoring active, set to true to deploy the service monitor
enabled: false
# The config for the service monitor
serviceMonitor:
# the name space to deploy the service monitor in
namespace: null
# additional labels to add to the service monitor
labels: {}
# additional annotations to add to the service monitor
annotations: {}
# the name space selector to use in the service monitor
namespaceSelector: {}
# the scape timeout
scrapeTimeout: null
# the scape interval
interval: null
# -- ServiceMonitor relabel configs to apply to samples before scraping
# https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#relabelconfig
relabelings: []
# -- ServiceMonitor metric relabel configs to apply to samples before ingestion
# https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#endpoint
metricRelabelings: []
# -- ServiceMonitor will use http by default, but you can pick https as well
scheme: http
# -- ServiceMonitor will use these tlsConfig settings to make the health check requests
tlsConfig: null