Karma

  • Leon
Channel Revision Published Runs on
latest/stable 28 28 Jun 2024
Ubuntu 20.04
latest/candidate 28 21 Jun 2024
Ubuntu 20.04
latest/beta 28 04 Jun 2024
Ubuntu 20.04
latest/edge 28 22 Apr 2024
Ubuntu 20.04
1.0/stable 20 29 Feb 2024
Ubuntu 20.04
1.0/candidate 20 12 Dec 2023
Ubuntu 20.04
1.0/beta 20 12 Dec 2023
Ubuntu 20.04
1.0/edge 20 12 Dec 2023
Ubuntu 20.04
juju deploy karma-k8s
Show information

Platform:

charms.karma_k8s.v0.karma_dashboard

Karma library.

This library is designed to be used by a charm consuming or providing the karma-dashboard relation. This library is published as part of the Karma charm.

You can file bugs here!

A typical example of including this library might be:

# ...
from charms.karma_k8s.v0.karma_dashboard import KarmaConsumer

class SomeApplication(CharmBase):
  def __init__(self, *args):
    # ...
    self.karma_consumer = KarmaConsumer(self, "dashboard")
    # ...

class KarmaAlertmanagerConfigChanged

Event raised when karma configuration is changed.

Description

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

class KarmaConsumerEvents

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 , relation_role: RelationRole )

class KarmaConsumer

A "consumer" handler to be used by the Karma charm (the 'requires' side).

Arguments

charm (CharmBase)

consumer charm

name (str)

from consumer's metadata.yaml

Attributes

relation_charm (CharmBase)
consumer charm

Description

This library offers the interface needed in order to forward Alertmanager URLs and associated information to the Karma application.

To have your charm provide URLs to Karma, declare the interface's use in your charm's metadata.yaml file:

provides:
  karma-dashboard:
    interface: karma_dashboard

A typical example of importing this library might be

from charms.alertmanager_karma.v0.karma_dashboard import KarmaConsumer

In your charm's __init__ method:

self.karma_consumer = KarmaConsumer(self, "dashboard")

The consumer charm is expected to observe and respond to the :class:KarmaAlertmanagerConfigChanged event, for example:

self.framework.observe(
    self.karma_consumer.on.alertmanager_config_changed, self._on_alertmanager_config_changed
)

This consumer observes relation joined, changed and departed events on behalf of the charm.

From charm code you can then obtain the list of proxied alertmanagers via:

alertmanagers = self.karma_consumer.get_alertmanager_servers()

Methods

KarmaConsumer. __init__( self , charm , relation_name: str )

KarmaConsumer. get_alertmanager_servers( self )

Return configuration data for all related alertmanager servers.

Returns

List of server configurations, in the format prescribed by the Karma project

Description

The exact spec is described in the Karma project documentation https://github.com/prymitive/karma/blob/main/docs/CONFIGURATION.md#alertmanagers Every item in the returned list represents an item under the "servers" yaml section.

KarmaConsumer. config_valid( self )

Check if the current configuration is valid.

Returns

True if the currently stored configuration for an alertmanager target is valid; False otherwise.

class KarmaProvider

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

Arguments

charm (CharmBase)

consumer charm

relation_name (str)

relation name from consumer's metadata.yaml

Attributes

charm (CharmBase)
consumer charm

Description

This library offers the interface needed in order to provide Alertmanager URLs and associated information to the Karma application.

To have your charm provide URLs to Karma, declare the interface's use in your charm's metadata.yaml file:

provides:
  karma-dashboard:
    interface: karma_dashboard

A typical example of importing this library might be

from charms.karma_k8s.v0.karma_dashboard import KarmaProvider

In your charm's __init__ method:

self.karma_provider = KarmaProvider(self, "karma-dashboard")

The provider charm is expected to set the target URL via the consumer library, for example in config-changed:

self.karma_provider.target = "http://whatever:9093"

The provider charm can then obtain the configured IP address, for example:

self.unit.status = ActiveStatus("Proxying {}".format(self.karma_provider.target))

Methods

KarmaProvider. __init__( self , charm , relation_name: str )

KarmaProvider. target( self )

Description

str: Alertmanager URL to be used by Karma. None

KarmaProvider. target( self , url: str )

Configure an alertmanager target server to be used by Karma.

Arguments

url

Complete URL (scheme and port) of the target alertmanager server.

Returns

None.

Description

Apart from the server's URL, the server configuration is determined from the juju topology.