diff --git a/stable/neo4j/Chart.yaml b/stable/neo4j/Chart.yaml index 9d266641fe58..f056aec5041a 100644 --- a/stable/neo4j/Chart.yaml +++ b/stable/neo4j/Chart.yaml @@ -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 diff --git a/stable/neo4j/README.md b/stable/neo4j/README.md index 7c835a7c66ed..0002dd5feb9c 100644 --- a/stable/neo4j/README.md +++ b/stable/neo4j/README.md @@ -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). diff --git a/stable/neo4j/templates/core-dns.yaml b/stable/neo4j/templates/core-dns.yaml index 4380c24e7d4b..7b23df06ce39 100644 --- a/stable/neo4j/templates/core-dns.yaml +++ b/stable/neo4j/templates/core-dns.yaml @@ -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 }} diff --git a/stable/neo4j/templates/core-statefulset.yaml b/stable/neo4j/templates/core-statefulset.yaml index 1b5020819438..e1c9a176cd6b 100644 --- a/stable/neo4j/templates/core-statefulset.yaml +++ b/stable/neo4j/templates/core-statefulset.yaml @@ -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" @@ -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 }}" diff --git a/stable/neo4j/templates/readreplicas-deployment.yaml b/stable/neo4j/templates/readreplicas-deployment.yaml index fc774f9d1c96..cd746ffa5094 100644 --- a/stable/neo4j/templates/readreplicas-deployment.yaml +++ b/stable/neo4j/templates/readreplicas-deployment.yaml @@ -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" @@ -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 diff --git a/stable/neo4j/templates/servicemonitor.yaml b/stable/neo4j/templates/servicemonitor.yaml new file mode 100644 index 000000000000..1b4cfbaefff1 --- /dev/null +++ b/stable/neo4j/templates/servicemonitor.yaml @@ -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 }} diff --git a/stable/neo4j/values.yaml b/stable/neo4j/values.yaml index b27511749e25..e053bf9c0845 100644 --- a/stable/neo4j/values.yaml +++ b/stable/neo4j/values.yaml @@ -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