Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

[stable/neo4j] Add Prometheus ServiceMonitor #21434

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion stable/neo4j/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
name: neo4j
home: https://www.neo4j.com
version: 3.0.0
version: 3.1.0
appVersion: 4.0.3
description: Neo4j is the world's leading graph database
icon: http://info.neo4j.com/rs/773-GON-065/images/neo4j_logo.png
Expand Down
4 changes: 4 additions & 0 deletions stable/neo4j/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ their default values.
| `readReplica.initContainers` | Init containers to add to the replica pods. Example use case is a script that installs custom plugins/extensions | `{}` |
| `resources` | Resources required (e.g. CPU, memory) | `{}` |
| `clusterDomain` | Cluster domain | `cluster.local` |
| `metrics.prometheus.enabled` | Publish metrics for polling as Prometheus endpoint | `false` |
| `metrics.prometheus.serviceMonitor.enabled` | Whether to create a ServiceMonitor used by the Prometheus Operator for scraping | `false` |
| `metrics.prometheus.serviceMonitor.interval` | How frequently Prometheus should scrape | `30s` |
| `metrics.prometheus.serviceMonitor.labels` | Additional labels for the ServiceMonitor | `{}` |

The above parameters map to the env variables defined in the
[Neo4j docker image](https://github.com/neo4j/docker-neo4j).
Expand Down
5 changes: 5 additions & 0 deletions stable/neo4j/templates/core-dns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ spec:
- name: https
port: 7473
targetPort: 7473
{{- if .Values.metrics.prometheus.enabled }}
- name: prometheus
port: 2004
targetPort: 2004
{{- end }}
selector:
app.kubernetes.io/name: {{ template "neo4j.name" . }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
Expand Down
12 changes: 11 additions & 1 deletion stable/neo4j/templates/core-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ spec:
secretKeyRef:
name: {{ template "neo4j.secrets.fullname" . }}
key: neo4j-password
{{- end }}
{{- end }}
{{- if .Values.metrics.prometheus.enabled }}
- name: NEO4J_metrics_prometheus_enabled
value: "true"
- name: NEO4J_metrics_prometheus_endpoint
value: "0.0.0.0:2004"
{{- end }}
command:
- "/bin/bash"
- "-c"
Expand Down Expand Up @@ -78,6 +84,10 @@ spec:
name: browser
- containerPort: 7687
name: bolt
{{- if .Values.metrics.prometheus.enabled }}
- containerPort: 2004
name: prometheus
{{- end }}
volumeMounts:
- name: datadir
mountPath: "{{ .Values.core.persistentVolume.mountPath }}"
Expand Down
10 changes: 10 additions & 0 deletions stable/neo4j/templates/readreplicas-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ spec:
name: {{ template "neo4j.secrets.fullname" . }}
key: neo4j-password
{{- end }}
{{- if .Values.metrics.prometheus.enabled }}
- name: NEO4J_metrics_prometheus_enabled
value: "true"
- name: NEO4J_metrics_prometheus_endpoint
value: "0.0.0.0:2004"
{{- end }}
command:
- "/bin/bash"
- "-c"
Expand Down Expand Up @@ -85,6 +91,10 @@ spec:
name: browser
- containerPort: 7687
name: bolt
{{- if .Values.metrics.prometheus.enabled }}
- containerPort: 2004
name: prometheus
{{- end }}
volumeMounts:
- name: plugins
mountPath: /plugins
Expand Down
28 changes: 28 additions & 0 deletions stable/neo4j/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if and .Values.metrics.prometheus.enabled .Values.metrics.prometheus.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "neo4j.fullname" . }}
labels:
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
app.kubernetes.io/name: {{ template "neo4j.name" . }}
{{- with .Values.metrics.prometheus.serviceMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
endpoints:
- port: prometheus
{{- if .Values.metrics.prometheus.serviceMonitor.interval }}
interval: {{ .Values.metrics.prometheus.serviceMonitor.interval }}
{{- end }}
jobLabel: {{ template "neo4j.fullname" . }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
app.kubernetes.io/name: {{ template "neo4j.name" . }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
{{- end }}
15 changes: 15 additions & 0 deletions stable/neo4j/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,18 @@ resources: {}
# requests:
# cpu: 100m
# memory: 512Mi

## Expose Neo4j metrics
## For now only Prometheus is supported by this chart
metrics:
prometheus:
## Publish metrics for polling as Prometheus endpoint
enabled: false
serviceMonitor:
## Whether to create a ServiceMonitor used by the Prometheus Operator for scraping
enabled: false
## How frequently Prometheus should scrape
interval: 30s
## Additional labels for the ServiceMonitor
labels: {}
# prometheus: monitoring