Registry / observability / cosl
library1.9.1pypypiunverified

COS Lite (Charmed Observability Stack Lite) library provides helper methods and utilities for Juju charm developers to integrate with the COS Lite ecosystem. It offers tools for defining metrics, alerts, dashboards, and managing COS integrations within a charm. The current version is 1.9.1, and it maintains a frequent release cadence with minor updates and bug fixes, typically releasing every few weeks or months.

pip install cosl
INSTALL
IMPORT
SIG · COSL
C
cosl
observabilitypythonv1.9.1
Install
3.8s avg
Import
Disk
32MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.9.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.915 runs
installs and imports cleanly · install 0.0s · import 0.000s · 33.4MB
glibc
py 3.103.915 runs
installs and imports cleanly · install 3.8s · import 0.000s · 34MB
32MB installed
● package 32MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

COSIntegration
from cosl import COSIntegration
from cosl import COSIntegration

This quickstart demonstrates how to define observability rules using the `Rules` class and illustrates the typical integration pattern of `COSIntegration` within a Juju charm. Note that `COSIntegration` requires an instance of `ops.charm.CharmBase` and a running Juju environment or a test harness to be fully functional.

from ops.charm import CharmBase # Required for actual COSIntegration usage from cosl.integrator import COSIntegration from cosl.rules import Rules # The 'cosl' library is primarily designed to be used within Juju charms. # 1. Basic usage: Defining observability rules # The Rules object encapsulates Prometheus/Grafana rules. try: # Rules are defined as a dictionary, typically loaded from YAML. example_rules_content = { "groups": [ { "name": "example_group", "rules": [ {"alert": "MyHighCPU", "expr": "node_cpu_usage_total > 0.9", "for": "5m"}, {"record": "job:cpu_usage_rate:avg1m", "expr": "rate(node_cpu_seconds_total[1m])"} ] } ] } my_rules = Rules(content=example_rules_content) print(f"Successfully created a Rules object:") print(my_rules.content) except Exception as e: print(f"Error creating Rules object: {e}") # 2. Advanced usage: Integrating with COS Lite in a Juju charm # The COSIntegration class requires a 'CharmBase' instance from the 'ops' library. # This part is illustrative and needs to be run within a Juju charm's context # (e.g., in a charm's __init__.py or a Juju 'ops' test harness). # class MyCOSCharm(CharmBase): # def __init__(self, framework): # super().__init__(framework) # self.cos = COSIntegration(self) # 'self' is the CharmBase instance # # You would then use self.cos to add rules, dashboards, etc. # # For example: self.cos.add_rules(my_rules) # self.framework.observe(self.cos.on.metrics_alert_rules_changed, self._on_rules_changed) # # def _on_rules_changed(self, event): # print(f"COS rules changed event detected for: {event.rules_path}") print("\nTo use COSIntegration, you need a Juju charm context (from 'ops' library).") print("See the commented-out code above for an example of how it's typically used.")
Debug
Known issues
breakingThe signature of `DashboardPath40UID.generate` changed in version 1.3.2. Code directly calling this method with the old signature will break.
fix
Consult the `cosl` source code or documentation for the updated method signature and adjust calls accordingly.
affects: <=1.3.1
breakingThe internal `_resolve_against_charm_dir` method was removed from `COSChecker` in version 1.6.0. Although prefixed with `_`, it was sometimes used by charm developers.
fix
Avoid direct calls to `_resolve_against_charm_dir` on `COSChecker` instances. Use officially exposed methods for path resolution or manage paths explicitly.
affects: <1.6.0
gotchaThe `cosl` library, particularly its `COSIntegration` class, is tightly coupled with the Juju Operator Framework ('ops' library) and is designed for use within Juju charms. Attempting to use `COSIntegration` outside of a `CharmBase` context will result in errors.
fix
Ensure `cosl` is used within a Juju charm's `CharmBase` subclass or a mocked `ops` test harness environment. Install `ops` via `pip install ops`.
affects: All versions
Upgrade
Version history
1.9.1latest on PyPI · released Mar 31, 2026
Audit
Dependencies
opsrequiredRequired for typical usage within Juju charms, as 'cosl' classes like `COSIntegration` depend on 'ops.charm.CharmBase'.
Agent activity
34 hits · last 30 days
node
28
OpenAI (training)
1
Resources