Skip to main content

wex_addon_services_monitoring

Version: 7.10.0

wex-addon-services-monitoring is a wex addon that registers Grafana, Kibana, Plausible, and Elastic Fleet as wex app services, making each available as a named service with lifecycle commands inside any wex-managed application. Each service exposes at minimum a ready command that health-checks its container's HTTP endpoint; Plausible additionally ships an install command that generates its required secrets (SECRET_KEY_BASE, TOTP_VAULT_KEY) and writes database names into the app config. It is aimed at developers who want to add observability or analytics tooling to a wex app without hand-writing the service definitions.

Table of Contents

Installation

pip install wexample-wex-addon-services-monitoring

Requires Python >=3.10.

Quickstart

Install the package:

pip install wexample-wex-addon-services-monitoring

The public entry point is ServicesMonitoringAddonManager, exported from src/wexample_wex_addon_services_monitoring/services_monitoring_addon_manager.py:

from wexample_wex_addon_services_monitoring import ServicesMonitoringAddonManager

Passing it to a wex kernel registers six monitoring services — grafana, kibana, matomo, plausible, fleet, and fleet_agent — each backed by a Docker Compose definition.

Plausible shows the full lifecycle. Before starting the container, run plausible service install. It generates two secrets:

  • SECRET_KEY_BASE — 64-byte URL-safe token, used by Phoenix to sign sessions.
  • TOTP_VAULT_KEY — 32-byte base64-encoded key, used to encrypt user TOTP secrets in the database.

It also derives db_name (<app>_plausible) and events_db_name (<app>_plausible_events) from the app name and writes all four values into the app config file. Running it a second time is safe — existing values are preserved. It logs:

Configured plausible service for app '<name>' (db: <name>_plausible, events_db: <name>_plausible_events)

Once the container is running, plausible service ready checks liveness by executing inside the container:

docker exec <project>_plausible wget -qO- http://127.0.0.1:8000/api/health

It returns True when the exit code is 0 — meaning Phoenix has finished migrations and is serving traffic, not just listening on the port. fleet service ready and kibana service ready follow the same shape: Fleet polls https://localhost:8220/api/status, Kibana polls http://localhost:5601/api/status.

Service declarations live in src/wexample_wex_addon_services_monitoring/services/plausible/service.yml and its siblings; each service's Docker Compose file is in the docker/ subdirectory alongside it.

Tests

This project uses pytest for testing and pytest-cov for code coverage analysis.

Installation

First, install the required testing dependencies:

.venv/bin/python -m pip install pytest pytest-cov

Basic Usage

Run all tests with coverage:

.venv/bin/python -m pytest --cov --cov-report=html

Common Commands

# Run tests with coverage for a specific module
.venv/bin/python -m pytest --cov=your_module

# Show which lines are not covered
.venv/bin/python -m pytest --cov=your_module --cov-report=term-missing

# Generate an HTML coverage report
.venv/bin/python -m pytest --cov=your_module --cov-report=html

# Combine terminal and HTML reports
.venv/bin/python -m pytest --cov=your_module --cov-report=term-missing --cov-report=html

# Run specific test file with coverage
.venv/bin/python -m pytest tests/test_file.py --cov=your_module --cov-report=term-missing

Viewing HTML Reports

After generating an HTML report, open htmlcov/index.html in your browser to view detailed line-by-line coverage information.

Coverage Threshold

To enforce a minimum coverage percentage:

.venv/bin/python -m pytest --cov=your_module --cov-fail-under=80

This will cause the test suite to fail if coverage drops below 80%.

Architecture

The addon is a registration layer. It contributes six monitoring services to any wex app that loads it; each service is self-contained in a subdirectory under services/.

Addon entry point

src/wexample_wex_addon_services_monitoring/services_monitoring_addon_manager.py contains ServicesMonitoringAddonManager, which subclasses AbstractAddonManager from wexample-wex-core:

@base_class
class ServicesMonitoringAddonManager(AbstractAddonManager):
    @classmethod
    def get_package_module(cls) -> Any:
        import wexample_wex_addon_services_monitoring
        return wexample_wex_addon_services_monitoring

get_package_module returns the package object; wex core uses it to walk the package tree and auto-discover every service and command beneath it. The class is re-exported from src/wexample_wex_addon_services_monitoring/init.py as the sole public symbol.

Services

Six services live under src/wexample_wex_addon_services_monitoring/services/, one subdirectory each:

