Skip to content

Commit

Permalink
Update chart to include service & pod monitors
Browse files Browse the repository at this point in the history
  • Loading branch information
Juansasa committed Feb 13, 2024
1 parent 7de07bb commit f3aa46a
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 68 deletions.
57 changes: 0 additions & 57 deletions keycloak-observability/README.md
Original file line number Diff line number Diff line change
@@ -1,62 +1,5 @@
# Helm chart for Keycloak dashboard


### Pod monitor
Pod monitor is required for EAP metrics and should be included as part of the keycloak deployment
```
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: eap
namespace: {keycloak instance namespace}
spec:
selector:
matchLabels:
app: sso
podMetricsEndpoints:
- targetPort: 9990
```

### Service monitor
Service monitor is required for application metrics and should be included as part of the keycloak deployment
```
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: example-name
namespace: {keycloak instance namespace}
spec:
jobLabel: rhsso
selector:
matchLabels:
app: sso
endpoints:
- port: sso-monitoring
path: /metrics
scheme: https
tlsConfig:
insecureSkipVerify: true
relabelings:
- targetLabel: job
replacement: keycloak
- targetLabel: provider
replacement: keycloak
- targetLabel: instance
replacement: sso
- port: sso
path: /auth/realms/master/metrics
scheme: https
tlsConfig:
insecureSkipVerify: true
relabelings:
- targetLabel: job
replacement: keycloak
- targetLabel: provider
replacement: keycloak
- targetLabel: instance
replacement: sso
```

## Dependencies

1. ???
Expand Down
6 changes: 3 additions & 3 deletions keycloak-observability/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Expand the name of the chart.
*/}}
{{- define "keycloak-observability.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- default .Values.global.name .Values.nameOverride .Chart.Name | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Expand All @@ -14,7 +14,7 @@ If release name contains chart name it will be used as a full name.
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- $name := default .Values.global.name .Values.nameOverride .Chart.Name }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
Expand All @@ -34,7 +34,7 @@ Create chart name and version as used by the chart label.
Allow the release namespace to be overridden
*/}}
{{- define "keycloak-observability.namespace" -}}
{{- default .Release.Namespace .Values.namespaceOverride -}}
{{- default .Values.global.namespace .Release.Namespace .Values.namespaceOverride -}}
{{- end -}}

{{/*
Expand Down
3 changes: 2 additions & 1 deletion keycloak-observability/templates/dashboard-configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Values.name }}-dashboard-definition
name: {{- include "keycloak-observability.name" . | indent 1 }}-dashboard-definition
namespace: {{- include "keycloak-observability.namespace" . | indent 1 }}
labels:
{{- include "keycloak-observability.labels" . | nindent 4 }}
data:
Expand Down
7 changes: 4 additions & 3 deletions keycloak-observability/templates/dashboard.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: {{ .Values.name }}-dashboard
name: {{- include "keycloak-observability.name" . | indent 1 }}-dashboard
namespace: {{- include "keycloak-observability.namespace" . | indent 1 }}
labels:
{{- include "keycloak-observability.labels" . | nindent 4 }}
spec:
Expand All @@ -10,8 +11,8 @@ spec:
instanceSelector:
{{ toYaml .Values.grafana | nindent 3 }}
datasources:
{{ toYaml .Values.datasources | nindent 3 }}
{{ toYaml .Values.dashboard.datasources | nindent 3 }}
resyncPeriod: 5s
configMapRef:
name: {{ .Values.name }}-dashboard-definition
name: {{- include "keycloak-observability.name" . | indent 1 }}-dashboard-definition
key: json
11 changes: 11 additions & 0 deletions keycloak-observability/templates/pod-monitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if and ( .Values.podMonitor ) ( .Values.podMonitor.enabled ) }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{- include "keycloak-observability.name" . | indent 1 }}-pod-monitor
namespace: {{- include "keycloak-observability.namespace" . | indent 1 }}
labels:
{{- include "keycloak-observability.labels" . | nindent 4 }}
spec:
{{- toYaml .Values.podMonitor.specs | nindent 2 }}
{{- end }}
11 changes: 11 additions & 0 deletions keycloak-observability/templates/service-monitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if and ( .Values.serviceMonitor ) ( .Values.serviceMonitor.enabled ) }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{- include "keycloak-observability.name" . | indent 1 }}-svc-monitor
namespace: {{- include "keycloak-observability.namespace" . | indent 1 }}
labels:
{{- include "keycloak-observability.labels" . | nindent 4 }}
spec:
{{- toYaml .Values.serviceMonitor.specs | nindent 2 }}
{{- end }}
49 changes: 45 additions & 4 deletions keycloak-observability/values.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,53 @@
# Dashboard name
name: rhsso
global:
name: rhsso
namespace: keycloak

# Grafana instance selector
grafana:
matchLabels:
dashboards: "grafana"

# Default data sources
datasources:
- inputName: "DS_PROMETHEUS"
datasourceName: "Prometheus"
dashboard:
datasources:
- inputName: "DS_PROMETHEUS"
datasourceName: "Prometheus"

# Pod Monitor specs
podMonitor:
enabled: true
specs:
selector:
matchLabels:
app: keycloak
podMetricsEndpoints:
- targetPort: 9990

# Service Monitor specs
serviceMonitor:
enabled: true
specs:
endpoints:
- bearerTokenSecret:
key: ''
path: /auth/realms/master/metrics
port: keycloak
scheme: https
tlsConfig:
ca: { }
cert: { }
insecureSkipVerify: true
- bearerTokenSecret:
key: ''
path: /metrics
port: keycloak-monitoring
scheme: http
tlsConfig:
ca: { }
cert: { }
insecureSkipVerify: true
namespaceSelector: { }
selector:
matchLabels:
app: keycloak

0 comments on commit f3aa46a

Please sign in to comment.