Skip to content

Commit

Permalink
Merge pull request #123 from conduktor/cus-334-six-nameoverride-suppo…
Browse files Browse the repository at this point in the history
…rt-in-grafana-template

Gateway Chart: Support nameOverride support in grafana templates
  • Loading branch information
BStarmerSmith authored Oct 18, 2024
2 parents 2db983a + 68db301 commit 816c1d2
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 10 deletions.
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,31 @@ helm-monitoring-stack: ## Install monitoring stack prometheus and grafana
@echo "Install grafana"
kubectl apply -f k3d/monitoring-stack-grafana-crd.yaml

.PHONY: helm-monitoring-stack-grafana-alpha
.ONESHELL:
helm-monitoring-stack-grafana-alpha: ## Install monitoring stack prometheus and grafana with alpha api version
make check-kube-context
@echo "Add prometheus helm repo"
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts || true
helm repo update
@echo "Install prometheus stack"
helm upgrade --install prometheus-stack prometheus-community/kube-prometheus-stack \
--namespace prometheus-stack --create-namespace \
--set prometheus.prometheusSpec.podMonitorSelectorNilUsesHelmValues=false \
--set prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues=false \
--set alertmanager.enabled=false \
--set grafana.enabled=false
@echo "Install grafana operator"
helm upgrade --install grafana-operator bitnami/grafana-operator \
--namespace prometheus-stack --create-namespace \
--set namespaceScope=false \
--set watchNamespaces="" \
--set grafana.enabled=false \
--version 2.9.3
@echo "Install grafana"
kubectl apply -f k3d/monitoring-stack-grafana-crd-alpha.yaml
kubectl apply -f k3d/monitoring-stack-grafana-ds-alpha.yaml

