github.com/grafana/pyroscope@v1.18.0/operations/monitoring/helm/pyroscope-monitoring/convert-dashboard.sh (about) 1 #!/usr/bin/env bash 2 3 # Goal of that script is to convert a grafana dashboard from internal GL environments so it can be used with this pyroscope-monitoring chart. 4 5 set -eux 6 set -o pipefail 7 8 # loop over inputs 9 for dashboard in "$@" 10 do 11 filename="$(basename $dashboard)" 12 name="${filename%.*}" 13 destination="templates/_dashboard_${name}.yaml" 14 15 # create basic dashboard 16 echo "{{- define \"pyroscope-monitoring.dashboards.${name}\" -}}" > "${destination}" 17 echo "{{- \$dashboard := \"${name}\" -}}" >> "${destination}" 18 cat "$dashboard" | js-yaml | sed 's/{{.*}}/{{"\0\"}}/g' >> "${destination}" 19 echo "{{- end }}" >> "${destination}" 20 21 # replace specific namespace 22 sed -i 's/profiles-ops-002/{{.Values.dashboards.namespace | quote}}/g' "${destination}" 23 sed -i 's/fire|profiles-\.\*/{{.Values.dashboards.namespaceRegex | quote}}/g' "${destination}" 24 sed -i 's/fire-\.\*|profiles-\.\*/{{.Values.dashboards.namespaceRegex | quote}}/g' "${destination}" 25 26 # replace default cluster 27 sed -i 's/ops-eu-south-0/{{.Values.dashboards.cluster | quote}}/g' "${destination}" 28 29 # replace cortex-gw selectors 30 sed -i 's/{job=~"$namespace\/cortex-gw(-internal)?"/{ {{ include "pyroscope-monitoring.dashboards-ingest-selector" . }}, namespace=~"$namespace"/g' "${destination}" 31 sed -i 's/job=~"$namespace\/cortex-gw(-internal)?"/{{ include "pyroscope-monitoring.dashboards-ingest-selector" . }}, namespace=~"$namespace"/g' "${destination}" 32 33 # replace cadvisor selectors 34 sed -i 's/{job="kube-system\/cadvisor"/{ {{ .Values.dashboards.cadvisorSelector }}/g' "${destination}" 35 sed -i 's/job="kube-system\/cadvisor"/{{ .Values.dashboards.cadvisorSelector }}/g' "${destination}" 36 37 # replace kube-state-metrics selectors 38 sed -i 's/{job="kube-system\/kube-state-metrics"/{ {{ .Values.dashboards.kubeStateMetricsSelector }}/g' "${destination}" 39 sed -i 's/job="kube-system\/kube-state-metrics"/{{ .Values.dashboards.kubeStateMetricsSelector }}/g' "${destination}" 40 sed -i 's/{job="kube-state-metrics\/kube-state-metrics"/{ {{ .Values.dashboards.kubeStateMetricsSelector }}/g' "${destination}" 41 sed -i 's/job="kube-state-metrics\/kube-state-metrics"/{{ .Values.dashboards.kubeStateMetricsSelector }}/g' "${destination}" 42 43 # fix extra namespace 44 sed -i 's/{ {{/{{ "{" }}{{/g' "${destination}" 45 done