diff --git a/examples/contact_point/_index.md b/examples/contact_point/_index.md index 050e4bd79..b68204b04 100644 --- a/examples/contact_point/_index.md +++ b/examples/contact_point/_index.md @@ -9,16 +9,22 @@ tags: Contact points contain the configuration for sending alert notifications. You can assign a contact point either in the alert rule or notification policy options. For a complete explanation on notification policies, refer to the [upstream Grafana documentation](https://grafana.com/docs/grafana/latest/alerting/fundamentals/notifications/contact-points/). -{{% alert title="Note" color="secondary" %}} -The Grafana operator currently only supports a single receiver per contact point definition. -As a workaround you can create multiple contact points with the same `spec.name` value. -Follow issue [#1529](https://github.com/grafana/grafana-operator/issues/1529) for further updates on this topic. -{{% /alert %}} - -The following snippet shows an example contact point which notifies a specific email address. +The following snippet shows an example contact point which notifies a specific email address and a webhook endpoint. It also highlights how secrets and config maps can utilized to externalize some of the configuration. This is especially useful for contact points which contain sensitive information. To view the entire configuration that you can do within Contact-Points, look at our [API documentation](/docs/api/#grafanacontactpointspec). {{< readfile file="./resources.yaml" code="true" lang="yaml" >}} + +### Deprecated Single receiver format + +`GrafanaContactPoint` did not support multiple receivers prior to `v5.21.0`. + +The previous format is now deprecated, but is still supported. + +The fields `.spec.type`, `.spec.settings`, and `.spec.valuesFrom` are entirely ignored when `.spec.recievers[...]` is configured, but the below configuration is still valid for the duration of `v1beta1`. + +This means full backwards compatibility during transitions to the receivers field. + +{{< readfile file="./previous-format.yaml" code="true" lang="yaml" >}} diff --git a/examples/contact_point/previous-format.yaml b/examples/contact_point/previous-format.yaml new file mode 100644 index 000000000..79125995f --- /dev/null +++ b/examples/contact_point/previous-format.yaml @@ -0,0 +1,19 @@ +--- +apiVersion: grafana.integreatly.org/v1beta1 +kind: GrafanaContactPoint +metadata: + name: previous-format +spec: + name: required + instanceSelector: + matchLabels: + instance: my-grafana-stack + type: "email" + settings: + subject: 'Grafana Alert' + valuesFrom: + - targetPath: addresses + valueFrom: + secretKeyRef: + name: contacts + key: alert-mails diff --git a/examples/contact_point/resources.yaml b/examples/contact_point/resources.yaml index 6bd3474e1..f4cf7464e 100644 --- a/examples/contact_point/resources.yaml +++ b/examples/contact_point/resources.yaml @@ -1,25 +1,38 @@ apiVersion: v1 kind: Secret metadata: - name: contact-mails + name: contacts stringData: alert-mails: "foo@example.com" + alert-hook: "webhook.example.invalid" --- apiVersion: grafana.integreatly.org/v1beta1 kind: GrafanaContactPoint metadata: name: grafanacontactpoint-sample spec: - name: grafanacontactpoint-sample - type: "email" + name: Optional Name instanceSelector: matchLabels: instance: my-grafana-stack - settings: - subject: 'Grafana Alert' - valuesFrom: - - targetPath: addresses - valueFrom: - secretKeyRef: - name: contact-mails - key: alert-mails + # Editing ContactPoints in the UI is disabled by default + editable: true # editable is immutable and can only be set at creation + receivers: + - type: email + settings: + subject: Grafana Alert + valuesFrom: + - targetPath: addresses + valueFrom: + secretKeyRef: + name: contacts + key: alert-mails + - type: webhook + settings: + title: Grafana Alert + valuesFrom: + - targetPath: url + valueFrom: + secretKeyRef: + name: contacts + key: alert-hook