.PHONY: create-test-ns
create-test-ns: ## Create test namespace
make check-kube-context
Expand Down
17 changes: 12 additions & 5 deletions charts/gateway/grafana-dashboards/gateway-logs.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
},
{
"name": "GATEWAY_NAME",
"label": "Gateway name",
"description": "The name of the gateway to monitor",
"type": "constant",
"value": "conduktor-gateway"
}
],
"__elements": {},
Expand Down Expand Up @@ -137,7 +144,7 @@
"uid": "${DS_LOKI}"
},
"editorMode": "builder",
"expr": "sum by(pod) (count_over_time({app=\"conduktor-gateway\"} | pod =~ `$pod` [$__range]))",
"expr": "sum by(pod) (count_over_time({app=\"${GATEWAY_NAME}\"} | pod =~ `$pod` [$__range]))",
"legendFormat": "{{pod}}",
"queryType": "range",
"refId": "A"
Expand Down Expand Up @@ -259,7 +266,7 @@
"uid": "${DS_LOKI}"
},
"editorMode": "builder",
"expr": "sum by(pod, level) (count_over_time({app=\"conduktor-gateway\"} | pod =~ `$pod` | json level=\"level\" | __error__=`` | level =~ `ERROR|WARN` [$__range]))",
"expr": "sum by(pod, level) (count_over_time({app=\"${GATEWAY_NAME}\"} | pod =~ `$pod` | json level=\"level\" | __error__=`` | level =~ `ERROR|WARN` [$__range]))",
"legendFormat": "{{level}}",
"queryType": "range",
"refId": "A"
Expand Down Expand Up @@ -298,7 +305,7 @@
"uid": "${DS_LOKI}"
},
"editorMode": "builder",
"expr": "{app=\"conduktor-gateway\"} | pod =~ `$pod` | json level=\"level\", message=\"message\", thread=\"thread\", logger=\"loggerName\", pod=\"pod\" | __error__=`` | line_format `{{.message}}`",
"expr": "{app=\"${GATEWAY_NAME}\"} | pod =~ `$pod` | json level=\"level\", message=\"message\", thread=\"thread\", logger=\"loggerName\", pod=\"pod\" | __error__=`` | line_format `{{.message}}`",
"legendFormat": "{{level}}",
"queryType": "range",
"refId": "A"
Expand All @@ -321,14 +328,14 @@
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"definition": "label_values(kube_pod_labels{conduktor_app_name=\"conduktor-gateway\"}, pod)",
"definition": "label_values(kube_pod_labels{conduktor_app_name=\"${GATEWAY_NAME}\"}, pod)",
"hide": 0,
"includeAll": true,
"multi": true,
"name": "pod",
"options": [],
"query": {
"query": "label_values(kube_pod_labels{conduktor_app_name=\"conduktor-gateway\"}, pod)",
"query": "label_values(kube_pod_labels{conduktor_app_name=\"${GATEWAY_NAME}\"}, pod)",
"refId": "StandardVariableQuery"
},
"refresh": 2,
Expand Down
17 changes: 12 additions & 5 deletions charts/gateway/grafana-dashboards/gateway.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
},
{
"name": "GATEWAY_NAME",
"label": "Gateway name",
"description": "The name of the gateway to monitor",
"type": "constant",
"value": "conduktor-gateway"
}
],
"__elements": {},
Expand Down Expand Up @@ -3671,8 +3678,8 @@
{
"current": {
"selected": true,
"text": "conduktor-gateway",
"value": "conduktor-gateway"
"text": "${GATEWAY_NAME}",
"value": "${GATEWAY_NAME}"
},
"hide": 2,
"includeAll": false,
Expand All @@ -3682,11 +3689,11 @@
"options": [
{
"selected": true,
"text": "conduktor-gateway",
"value": "conduktor-gateway"
"text": "${GATEWAY_NAME}",
"value": "${GATEWAY_NAME}"
}
],
"query": "conduktor-gateway",
"query": "${GATEWAY_NAME}",
"queryValue": "",
"skipUrlSync": false,
"type": "custom"
Expand Down
4 changes: 4 additions & 0 deletions charts/gateway/templates/grafana-dashboards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ spec:
datasources:
- inputName: "DS_PROMETHEUS"
datasourceName: {{ .Values.metrics.grafana.datasources.prometheus | quote }}
- inputName: "GATEWAY_NAME"
datasourceName: {{ include "conduktor-gateway.fullname" . | quote }}
---
apiVersion: integreatly.org/v1alpha1
kind: GrafanaDashboard
Expand All @@ -45,5 +47,7 @@ spec:
datasourceName: {{ .Values.metrics.grafana.datasources.loki | quote }}
- inputName: "DS_PROMETHEUS"
datasourceName: {{ .Values.metrics.grafana.datasources.prometheus | quote }}
- inputName: "GATEWAY_NAME"
datasourceName: {{ include "conduktor-gateway.fullname" . | quote }}
{{- end }}
{{- end }}
18 changes: 18 additions & 0 deletions k3d/monitoring-stack-grafana-crd-alpha.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
apiVersion: integreatly.org/v1alpha1
kind: Grafana
metadata:
name: grafana
namespace: prometheus-stack
labels:
dashboards: "grafana"
spec:
config:
log:
mode: "console"
security:
admin_user: root
admin_password: secret
deployment:
replicas: 1
baseImage: grafana/grafana:10.2.2
17 changes: 17 additions & 0 deletions k3d/monitoring-stack-grafana-ds-alpha.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Has to go in it's own file due to how old grafana API works: https://github.com/grafana/grafana-operator/issues/652
---
apiVersion: integreatly.org/v1alpha1
kind: GrafanaDataSource
metadata:
name: "prometheus-ds"
namespace: "prometheus-stack"
spec:
name: prometheus-ds
datasources:
- name: prometheus
type: prometheus
url: http://prometheus-stack-kube-prom-prometheus:9090
access: proxy
isDefault: true
jsonData:
tlsSkipVerify: true

0 comments on commit 816c1d2

Please sign in to comment.