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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file charmlibs_interfaces_sloth-0.1.0.tar.gz.
File metadata
- Download URL: charmlibs_interfaces_sloth-0.1.0.tar.gz
- Upload date:
- Size: 45.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e05f68d7d096df49a24a6f0eebbbb265da12ea2d6801f5027f57c0d679fbd0f6
|
|
| MD5 |
6fe3f3e1ab5c3e6382d15bdad7eade10
|
|
| BLAKE2b-256 |
ced72393442e9715d55b30b946f9a36f00aacdfae4f101cc793f25993f241dfb
|
Provenance
The following attestation bundles were made for charmlibs_interfaces_sloth-0.1.0.tar.gz:
Publisher:
publish.yaml on canonical/charmlibs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
charmlibs_interfaces_sloth-0.1.0.tar.gz -
Subject digest:
e05f68d7d096df49a24a6f0eebbbb265da12ea2d6801f5027f57c0d679fbd0f6 - Sigstore transparency entry: 947205651
- Sigstore integration time:
-
Permalink:
canonical/charmlibs@518282c1dea906edecf8084fb7e7185f84b2a708 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/canonical
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@518282c1dea906edecf8084fb7e7185f84b2a708 -
Trigger Event:
push
-
Statement type:
File details
Details for the file charmlibs_interfaces_sloth-0.1.0-py3-none-any.whl.
File metadata
- Download URL: charmlibs_interfaces_sloth-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f41fbe4f38d8bb8668375e91015c9fdb7bcf63f8f2005fcd4d3f607d6fb5aa09
|
|
| MD5 |
53b2ce87eafd2f7e6e8f481aac6f5101
|
|
| BLAKE2b-256 |
a46f1e895e6f0640742e0ff5b0d23b06f00a6f88aedd843272fb3afeca530167
|
Provenance
The following attestation bundles were made for charmlibs_interfaces_sloth-0.1.0-py3-none-any.whl:
Publisher:
publish.yaml on canonical/charmlibs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
charmlibs_interfaces_sloth-0.1.0-py3-none-any.whl -
Subject digest:
f41fbe4f38d8bb8668375e91015c9fdb7bcf63f8f2005fcd4d3f607d6fb5aa09 - Sigstore transparency entry: 947205652
- Sigstore integration time:
-
Permalink:
canonical/charmlibs@518282c1dea906edecf8084fb7e7185f84b2a708 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/canonical
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@518282c1dea906edecf8084fb7e7185f84b2a708 -
Trigger Event:
push
-
Statement type: