---
title: "ezgh obs alert-rules import"
description: "Import the alerting rules of a Prometheus rule file."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.ezghcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ezgh obs alert-rules import

{/* Generated by ezgh-cli's internal/tools/clidocs from the ezgh command tree. Don't edit: change the command's help in ezgh-cli and regenerate. */}

```sh
ezgh obs alert-rules import <rules.yaml> [--contact-point cp]... [--update] [--dry-run] [flags]
```

Turn each alerting rule of a Prometheus rule file (groups of rules with alert, expr, for, keep_firing_for, labels and annotations) into an alert rule, with Prometheus's semantics: the expression includes the comparison, and every series it returns is an instance. A group's labels go under each rule's. for and keep_firing_for round up to whole minutes, since EZGH evaluates every minute (and a group interval other than 1m is reported). An alert name the file repeats (often one rule per severity) becomes "&lt;alert&gt; (&lt;severity&gt;)", or "&lt;alert&gt; #2".

What can't be imported is listed, and nothing is sent for it: recording rules, the @ modifier, a range, subquery or offset over 1 hour, labels that are templates (EZGH's labels are plain text), and annotation templates that call query (EZGH's templates can't run queries) or $externalURL. obs-api checks each rule again, and one it refuses is reported with its problems while the others go on.

`--contact-point` (ID, slug or name; repeatable) is set on every imported rule. A rule whose name is already in the project is left alone unless `--update`, which replaces its condition, for, keep_firing_for, labels and annotations (and contact points, when given) and keeps the rest. `--dry-run` lists what would happen and sends nothing. It exits 1 if any rule failed.

Part of [`ezgh obs alert-rules`](/cli/reference/obs-alert-rules).

## Examples

```sh
ezgh obs alert-rules import prometheus/alerts.yaml --contact-point "Platform on-call" --dry-run
ezgh obs alert-rules import prometheus/alerts.yaml --contact-point "Platform on-call"
ezgh obs alert-rules import prometheus/alerts.yaml --update
```

## Flags

| Flag | Type | Default | Description |
| --- | --- | --- | --- |
| `--contact-point` | string, repeatable |  | a contact point (ID, slug or name) for every imported rule (repeatable) |
| `--dry-run` | boolean |  | list what would happen, and send nothing |
| `--update` | boolean |  | replace rules whose name is already in the project |

This command also takes the [global flags](/cli/reference#global-flags).

Source: https://docs.ezghcloud.com/cli/reference/obs-alert-rules-import/index.mdx
