Skip to content
Open
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
1 change: 1 addition & 0 deletions charts/cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ refer to the [CloudNativePG Documentation](https://cloudnative-pg.io/documentat
| cluster.monitoring.disableDefaultQueries | bool | `false` | Whether the default queries should be injected. Set it to true if you don't want to inject default queries into the cluster. |
| cluster.monitoring.enabled | bool | `false` | Whether to enable monitoring |
| cluster.monitoring.podMonitor.enabled | bool | `true` | Whether to enable the PodMonitor |
| cluster.monitoring.podMonitor.labels | object | `{}` | Additional labels to set on the generated PodMonitor resource. Add labels your monitoring stack requires (for example `team-name`). |
| cluster.monitoring.podMonitor.metricRelabelings | list | `[]` | The list of metric relabelings for the PodMonitor. Applied to samples before ingestion. |
| cluster.monitoring.podMonitor.relabelings | list | `[]` | The list of relabelings for the PodMonitor. Applied to samples before scraping. |
| cluster.monitoring.prometheusRule.enabled | bool | `true` | Whether to enable the PrometheusRule automated alerts |
Expand Down
2 changes: 2 additions & 0 deletions charts/cluster/examples/pgbouncer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ cluster:
enabled: true
podMonitor:
enabled: true
# labels:
# team-name: my-team

backups:
enabled: false
Expand Down
14 changes: 1 addition & 13 deletions charts/cluster/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ spec:
{{- end }}

monitoring:
enablePodMonitor: {{ and .Values.cluster.monitoring.enabled .Values.cluster.monitoring.podMonitor.enabled }}
enablePodMonitor: false
disableDefaultQueries: {{ .Values.cluster.monitoring.disableDefaultQueries }}
{{- if not (empty .Values.cluster.monitoring.customQueries) }}
customQueriesConfigMap:
Expand All @@ -129,17 +129,5 @@ spec:
{{- toYaml . | nindent 6 }}
{{ end }}
{{- end }}
{{- if not (empty .Values.cluster.monitoring.podMonitor.relabelings) }}
{{- with .Values.cluster.monitoring.podMonitor.relabelings }}
podMonitorRelabelings:
{{- toYaml . | nindent 6 }}
{{ end }}
{{- end }}
{{- if not (empty .Values.cluster.monitoring.podMonitor.metricRelabelings) }}
{{- with .Values.cluster.monitoring.podMonitor.metricRelabelings }}
podMonitorMetricRelabelings:
{{- toYaml . | nindent 6 }}
{{ end }}
{{- end }}
{{ include "cluster.bootstrap" . | nindent 2 }}
{{ include "cluster.backup" . | nindent 2 }}
48 changes: 48 additions & 0 deletions charts/cluster/templates/podmonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#
# Copyright © contributors to CloudNativePG, established as
# CloudNativePG a Series of LF Projects, LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
{{- if and .Values.cluster.monitoring.enabled .Values.cluster.monitoring.podMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ include "cluster.fullname" . }}
namespace: {{ include "cluster.namespace" . }}
labels:
{{- include "cluster.labels" . | nindent 4 }}
{{- with .Values.cluster.monitoring.podMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.cluster.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
cnpg.io/cluster: {{ include "cluster.fullname" . }}
podMetricsEndpoints:
- port: metrics
{{- with .Values.cluster.monitoring.podMonitor.relabelings }}
relabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.cluster.monitoring.podMonitor.metricRelabelings }}
metricRelabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: monitoring-cluster
labels:
team-name: test-team
environment: test
spec:
selector:
matchLabels:
Expand Down
3 changes: 3 additions & 0 deletions charts/cluster/test/monitoring/01-monitoring_cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ cluster:
usage: GAUGE
description: "Cache hit ratio"
podMonitor:
labels:
team-name: test-team
environment: test
relabelings:
- targetLabel: environment
replacement: test
Expand Down
3 changes: 3 additions & 0 deletions charts/cluster/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@
"metricRelabelings": {
"type": "array"
},
"labels": {
"type": "object"
},
"relabelings": {
"type": "array"
}
Expand Down
3 changes: 3 additions & 0 deletions charts/cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ cluster:
podMonitor:
# -- Whether to enable the PodMonitor
enabled: true
# -- Additional labels to set on the generated PodMonitor resource.
# Add labels your monitoring stack requires (for example `team-name`).
labels: {}
# --The list of relabelings for the PodMonitor.
# Applied to samples before scraping.
relabelings: []
Expand Down