Skip to content

Commit

Permalink
feat: Add ServiceMonitor support to helm chart (#2929)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreZiviani authored Jan 18, 2024
1 parent c5ec9ac commit f658f05
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 0 deletions.
12 changes: 12 additions & 0 deletions operations/pyroscope/helm/pyroscope/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@
| pyroscope.structuredConfig | object | `{}` | Allows to override Phlare's configuration using structured format. |
| pyroscope.tenantOverrides | object | `{}` | Allows to add tenant specific overrides to the default limit configuration. |
| pyroscope.tolerations | list | `[]` | |
| serviceMonitor.annotations | object | `{}` | ServiceMonitor annotations |
| serviceMonitor.enabled | bool | `false` | If enabled, ServiceMonitor resources for Prometheus Operator are created |
| serviceMonitor.interval | string | `nil` | ServiceMonitor scrape interval |
| serviceMonitor.labels | object | `{}` | Additional ServiceMonitor labels |
| serviceMonitor.matchExpressions | list | `[]` | Optional expressions to match on |
| serviceMonitor.metricRelabelings | list | `[]` | ServiceMonitor metric relabel configs to apply to samples before ingestion https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#endpoint |
| serviceMonitor.namespaceSelector | object | `{}` | Namespace selector for ServiceMonitor resources |
| serviceMonitor.relabelings | list | `[]` | ServiceMonitor relabel configs to apply to samples before scraping https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#relabelconfig |
| serviceMonitor.scheme | string | `"http"` | ServiceMonitor will use http by default, but you can pick https as well |
| serviceMonitor.scrapeTimeout | string | `nil` | ServiceMonitor scrape timeout in Go duration format (e.g. 15s) |
| serviceMonitor.targetLabels | list | `[]` | ServiceMonitor will add labels from the service to the Prometheus metric https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#servicemonitorspec |
| serviceMonitor.tlsConfig | string | `nil` | ServiceMonitor will use these tlsConfig settings to make the health check requests |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.8.1](https://github.com/norwoodj/helm-docs/releases/v1.8.1)
65 changes: 65 additions & 0 deletions operations/pyroscope/helm/pyroscope/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{{- if .Values.serviceMonitor.enabled }}
{{- $global := . }}
{{- $serviceMonitor := .Values.serviceMonitor }}
{{- range $component, $cfg := (fromYaml (include "pyroscope.components" .)) }}
{{- with $global }}
{{- $values := mustMergeOverwrite (deepCopy .Values.pyroscope ) ($cfg | default dict)}}
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ $cfg.name }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "pyroscope.labels" . | nindent 4 }}
app.kubernetes.io/component: {{ $component | quote }}
{{- with $serviceMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with $serviceMonitor.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- with $serviceMonitor.namespaceSelector }}
namespaceSelector:
{{- toYaml . | nindent 4 }}
{{- end }}
selector:
matchLabels:
{{- include "pyroscope.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: {{ $component | quote }}
{{- with $serviceMonitor.matchExpressions }}
matchExpressions:
{{- toYaml . | nindent 6 }}
{{- end }}
endpoints:
- port: {{ $values.service.port_name }}
{{- with $serviceMonitor.interval }}
interval: {{ . }}
{{- end }}
{{- with $serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
{{- with $serviceMonitor.relabelings }}
relabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $serviceMonitor.metricRelabelings }}
metricRelabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $serviceMonitor.scheme }}
scheme: {{ . }}
{{- end }}
{{- with $serviceMonitor.tlsConfig }}
tlsConfig:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $serviceMonitor.targetLabels }}
targetLabels:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
34 changes: 34 additions & 0 deletions operations/pyroscope/helm/pyroscope/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,37 @@ ingress:
# - localhost
# tls:
# - secretName: certificate

# ServiceMonitor configuration
serviceMonitor:
# -- If enabled, ServiceMonitor resources for Prometheus Operator are created
enabled: false
# -- Namespace selector for ServiceMonitor resources
namespaceSelector: {}
# -- Optional expressions to match on
matchExpressions: []
# - key: prometheus.io/service-monitor
# operator: NotIn
# values:
# - "false"
# -- ServiceMonitor annotations
annotations: {}
# -- Additional ServiceMonitor labels
labels: {}
# -- ServiceMonitor scrape interval
interval: null
# -- ServiceMonitor scrape timeout in Go duration format (e.g. 15s)
scrapeTimeout: 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 add labels from the service to the Prometheus metric
# https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#servicemonitorspec
targetLabels: []
# -- 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
14 changes: 14 additions & 0 deletions operations/pyroscope/jsonnet/values.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,19 @@
"structuredConfig": {},
"tenantOverrides": {},
"tolerations": []
},
"serviceMonitor": {
"annotations": {},
"enabled": false,
"interval": null,
"labels": {},
"matchExpressions": [],
"metricRelabelings": [],
"namespaceSelector": {},
"relabelings": [],
"scheme": "http",
"scrapeTimeout": null,
"targetLabels": [],
"tlsConfig": null
}
}

0 comments on commit f658f05

Please sign in to comment.