Configure Alertmanagers using mimirtool
In addition to configuring Alertmanagers from the Grafana UI, you can use mimirtool
to set up an Alertmanager configuration for the Mimir instance running in your Grafana Cloud Stack.
Install and configure access for mimirtool
mimirtool
is a command-line tool for interacting with Grafana Mimir, which powers Grafana Cloud Metrics and Alerts. For detailed installation instructions and configuration options, refer to Mimirtool
.
To use mimirtool
with Grafana Cloud, you need the Mimir address of your Cloud Stack, a Cloud instance ID, and an API token with proper permissions.
Environment variable | Flag | Description |
---|---|---|
MIMIR_ADDRESS | --address | The address of the API of the Grafana Mimir cluster. For instance, https://prometheus-us-central1.grafana.net. |
MIMIR_API_USER | --user | Grafana Cloud instance ID. These should be part of /orgs/<yourOrgName> /. |
MIMIR_API_KEY | --key | API token with permissions. Refer to Grafana Cloud Access Policies |
Manage the Alertmanager configuration for a Grafana Cloud Mimir instance
With your instance ID, URL, and API token you’re now ready to upload your Alertmanager configuration. You can set the configuration options detailed in this guide, either as environment variables or command-line flags. Use the following commands and files as a reference.
Ultimately, you need to write your own or adapt an configuration file example for alerts to be delivered.
The following alertmanager.yml
file is an example Alertmanager configuration. Note that this not a working configuration—alerts are not delivered using this setup, but the Alertmanager UI is accessible.
global:
smtp_smarthost: 'localhost:25'
smtp_from: 'youraddress@example.org'
route:
receiver: example-email
receivers:
- name: example-email
email_configs:
- to: 'youraddress@example.org'
With this file, you can run the following commands to upload your Alertmanager configuration in your Alerts instance.
mimirtool alertmanager load alertmanager.yml \
--address=https://alertmanager-us-central1.grafana.net \
--id=<yourID> \
--key=<yourKey>
Then, confirm that the rules were uploaded correctly by running:
mimirtool alertmanager get \
--address=https://alertmanager-us-central1.grafana.net \
--id=<yourID> \
--key=<yourKey>
You should see output similar to the following:
global:
smtp_smarthost: 'localhost:25'
smtp_from: 'youraddress@example.org'
route:
receiver: example-email
receivers:
- name: example-email
email_configs:
- to: 'youraddress@example.org'
Finally, you can delete the configuration with:
mimirtool alertmanager delete \
--address=https://alertmanager-us-central1.grafana.net \
--id=<yourID> \
--key=<yourKey>
After you upload a working Alertmanager configuration file, you can access the Alertmanager UI at: https://alertmanager-us-central1.grafana.net/alertmanager.