Service Depends on Proxy
grafana — yes
kibana elasticsearch yes
matomo mysql yes
plausible postgres, clickhouse yes
fleet elasticsearch, kibana no
fleet_agent fleet no

Every service directory has the same shape:

  • service.yml — declares the service name, tags, dependencies, and the path to its Docker Compose file.
  • docker/docker-compose.yml — the Compose definition wex merges when the service is active.
  • app_service.py (where present) — a class that subclasses AppService from wexample-wex-addon-app.
  • commands/service/ — one module per lifecycle command.

service.yml

src/wexample_wex_addon_services_monitoring/services/plausible/service.yml is representative:

name: plausible
tags:
  - monitoring
  - analytics
config:
  proxy: true
dependencies:
  - postgres
  - clickhouse
docker:
  compose: docker/docker-compose.yml

dependencies tells wex which other services must be present before this one starts. proxy: true means the service is exposed through the app's reverse proxy.

app_service.py

Services with no custom behaviour — kibana, fleet, fleet_agent — inherit AppService and add nothing. Plausible overrides get_workdir_contribution to return {"children": []}, telling wex it contributes no filesystem mounts; all state lives inside postgres and clickhouse.

Commands

Commands live in commands/service/. Each is a plain function decorated with @command:

@command(
    type=COMMAND_TYPE_SERVICE,
    tags=[DomainTag.MONITORING, DomainTag.SERVICE, EffectTag.READ_ONLY, ...],
)
def plausible__service__ready(context: ExecutionContext, service: AppService) -> BooleanResponse:
    ...

type=COMMAND_TYPE_SERVICE binds the function to a service rather than to the app or the global CLI. The domain tags (domain:monitoring, domain:service) are defined in src/wexample_wex_addon_services_monitoring/const/tags.py.

ready commands

Plausible, fleet, and kibana each ship a ready command. The pattern is identical across all three:

  1. Read app.project_name from the runtime config.
  2. Build the container name as {project_name}_{service_name}.
  3. Run docker exec {container} <probe> and return BooleanResponse(returncode == 0).

The probes differ by service: Plausible executes wget -qO- http://127.0.0.1:8000/api/health (ready only after Phoenix finishes migrations), Kibana runs curl -sf http://localhost:5601/api/status, Fleet runs curl -sf https://localhost:8220/api/status -k.

plausible service install

src/wexample_wex_addon_services_monitoring/services/plausible/commands/service/install.py is the only command that writes state. It sets four keys under service.plausible.* in the app config file:

  • secret_key_base — 64-byte URL-safe token, used by Phoenix to sign sessions and cookies.
  • totp_vault_key — 32-byte base64-encoded key, used to encrypt TOTP secrets in the database.
  • db_name — defaults to {app_name}_plausible.
  • events_db_name — defaults to {app_name}_plausible_events.

It also sets service.postgres.user to plausible so that the postgres superuser matches the credentials Plausible's libpq client sends. Existing values are never overwritten, making the command safe to run more than once.

Call path

When a command such as plausible service ready is invoked:

  1. The wex kernel resolves ServicesMonitoringAddonManager and, through get_package_module, locates the plausible service directory.
  2. It instantiates the service's AppService and passes it alongside an ExecutionContext to the command function.
  3. The command calls service.app_workdir.get_runtime_config() to read app.project_name, assembles the container name, and shells out to docker exec.
  4. The BooleanResponse travels back through the kernel to the caller.

install follows the same routing up to step 2; from there it calls service.app_workdir.get_config_file(), mutates the config object, writes it back, and rebuilds the runtime config with get_runtime_config(rebuild=True).

Integration in the Suite

This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.

Related Packages

The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.

Visit the Wexample Suite documentation for the complete package ecosystem.

Dependencies

  • wexample-wex-addon-app: >=31.0.0
  • wexample-wex-core: >=30.1.0

Versioning & Compatibility Policy

Wexample packages follow Semantic Versioning (SemVer):

  • MAJOR: Breaking changes
  • MINOR: New features, backward compatible
  • PATCH: Bug fixes, backward compatible

We maintain backward compatibility within major versions and provide clear migration guides for breaking changes.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Free to use in both personal and commercial projects.

About us

Wexample stands as a cornerstone of the digital ecosystem — a collective of seasoned engineers, researchers, and creators driven by a relentless pursuit of technological excellence. More than a media platform, it has grown into a vibrant community where innovation meets craftsmanship, and where every line of code reflects a commitment to clarity, durability, and shared intelligence.

