Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grafana helm notification configuration

I am trying to install grafana helm chart with opsgenie notification like so

   helm install stable/grafana -n grafana --namespace monitoring --set-string notifiers."notifiers\.yaml"="notifiers:
- name: opsgenie-notifier
  type: opsgenie
  uid: notifier-1
  settings:
    apiKey: some-key
    apiUrl: https://some-server/alerts"

When I check the config map I see the value is set with an extra pipe at the begining --> |-

apiVersion: v1
data:
  notifiers.yaml: |
    |-
      notifiers:
      - name: opsgenie-notifier
        type: opsgenie
        uid: notifier-1
        settings:
          apiKey: some-key
          apiUrl: https://some-server/alerts
kind: ConfigMap
metadata:
  creationTimestamp: "2019-08-27T00:32:40Z"
  labels:
    app: grafana
    chart: grafana-3.5.10
    heritage: Tiller
    release: grafana
  name: grafana
  namespace: monitoring

Checking the source code - https://github.com/helm/charts/blob/master/stable/grafana/templates/configmap.yaml, I can't figure out why. The below source code should print the values verbatim but its adding an extra line --> |-, causing grafana server to crash as it is unable to read the configuration.

{{- if .Values.notifiers }}
  {{- range $key, $value := .Values.notifiers }}
  {{ $key }}: |
{{ toYaml $value | indent 4 }}
  {{- end -}}
{{- end -}}

I have tried with --set, --set-file and --set-string. Its the same behavio.

like image 227
Anshu Dutta Avatar asked Mar 03 '23 12:03

Anshu Dutta


1 Answers

Easy way to achieve this is by using a values.yaml file as below

notifiers:
  notifiers.yaml:
    notifiers:
    - name: opsgenie-notifier
      type: opsgenie
      uid: notifier-1
      settings:
        apiKey: some-key
        apiUrl: https://some-server/alerts

and by installing as

helm install stable/grafana -n grafana --namespace monitoring --values values.yaml

You can do via the --set/--set-string flag as below

helm install stable/grafana -n grafana --namespace monitoring \
    --set notifiers."notifiers\.yaml".notifiers[0].name="opsgenie-notifier" \
    --set notifiers."notifiers\.yaml".notifiers[0].type="opsgenie" \
    --set notifiers."notifiers\.yaml".notifiers[0].uid="notifier-1" \
    --set notifiers."notifiers\.yaml".notifiers[0].settings.apiKey="some-key" \
    --set notifiers."notifiers\.yaml".notifiers[0].settings.apiUrl="https://some-server/alerts"
like image 66
Tummala Dhanvi Avatar answered Apr 05 '23 21:04

Tummala Dhanvi