---
title: Charmhub | Deploy Alertmanager using Charmhub - The Open Operator Collection
description: Deploy the latest version of Alertmanager as a Kubernetes Operator on
  any cloud.
url: https://charmhub.io/alertmanager-k8s/libraries/alertmanager_remote_configuration
---

# Alertmanager

[Canonical Observability](https://charmhub.io/publisher/observability "View all packages from Canonical Observability")

* [Canonical Observability](https://charmhub.io/publisher/observability "View all packages from Canonical Observability")

Platform:

0.31/stable tf-0.31.1-1-g7796bf8

```
juju deploy alertmanager-k8s --channel 0.31/stable
```

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

[Toggle side navigation](https://charmhub.io/alertmanager-k8s/libraries/alertmanager_remote_configuration#drawer)

## charms.alertmanager\_k8s.v0.alertmanager\_remote\_configuration

* [*Docstrings*Docstrings](https://charmhub.io/alertmanager-k8s/libraries/alertmanager_remote_configuration)
  [*Code*Source code](https://charmhub.io/alertmanager-k8s/libraries/alertmanager_remote_configuration/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.alertmanager_k8s.v0.alertmanager_remote_configuration
    ```

    [Download alertmanager\_remote\_configuration.py](https://charmhub.io/alertmanager-k8s/libraries/alertmanager_remote_configuration/download)
  + *Last updated* 18 Nov 2025
  + *Revision* Library version 0.4

Alertmanager Remote Configuration library.

This library offers the option of configuring Alertmanager via relation data.
It has been created with the `alertmanager-k8s` and the `alertmanager-k8s-configurer`
(https://charmhub.io/alertmanager-configurer-k8s) charms in mind, but can be used by any charms
which require functionalities implemented by this library.

To get started using the library, you just need to fetch the library using `charmcraft`.

```
cd some-charm
charmcraft fetch-lib charms.alertmanager_k8s.v0.alertmanager_remote_configuration
```

Charms that need to push Alertmanager configuration to a charm exposing relation using
the `alertmanager_remote_configuration` interface, should use the `RemoteConfigurationProvider`.
Charms that need to can utilize the Alertmanager configuration provided from the external source
through a relation using the `alertmanager_remote_configuration` interface, should use
the `RemoteConfigurationRequirer`.

---

Index

* [class ConfigReadError](https://charmhub.io/alertmanager-k8s/libraries/alertmanager_remote_configuration#configreaderror)
* + [def \_\_init\_\_(
    self,
    config\_file)](https://charmhub.io/alertmanager-k8s/libraries/alertmanager_remote_configuration#configreaderror-__init__)
* [def config\_main\_keys\_are\_valid(
  config
  )](https://charmhub.io/alertmanager-k8s/libraries/alertmanager_remote_configuration#config_main_keys_are_valid)
* [class AlertmanagerRemoteConfigurationChangedEvent](https://charmhub.io/alertmanager-k8s/libraries/alertmanager_remote_configuration#alertmanagerremoteconfigurationchangedevent)
* [class AlertmanagerRemoteConfigurationRequirerEvents](https://charmhub.io/alertmanager-k8s/libraries/alertmanager_remote_configuration#alertmanagerremoteconfigurationrequirerevents)
* [class RemoteConfigurationRequirer](https://charmhub.io/alertmanager-k8s/libraries/alertmanager_remote_configuration#remoteconfigurationrequirer)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name)](https://charmhub.io/alertmanager-k8s/libraries/alertmanager_remote_configuration#remoteconfigurationrequirer-__init__)
* + [def config(
    self)](https://charmhub.io/alertmanager-k8s/libraries/alertmanager_remote_configuration#remoteconfigurationrequirer-config)
* [class AlertmanagerConfigurationBrokenEvent](https://charmhub.io/alertmanager-k8s/libraries/alertmanager_remote_configuration#alertmanagerconfigurationbrokenevent)
* [class AlertmanagerRemoteConfigurationProviderEvents](https://charmhub.io/alertmanager-k8s/libraries/alertmanager_remote_configuration#alertmanagerremoteconfigurationproviderevents)
* [class RemoteConfigurationProvider](https://charmhub.io/alertmanager-k8s/libraries/alertmanager_remote_configuration#remoteconfigurationprovider)
* + [def \_\_init\_\_(
    self,
    charm,
    alertmanager\_config,
    relation\_name)](https://charmhub.io/alertmanager-k8s/libraries/alertmanager_remote_configuration#remoteconfigurationprovider-__init__)
* + [def with\_config\_file(
    cls,
    charm,
    config\_file,
    relation\_name)](https://charmhub.io/alertmanager-k8s/libraries/alertmanager_remote_configuration#remoteconfigurationprovider-with_config_file)
* + [def load\_config\_file(
    path)](https://charmhub.io/alertmanager-k8s/libraries/alertmanager_remote_configuration#remoteconfigurationprovider-load_config_file)
* + [def update\_relation\_data\_bag(
    self,
    alertmanager\_config)](https://charmhub.io/alertmanager-k8s/libraries/alertmanager_remote_configuration#remoteconfigurationprovider-update_relation_data_bag)

#### class ConfigReadError

Description

Raised if Alertmanager configuration can't be read. None

Methods

ConfigReadError.
\_\_init\_\_(

*self*

,
config\_file: str
)

#### def config\_main\_keys\_are\_valid(config)

Checks whether main keys in the Alertmanager's config file are valid.

Arguments

config

Alertmanager config dictionary

Returns

True/False

Description

This method facilitates the basic confidence check of Alertmanager's configuration. It checks
whether given configuration contains only allowed main keys or not. `templates` have been
removed from the list of allowed main keys to reflect the fact that `alertmanager-k8s` doesn't
accept it as part of config (see `alertmanager-k8s` description for more details).
Full validation of the config is done on the `alertmanager-k8s` charm side.

#### class AlertmanagerRemoteConfigurationChangedEvent

Description

Event emitted when Alertmanager remote\_configuration relation data bag changes. None

#### class AlertmanagerRemoteConfigurationRequirerEvents

Description

Event descriptor for events raised by `AlertmanagerRemoteConfigurationRequirer`. None

#### class RemoteConfigurationRequirer

API that manages a required `alertmanager_remote_configuration` relation.

Description

The `RemoteConfigurationRequirer` object can be instantiated as follows in your charm:

```
from charms.alertmanager_k8s.v0.alertmanager_remote_configuration import (
    RemoteConfigurationRequirer,
)

def __init__(self, *args):
    ...
    self.remote_configuration = RemoteConfigurationRequirer(self)
    ...
```

The `RemoteConfigurationRequirer` assumes that, in the `metadata.yaml` of your charm,
you declare a required relation as follows:

```
requires:
    remote-configuration:  # Relation name
        interface: alertmanager_remote_configuration  # Relation interface
        limit: 1
```

The `RemoteConfigurationRequirer` provides a public `config` method for exposing the data
from the relation data bag. Typical usage of these methods in the provider charm would look
something like:

```
def get_config(self, *args):
    ...
    configuration, templates = self.remote_configuration.config()
    ...
    self.container.push("/alertmanager/config/file.yml", configuration)
    self.container.push("/alertmanager/templates/file.tmpl", templates)
    ...
```

Separation of the main configuration and the templates is dictated by the assumption that
the default provider of the `alertmanager_remote_configuration` relation will be
`alertmanager-k8s` charm, which requires such separation.

Methods

RemoteConfigurationRequirer.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
relation\_name: str
)

API that manages a required `remote-configuration` relation.

Arguments

charm

The charm object that instantiated this class.

relation\_name

Name of the relation with the `alertmanager_remote_configuration`
interface as defined in metadata.yaml. Defaults to `remote-configuration`.

RemoteConfigurationRequirer.
config(

*self*
)

Exposes Alertmanager configuration sent inside the relation data bag.

Returns

tuple

Alertmanager configuration (dict) and templates (list)

Description

Charm which requires Alertmanager configuration, can access it like below:

```
def get_config(self, *args):
    ...
    configuration, templates = self.remote_configuration.config()
    ...
    self.container.push("/alertmanager/config/file.yml", configuration)
    self.container.push("/alertmanager/templates/file.tmpl", templates)
    ...
```

#### class AlertmanagerConfigurationBrokenEvent

Description

Event emitted when configuration provided by the Provider charm is invalid. None

#### class AlertmanagerRemoteConfigurationProviderEvents

Description

Event descriptor for events raised by `AlertmanagerRemoteConfigurationProvider`. None

#### class RemoteConfigurationProvider

API that manages a provided `alertmanager_remote_configuration` relation.

Description

The `RemoteConfigurationProvider` is intended to be used by charms that need to push data
to other charms over the `alertmanager_remote_configuration` interface.

The `RemoteConfigurationProvider` object can be instantiated as follows in your charm:

```
from charms.alertmanager_k8s.v0.alertmanager_remote_configuration import
    RemoteConfigurationProvider,
)

def __init__(self, *args):
    ...
    config = RemoteConfigurationProvider.load_config_file(FILE_PATH)
    self.remote_configuration_provider = RemoteConfigurationProvider(
        charm=self,
        alertmanager_config=config,
    )
    ...
```

Alternatively, RemoteConfigurationProvider can be instantiated using a factory, which allows
using a configuration file path directly instead of a configuration string:

```
from charms.alertmanager_k8s.v0.alertmanager_remote_configuration import
    RemoteConfigurationProvider,
)

def __init__(self, *args):
    ...
    self.remote_configuration_provider = RemoteConfigurationProvider.with_config_file(
        charm=self,
        config_file=FILE_PATH,
    )
    ...
```

The `RemoteConfigurationProvider` assumes that, in the `metadata.yaml` of your charm,
you declare a required relation as follows:

```
provides:
    remote-configuration:  # Relation name
        interface: alertmanager_remote_configuration  # Relation interface
```

The `RemoteConfigurationProvider` provides handling of the most relevant charm
lifecycle events. On each of the defined Juju events, Alertmanager configuration and templates
from a specified file will be pushed to the relation data bag.
Inside the relation data bag, Alertmanager configuration will be stored under
`alertmanager_configuration` key, while the templates under the `alertmanager_templates` key.
Separation of the main configuration and the templates is dictated by the assumption that
the default provider of the `alertmanager_remote_configuration` relation will be
`alertmanager-k8s` charm, which requires such separation.

Methods

RemoteConfigurationProvider.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
alertmanager\_config

,
relation\_name: str
)

API that manages a provided `remote-configuration` relation.

Arguments

charm

The charm object that instantiated this class.

alertmanager\_config

Alertmanager configuration dictionary.

relation\_name

Name of the relation with the `alertmanager_remote_configuration`
interface as defined in metadata.yaml. Defaults to `remote-configuration`.

RemoteConfigurationProvider.
with\_config\_file(

cls

,
charm: CharmBase

,
config\_file: str

,
relation\_name: str
)

The RemoteConfigurationProvider object factory.

Arguments

charm

The charm object that instantiated this class.

config\_file

Path to the Alertmanager configuration file.

relation\_name

Name of the relation with the `alertmanager_remote_configuration`
interface as defined in metadata.yaml. Defaults to `remote-configuration`.

Returns

RemoteConfigurationProvider object

Description

This factory provides an alternative way of instantiating the RemoteConfigurationProvider.
While the default constructor requires passing a config dict, the factory allows using
a configuration file path.

RemoteConfigurationProvider.
load\_config\_file(

path: str
)

Reads given Alertmanager configuration file and turns it into a dictionary.

Arguments

path

Path to the Alertmanager configuration file

Returns

dict

Alertmanager configuration file in a form of a dictionary

RemoteConfigurationProvider.
update\_relation\_data\_bag(

*self*

,
alertmanager\_config
)

Updates relation data bag with Alertmanager config and templates.

Arguments

alertmanager\_config

Alertmanager configuration dictionary.

Description

Before updating relation data bag, basic confidence check of given configuration is done.
