Skip to main content

Sloth integration for Juju charms - SLO (Service Level Objective) management with the Sloth operator.

Project description

charmlibs.interfaces.sloth

Sloth integration library for Juju charms, providing SLO (Service Level Objective) management with the Sloth operator for generating Prometheus recording and alerting rules.

Features

  • Provider/Requirer pattern: Enables charms to share SLO specifications with Sloth
  • Raw YAML interface: Provider passes raw YAML strings; validation happens on requirer side
  • Automatic topology injection: Optionally inject Juju topology labels into Prometheus queries
  • Multi-service support: Provide SLO specs for multiple services in a single YAML document

Getting started

To install, add charmlibs-interfaces-sloth to your Python dependencies. Then in your Python code, import as:

from charmlibs.interfaces.sloth import SlothProvider, SlothRequirer

Provider Side

from charmlibs.interfaces.sloth import SlothProvider

class MyCharm(ops.CharmBase):
    def __init__(self, *args):
        super().__init__(*args)
        self.sloth_provider = SlothProvider(self)

    def _provide_slos(self):
        slo_config = '''
        version: prometheus/v1
        service: my-service
        slos:
          - name: requests-availability
            objective: 99.9
            sli:
              events:
                error_query: 'sum(rate(http_requests_total{status=~"5.."}[{{.window}}]))'
                total_query: 'sum(rate(http_requests_total[{{.window}}]))'
        '''
        self.sloth_provider.provide_slos(slo_config)

Requirer Side

from charmlibs.interfaces.sloth import SlothRequirer

class SlothCharm(ops.CharmBase):
    def __init__(self, *args):
        super().__init__(*args)
        self.sloth_requirer = SlothRequirer(self)

    def _on_config_changed(self, event):
        # Get validated SLO specs from all related charms
        slos = self.sloth_requirer.get_slos()
        # Process SLOs and generate rules

Documentation

For complete documentation, see the charmlibs documentation.

Contributing

See CONTRIBUTING.md in the repository root.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

charmlibs_interfaces_sloth-0.1.0.tar.gz (45.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

charmlibs_interfaces_sloth-0.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file charmlibs_interfaces_sloth-0.1.0.tar.gz.

File metadata

File hashes

Hashes for charmlibs_interfaces_sloth-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e05f68d7d096df49a24a6f0eebbbb265da12ea2d6801f5027f57c0d679fbd0f6
MD5 6fe3f3e1ab5c3e6382d15bdad7eade10
BLAKE2b-256 ced72393442e9715d55b30b946f9a36f00aacdfae4f101cc793f25993f241dfb

See more details on using hashes here.

Provenance

The following attestation bundles were made for charmlibs_interfaces_sloth-0.1.0.tar.gz:

Publisher: publish.yaml on canonical/charmlibs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file charmlibs_interfaces_sloth-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for charmlibs_interfaces_sloth-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f41fbe4f38d8bb8668375e91015c9fdb7bcf63f8f2005fcd4d3f607d6fb5aa09
MD5 53b2ce87eafd2f7e6e8f481aac6f5101
BLAKE2b-256 a46f1e895e6f0640742e0ff5b0d23b06f00a6f88aedd843272fb3afeca530167

See more details on using hashes here.

Provenance

The following attestation bundles were made for charmlibs_interfaces_sloth-0.1.0-py3-none-any.whl:

Publisher: publish.yaml on canonical/charmlibs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page