[v11.4.x] docs>alert-rules>templates:example-fix (#99360)

docs>alert-rules>templates:example-fix (#99355)

* docs>alert-rules>templates:example-fix

* second-fix

* fixed 2 other label templates

(cherry picked from commit 88d5ae8153)

Co-authored-by: antonio <45235678+tonypowa@users.noreply.github.com>
pull/99373/head
grafana-delivery-bot[bot] 5 months ago committed by GitHub
parent f433bc770f
commit 0fc69d16e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 36
      docs/sources/alerting/alerting-rules/templates/examples.md
  2. 2
      docs/sources/alerting/fundamentals/alert-rule-evaluation/state-and-health.md
  3. 2
      docs/sources/setup-grafana/installation/helm/index.md

@ -193,15 +193,11 @@ For additional functions to display or format data, refer to:
Here’s an example of creating a `severity` label based on a query value:
```go
{{ if (gt $values.A.Value 90.0) -}}
critical
{{ else if (gt $values.A.Value 80.0) -}}
high
{{ else if (gt $values.A.Value 60.0) -}}
medium
{{ else -}}
low
{{- end }}
{{- if (gt $values.A.Value 90.0) -}}critical
{{- else if (gt $values.A.Value 80.0) -}}high
{{- else if (gt $values.A.Value 60.0) -}}medium
{{- else -}}low
{{- end -}}
```
In this example, the `severity` label is determined by the query value:
@ -222,10 +218,13 @@ You should avoid displaying query values in labels, as this may create many aler
You can use labels to differentiate alerts coming from various environments (e.g., production, staging, dev). For example, you may want to add a label that sets the environment based on the instance’s label. Here’s how you can template it:
```go
{{ if eq $labels.instance "prod-server-1" }}production
{{ else if eq $labels.instance "staging-server-1" }}staging
{{ else }}development
{{ end }}
{{- if eq $labels.instance "prod-server-1" -}}
production
{{- else if eq $labels.instance "staging-server-1" -}}
staging
{{- else -}}
development
{{- end -}}
```
This would print:
@ -237,10 +236,13 @@ This would print:
To make this template more flexible, you can use a regular expression that matches the instance name with the instance name prefix using the [`match()`](ref:reference-match) function:
```go
{{ if match "^prod-server-.*" $labels.instance }}production
{{ else if match "^staging-server-.*" $labels.instance}}staging
{{ else }}development
{{ end }}
{{- if match "^prod-server-.*" $labels.instance -}}
production
{{- else if match "^staging-server-.*" $labels.instance -}}
staging
{{- else -}}
development
{{- end -}}
```
{{< collapse title="Legacy Alerting templates" >}}

@ -91,7 +91,7 @@ Note that `No Data` and `Error` states are supported only for Grafana-managed al
{{< docs/shared lookup="alerts/table-configure-no-data-and-error.md" source="grafana" version="<GRAFANA_VERSION>" >}}
Note that when you configure the **No Data** or **Error** behavior to `Alerting` or `Normal`, Grafana attempts to keep a stable set of fields under notification `Values`. If your query returns no data or an error, Grafana re-uses the latest known set of fields in `Values`, but will use `-1` in place of the measured value.
Note that when you configure the **No Data** or **Error** behavior to `Alerting` or `Normal`, Grafana attempts to keep a stable set of fields under notification `Values`. If your query returns no data or an error, Grafana reuses the latest known set of fields in `Values`, but will use `-1` in place of the measured value.
### Reduce `No Data` or `Error` alerts

@ -187,7 +187,7 @@ This section describes the steps you must complete to access Grafana via web bro
## Customize Grafana default configuration
Helm is a popular package manager for Kubernetes. It bundles Kubernetes resource manifests to be re-used across different environments. These manifests are written in a templating language, allowing you to provide configuration values via `values.yaml` file, or in-line using Helm, to replace the placeholders in the manifest where these configurations should reside.
Helm is a popular package manager for Kubernetes. It bundles Kubernetes resource manifests to be reused across different environments. These manifests are written in a templating language, allowing you to provide configuration values via `values.yaml` file, or in-line using Helm, to replace the placeholders in the manifest where these configurations should reside.
The `values.yaml` file allows you to customize the chart's configuration by specifying values for various parameters such as image versions, resource limits, service configurations, etc.

Loading…
Cancel
Save