---
title: Charmhub | Deploy Generic Exporter using Charmhub - The Open Operator Collection
description: Deploy the latest version of Generic Exporter on any cloud.
url: https://charmhub.io/generic-exporter-operator/docs/attach-alert-rules
---

# Generic Exporter

[Iurii Kondrakov](https://charmhub.io/publisher/deezzir "View all packages from Iurii Kondrakov")

* [Iurii Kondrakov](https://charmhub.io/publisher/deezzir "View all packages from Iurii Kondrakov")

Platform:

24.04

22.04

dev/edge 58

```
juju deploy generic-exporter-operator --channel dev/edge
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

---

#### Relevant links

* [Homepage](https://charmhub.io/velero-operator)

---

#### Contacts

* [Submit a bug](https://github.com/canonical/generic-exporter-operator/issues)

---

Share your thoughts on this charm with the community on discourse.

[Join the discussion](https://discourse.charmhub.io/)

# Attach alert rules from a resource

This guide describes how to provide custom Prometheus alert rules to the Generic Exporter operator using a Juju resource. The charm will:

* Read the attached resource file (YAML)
* Write it into an alerts rules directory under `/run/<app>-<unit-id>/`
* Expose those rules via the `cos-agent` relation to Grafana Agent and COS Lite

## [Requirements](https://charmhub.io/generic-exporter-operator/docs/attach-alert-rules#p-40632-requirements)

* Generic Exporter operator deployed and running.
* (Optional) Opentelemetry Collector and COS Lite are already integrated, as described in the previous how-to.

## [Prepare an alerts resource](https://charmhub.io/generic-exporter-operator/docs/attach-alert-rules#p-40632-prepare-an-alerts-resource)

Create a local file `alerts.yaml` containing one or more Prometheus alerting rules. For example:

```
groups:
  - name: generic-exporter.rules
    rules:
      - alert: ExporterDown
        expr: up{job="node-exporter"} == 0
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: "Exporter is down on {{ $labels.instance }}"
          description: "The node-exporter exporter has not been scraping successfully for 5 minutes."
```

Ensure the file is valid YAML and follows Prometheus alert rule syntax.

## [Attach the resource](https://charmhub.io/generic-exporter-operator/docs/attach-alert-rules#p-40632-attach-the-resource)

Attach the resource to the Generic Exporter application. Assuming the app is called `node-exporter`:

```
juju attach-resource node-exporter alerts=./alerts.yaml
```

The charm will:

* Fetch the `alerts` resource
* Write it to a rules directory, for example:

  ```
  /run/node-exporter-0/alerts.yaml
  ```
* Notify Grafana Agent via the `cos-agent` relation so that alerts are reloaded.

## [Use the `dump-alerts` action](https://charmhub.io/generic-exporter-operator/docs/attach-alert-rules#p-40632-use-the-dump-alerts-action)

To verify which rules the charm has loaded, use the `dump-alerts` action (provided by the charm):

```
juju run node-exporter/0 dump-alerts --wait
```

The action prints the effective path on the machine and dumps the alert rules. This is useful for validating that the uploaded resource is being parsed and consumed correctly.

## [Update or remove alerts](https://charmhub.io/generic-exporter-operator/docs/attach-alert-rules#p-40632-update-or-remove-alerts)

To update alert rules, modify `alerts.yaml` and re-attach:

```
juju attach-resource node-exporter alerts=./alerts.yaml
```

To effectively remove alerts:

* Attach an empty rules file, or
* Use a minimal file that defines an empty rule group.

The charm will refresh the rules directory and inform Grafana Agent via its `refresh_events` configuration.

---
