Skip to content

Commit

Permalink
Enable builtin metrics and add default ServiceMonitor (#159)
Browse files Browse the repository at this point in the history
* Create sync-from-upstream.yaml

Signed-off-by: Zach Stone <zach@giantswarm.io>

* Update sync-from-upstream.yaml

Signed-off-by: Zach Stone <zach@giantswarm.io>

* fix(charts): remove erroneous 'metadata' key from ClusterRole object (#119)

Signed-off-by: Mike Dougherty <mike.dougherty@missionlane.com>
Co-authored-by: Jim Bugwadia <jim@nirmata.com>
Signed-off-by: Zach Stone <zach@giantswarm.io>

* Enable metrics endpoint and add service monitor

Signed-off-by: Zach Stone <zach@giantswarm.io>

* Update generated install

Signed-off-by: Zach Stone <zach@giantswarm.io>

* Do not enable ServiceMonitor by default

Signed-off-by: Zach Stone <zach@giantswarm.io>

* Rerun codegen

Signed-off-by: Zach Stone <zach@giantswarm.io>

---------

Signed-off-by: Zach Stone <zach@giantswarm.io>
Signed-off-by: Mike Dougherty <mike.dougherty@missionlane.com>
Co-authored-by: Mike Dougherty <mikedougherty@users.noreply.github.com>
Co-authored-by: Jim Bugwadia <jim@nirmata.com>
  • Loading branch information
3 people authored Jul 10, 2024
1 parent ca35f64 commit a52d85d
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 0 deletions.
7 changes: 7 additions & 0 deletions charts/reports-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ helm install reports-server --namespace reports-server --create-namespace report
| securityContext | object | See [values.yaml](values.yaml) | Container security context |
| livenessProbe | object | `{"failureThreshold":10,"httpGet":{"path":"/livez","port":"https","scheme":"HTTPS"},"initialDelaySeconds":20,"periodSeconds":10}` | Liveness probe |
| readinessProbe | object | `{"failureThreshold":10,"httpGet":{"path":"/readyz","port":"https","scheme":"HTTPS"},"initialDelaySeconds":30,"periodSeconds":10}` | Readiness probe |
| metrics.enabled | bool | `true` | Enable prometheus metrics |
| metrics.serviceMonitor.enabled | bool | `false` | Enable service monitor for scraping prometheus metrics |
| metrics.serviceMonitor.additionalLabels | object | `{}` | Service monitor additional labels |
| metrics.serviceMonitor.interval | string | `""` | Service monitor scrape interval |
| metrics.serviceMonitor.metricRelabelings | list | `[]` | Service monitor metric relabelings |
| metrics.serviceMonitor.relabelings | list | `[]` | Service monitor relabelings |
| metrics.serviceMonitor.scrapeTimeout | string | `""` | Service monitor scrape timeout |
| resources.limits | string | `nil` | Container resource limits |
| resources.requests | string | `nil` | Container resource requests |
| autoscaling.enabled | bool | `false` | Enable autoscaling |
Expand Down
3 changes: 3 additions & 0 deletions charts/reports-server/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ spec:
{{- end }}
- --cert-dir=/tmp
- --secure-port=4443
{{- if .Values.metrics.enabled }}
- --authorization-always-allow-paths=/metrics
{{- end }}
{{- if .Values.config.db.secretName }}
env:
- name: DB_HOST
Expand Down
36 changes: 36 additions & 0 deletions charts/reports-server/templates/service-monitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled -}}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "reports-server.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "reports-server.labels" . | nindent 4 }}
{{- with .Values.metrics.serviceMonitor.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "reports-server.selectorLabels" . | nindent 6 }}
endpoints:
- port: https
path: /metrics
scheme: https
tlsConfig:
insecureSkipVerify: true
{{- if .Values.metrics.serviceMonitor.interval}}
interval: {{ .Values.metrics.serviceMonitor.interval }}
{{- end }}
{{- if .Values.metrics.serviceMonitor.scrapeTimeout}}
scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- with .Values.metrics.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.metrics.serviceMonitor.relabelings }}
relabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end -}}
23 changes: 23 additions & 0 deletions charts/reports-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,29 @@ readinessProbe:
port: https
scheme: HTTPS

metrics:
# -- Enable prometheus metrics
enabled: true

serviceMonitor:
# -- Enable service monitor for scraping prometheus metrics
enabled: false

# -- Service monitor additional labels
additionalLabels: {}

# -- Service monitor scrape interval
interval: ""

# -- Service monitor metric relabelings
metricRelabelings: []

# -- Service monitor relabelings
relabelings: []

# -- Service monitor scrape timeout
scrapeTimeout: ""

# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
Expand Down
1 change: 1 addition & 0 deletions config/install-inmemory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ spec:
- --debug
- --cert-dir=/tmp
- --secure-port=4443
- --authorization-always-allow-paths=/metrics
securityContext:
allowPrivilegeEscalation: false
capabilities:
Expand Down
1 change: 1 addition & 0 deletions config/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ spec:
- --dbsslcert=
- --cert-dir=/tmp
- --secure-port=4443
- --authorization-always-allow-paths=/metrics
securityContext:
allowPrivilegeEscalation: false
capabilities:
Expand Down

0 comments on commit a52d85d

Please sign in to comment.