This packages suite embodies this spirit. Trusted by professionals and enthusiasts alike, it delivers a consistent, high-quality foundation for modern development — open, elegant, and battle-tested. Its reputation is built on years of collaboration, refinement, and rigorous attention to detail, making it a natural choice for those who demand both robustness and beauty in their tools.

Wexample cultivates a culture of mastery. Each package, each contribution carries the mark of a community that values precision, ethics, and innovation — a community proud to shape the future of digital craftsmanship.

Known Limitations & Roadmap

Current limitations and planned features are tracked in the GitHub issues.

See the project roadmap for upcoming features and improvements.

Status & Compatibility

Maturity: Production-ready

Python Support: >=3.10

OS Support: Linux, macOS, Windows

Status: Actively maintained

Useful Links

Migration Notes

When upgrading between major versions, refer to the migration guides in the documentation.

Breaking changes are clearly documented with upgrade paths and examples.

Metadata

Release files for wexample-wex-addon-services-monitoring 7.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wexample-wex-addon-services-monitoring 7.10.0
File Size Uploaded
wexample_wex_addon_services_monitoring-7.10.0.tar.gz 17.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wexample-wex-addon-services-monitoring 7.10.0
File Interpreter ABI Platform
wexample_wex_addon_services_monitoring-7.10.0-py3-none-any.whl Python 3 none any Details

Total release size: 46.5 kB

Release files / wexample_wex_addon_services_monitoring-7.10.0.tar.gz

Download URL wexample_wex_addon_services_monitoring-7.10.0.tar.gz
Size 17.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8bf043ddba4c9a422cf921a6d0407530c49170b32fe377f34c7ad3b1a191951b
BLAKE2b-256 checksum
How to use checksums
4d7f2ad127c6052220b8c6bdc4fd187628b1c8ae009b6bb1e8ebbe0edea82471
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.25.9 CPython/3.12.3 Linux/6.8.0-138-generic

Release files / wexample_wex_addon_services_monitoring-7.10.0-py3-none-any.whl

Download URL wexample_wex_addon_services_monitoring-7.10.0-py3-none-any.whl
Size 29.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9648f36fb75dc7fd7f6ee519f5b452313eaefe54c48c6d9b59b236fb7b34e7eb
BLAKE2b-256 checksum
How to use checksums
f5ba0ef833dfffd7e86a8e1fb9a49a498808c658a485f3c23eabaaf8490f1dd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.25.9 CPython/3.12.3 Linux/6.8.0-138-generic

Release history Release notifications | RSS feed

7.10.9

2 release files

7.10.8

2 release files

7.10.3

2 release files

7.10.2

2 release files

7.10.1

2 release files

This release

7.10.0 This release

2 release files

7.9.9

2 release files

7.9.8

2 release files

7.9.7

2 release files

7.9.6

2 release files

7.9.5

2 release files

7.9.4

2 release files

7.9.3

2 release files

7.9.2

2 release files

7.9.1

2 release files

7.9.0

2 release files

7.8.5

2 release files

7.8.4

2 release files

7.8.3

2 release files

7.8.2

2 release files

7.8.1

2 release files

7.8.0

2 release files

7.7.0

2 release files

7.6.9

2 release files

7.6.8

2 release files

7.6.7

2 release files

7.6.6

2 release files

7.6.5

2 release files

7.6.4

2 release files

7.6.3

2 release files

7.6.2

2 release files

7.6.1

2 release files

7.6.0

2 release files

7.5.4

2 release files

7.5.3

2 release files

7.5.2

2 release files

7.5.1

2 release files

7.5.0

2 release files

7.4.1

2 release files

7.4.0

2 release files

7.3.1

2 release files

7.3.0

2 release files

7.2.4

2 release files

7.2.3

2 release files

7.2.2

2 release files

7.2.1

2 release files

7.2.0

2 release files

7.1.10

2 release files

7.1.9

2 release files

7.1.8

2 release files

7.1.7

2 release files

7.1.6

2 release files

7.1.5

2 release files

7.1.4

2 release files

7.1.3

2 release files

7.1.2

2 release files

7.1.1

2 release files

7.1.0

2 release files

7.0.8

2 release files

7.0.7

2 release files

7.0.6

2 release files

7.0.5

2 release files

7.0.4

2 release files

7.0.3

2 release files

7.0.2

2 release files

7.0.1

2 release files

7.0.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.4

2 release files

0.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page