diff --git a/keycloak-observability/README.md b/keycloak-observability/README.md index 3a943f7..65e3a41 100644 --- a/keycloak-observability/README.md +++ b/keycloak-observability/README.md @@ -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. ??? diff --git a/keycloak-observability/templates/_helpers.tpl b/keycloak-observability/templates/_helpers.tpl index 0ec012b..7f7c85e 100644 --- a/keycloak-observability/templates/_helpers.tpl +++ b/keycloak-observability/templates/_helpers.tpl @@ -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 }} {{/* @@ -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 }} @@ -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 -}} {{/* diff --git a/keycloak-observability/templates/dashboard-configmap.yaml b/keycloak-observability/templates/dashboard-configmap.yaml index 821f545..a3e778c 100644 --- a/keycloak-observability/templates/dashboard-configmap.yaml +++ b/keycloak-observability/templates/dashboard-configmap.yaml @@ -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: diff --git a/keycloak-observability/templates/dashboard.yaml b/keycloak-observability/templates/dashboard.yaml index 9d35eda..692509f 100644 --- a/keycloak-observability/templates/dashboard.yaml +++ b/keycloak-observability/templates/dashboard.yaml @@ -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: @@ -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 \ No newline at end of file diff --git a/keycloak-observability/templates/pod-monitor.yaml b/keycloak-observability/templates/pod-monitor.yaml new file mode 100644 index 0000000..7e0bdfc --- /dev/null +++ b/keycloak-observability/templates/pod-monitor.yaml @@ -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 }} \ No newline at end of file diff --git a/keycloak-observability/templates/service-monitor.yaml b/keycloak-observability/templates/service-monitor.yaml new file mode 100644 index 0000000..1c47926 --- /dev/null +++ b/keycloak-observability/templates/service-monitor.yaml @@ -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 }} diff --git a/keycloak-observability/values.yaml b/keycloak-observability/values.yaml index cc99f65..4ea8853 100644 --- a/keycloak-observability/values.yaml +++ b/keycloak-observability/values.yaml @@ -1,5 +1,7 @@ # Dashboard name -name: rhsso +global: + name: rhsso + namespace: keycloak # Grafana instance selector grafana: @@ -7,6 +9,45 @@ grafana: 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 \ No newline at end of file