Alertmanager

  • Canonical Observability
Channel Revision Published Runs on
latest/stable 125 06 Sep 2024
Ubuntu 20.04
latest/candidate 128 19 Nov 2024
Ubuntu 20.04
latest/beta 138 19 Nov 2024
Ubuntu 20.04
latest/edge 138 18 Oct 2024
Ubuntu 20.04
1.0/stable 96 12 Dec 2023
Ubuntu 20.04
1.0/candidate 96 22 Nov 2023
Ubuntu 20.04
1.0/beta 96 22 Nov 2023
Ubuntu 20.04
1.0/edge 96 22 Nov 2023
Ubuntu 20.04
juju deploy alertmanager-k8s
Show information

Platform:

charms.alertmanager_k8s.v1.alertmanager_dispatch

Alertmanager library.

This library is designed to be used by a charm consuming or providing the alertmanager_dispatch relation interface.

This library is published as part of the Alertmanager charm.

You can file bugs here!

A typical example of including this library might be:

# ...
from charms.alertmanager_k8s.v1.alertmanager_dispatch import AlertmanagerConsumer

class SomeApplication(CharmBase):
  def __init__(self, *args):
    # ...
    self.alertmanager_consumer = AlertmanagerConsumer(self, relation_name="alertmanager")
    # ...

class ClusterChanged

Event raised when an alertmanager cluster is changed.

Description

If an alertmanager unit is added to or removed from a relation, then a :class:ClusterChanged event should be emitted.

class AlertmanagerConsumerEvents

Description

Event descriptor for events raised by AlertmanagerConsumer. None

class RelationManagerBase

Base class that represents relation ends ("provides" and "requires").

Methods

RelationManagerBase. __init__( self , charm: CharmBase , relation_name: str , relation_role: RelationRole )

class AlertmanagerConsumer

A "consumer" handler to be used by charms that relate to Alertmanager (the 'requires' side).

Arguments

charm (CharmBase)

consumer charm

relation_name (str)

from consumer's metadata.yaml

Attributes

charm (CharmBase)
consumer charm

Description

To have your charm consume alertmanager cluster data, declare the interface's use in your charm's metadata.yaml file:

requires:
  alertmanager:
    interface: alertmanager_dispatch

A typical example of importing this library might be

from charms.alertmanager_k8s.v1.alertmanager_dispatch import AlertmanagerConsumer

In your charm's __init__ method:

self.alertmanager_consumer = AlertmanagerConsumer(self, relation_name="alertmanager")

Every change in the alertmanager cluster emits a :class:ClusterChanged event that the consumer charm can register and handle, for example:

self.framework.observe(self.alertmanager_consumer.on.cluster_changed,
                       self._on_alertmanager_cluster_changed)

The updated alertmanager cluster can then be obtained via the get_cluster_info method

This consumer library expect the consumer charm to observe the cluster_changed event.

Methods

AlertmanagerConsumer. __init__( self , charm: CharmBase )

AlertmanagerConsumer. get_cluster_info( self )

Description

Returns a list of URLs of all alertmanager units. None

class AlertmanagerProvider

A "provider" handler to be used by charms that relate to Alertmanager (the 'provides' side).

Arguments

charm

consumer charm

external_url

URL for this unit's workload API endpoint

relation_name

relation name (not interface name)

Description

To have your charm provide alertmanager cluster data, declare the interface's use in your charm's metadata.yaml file:

provides:
  alerting:
    interface: alertmanager_dispatch

A typical example of importing this library might be

from charms.alertmanager_k8s.v1.alertmanager_dispatch import AlertmanagerProvider

In your charm's __init__ method:

self.alertmanager_provider = AlertmanagerProvider(
    self, relation_name=self._relation_name, external_url=f"http://{socket.getfqdn()}:9093"
)

Then inform consumers on any update to alertmanager cluster data via

self.alertmanager_provider.update(external_url=self.ingress.url)

This provider auto-registers relation events on behalf of the main Alertmanager charm.

Methods

AlertmanagerProvider. __init__( self , charm: CharmBase )

AlertmanagerProvider. update( self )

Description

Update data pertaining to this relation manager (similar args to init). None