Skip to content

Create alert with Prometheus

This guide shows you how to create alerts for your application.


You can define alerts by using Kubernetes resources (PrometheusRule), as well as directly in Grafana (GUI based).

You will have a separate alertmanager for each environment available at https://alertmanager.<MY-ENV>

Create PrometheusRule

We use native Prometheus alert rules, and let Alertmanager handle the notifications.

You can define alerts by creating a PrometheusRule resource in your teams namespace.

kind: PrometheusRule
  name: <MY-ALERT>
  namespace: <MY-TEAM>
    team: <MY-TEAM>
  - name: <MY-ALERT>
    - alert: InstanceDown
      expr: kube_deployment_status_replicas_available{namespace="<namespace>", deployment="<application name>"} == 0
      for: 5m
        consequence: Application is unavailable
        action: "`kubectl describe pod <podname>` -> `kubectl logs <podname>`"
        summary: |-
          This is a multi-line summary with
          linebreaks and everything. Here you can give a more detailed
          summary of what this alert is about
        namespace: <MY-TEAM> # required
        severity: critical

Activate the alert

Add the file to your application repository, alongside nais.yaml to deploy with NAIS github action. Some [link](

kubectl apply -f ./nais/alert.yaml

Verify your alert

You can see the alerts in the Alertmanager at https://alertmanager.<MY-ENV> and the defined rules in Prometheus at https://prometheus.<MY-ENV>

Disable resolved (Optional)

A message will be automatically sent when the alert is resolved. In some cases this message may be unnecessary and can be disabled by adding the label send_resolved: "false":

  namespace: <MY-TEAM> # required
  severity: info
  send_resolved: "false"

Learn how to write good alerts here