Grafana头盔通知配置

时间:2019-08-27 00:42:20

标签: kubernetes grafana kubernetes-helm grafana-alerts

我正在尝试通过opsgenie通知安装grafana舵图

   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"

当我检查配置映射时,我看到值在开头处用额外的管道设置-> |-

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

检查源代码-https://github.com/helm/charts/blob/master/stable/grafana/templates/configmap.yaml,我不知道为什么。下面的源代码应按原样打印值,但会增加一行-> |-,导致grafana服务器因无法读取配置而崩溃。

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

我尝试使用--set,-set-file和--set-string。它是相同的行为。

1 个答案:

答案 0 :(得分:2)

轻松实现此目标的方法是使用下面的values.yaml文件

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

并通过安装为

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

您可以通过--set /-set-string标志执行以下操作

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"