Lightweight OS-agnostic observability UI for PyNinja
Project description
PyObservability
Platform Supported
Deployments
Kick off
Recommendations
- Install
python3.11 or above - Use a dedicated virtual environment
Install PyObservability
python -m pip install pyobservability
Initiate - IDE
import pyobservability
if __name__ == '__main__':
pyobservability.start()
Initiate - CLI
pyobservability start
Use
pyobservability --helpfor usage instructions.
Containerized Deployment
docker pull thevickypedia/pyobservability:latest
docker run \
--name observability \
-p 8080:80 \
-v /home/user/config:/config \
--restart=no \
thevickypedia/pyobservability
Grafana Dashboard powered by Prometheus
PyObservability can optionally stream metrics through a /metrics endpoint in Prometheus format, which can be scraped by Prometheus and visualized in Grafana.
The dashboard is powered by Prometheus, which is used to scrape the metrics from the targets and store them in a time-series database.
Steps to set up the Grafana dashboard:
- Create a
configdirectory in the current working directory to store the configuration files for the server and Grafana containers. - Copy samples/secrets.json to the
configdirectory and update it with the appropriate values for your environment. - COPY samples/docker-compose-server.yml and samples/docker-compose-grafana.yml to current working directory.
- Run
./docker-launch.shto start the server and Grafana containers using Docker Compose.NOTE: Set env variables [OR] update the
docker-compose-*.ymlfiles with the desired port numbers andconfigdirectory location before running the script. - Access the Grafana dashboard at
http://localhost:3000and log in with the credentials specified in thesecrets.jsonfile. - Add Prometheus as a data source in Grafana using the URL
http://host.docker.internal:9090(orhttp://localhost:9090if running on Linux). - Import the sample Grafana dashboard JSON file into Grafana to visualize the metrics.
Environment Variables
Sourcing environment variables from an env file
By default,
PyObservabilitywill look for a.envfile in the current working directory. JSON file format is also supported with a custom kwarg or env varenv_filepointing to the filepath.
Mandatory
- TARGETS - Target URLs running
PyNinjain the following format.TARGETS='[{"name":"node1","base_url":"http://192.168.1.10:8000","apikey":"token1"},{"name":"node2","base_url":"http://192.168.1.11:8000"}]'
Defaults
- HOST - Host IP to run PyObservability. Defaults to
127.0.0.1or0.0.0.0 - PORT - Port number to run PyObservability. Defaults to
8080 - INTERVAL - Polling interval to retrieve server information.
Optional
- USERNAME - Username to authenticate the monitoring page.
- PASSWORD - Password to authenticate the monitoring page.
- TIMEOUT - Timeout (in seconds) for UI authentication. Defaults to 5m.
- LEGACY_UI - Enable legacy UI. Defaults to
False, displaying a Grafana like dashboard.
Logging
PyObservability uses
uvicornlogger by default. Following options can be used to override the default logger.
- LOG - Lazy config to use the default log format. Can either be
fileorstdout. - DEBUG - Enables debug level logging. Defaults to
False. - LOGS_PATH - Directory path to store log files if
LOGis set tofile. - LOG_CONFIG - Path to a custom logging configuration file.
Uptime Kuma
Uptime Kuma integration can be enabled by setting the following environment variables.
- KUMA_URL - Base URL of the Uptime Kuma server.
- KUMA_USERNAME - Username to authenticate with Uptime Kuma.
- KUMA_PASSWORD - Password to authenticate with Uptime Kuma.
- KUMA_TIMEOUT - Timeout (in seconds) for Uptime Kuma authentication. Defaults to 5s.
GitHub Runners
GitHub Runners integration can be enabled by setting the following environment variables.
- GIT_ORG - GitHub organization name or username.
- GIT_TOKEN - GitHub token with
read:orgpermissions.
Prometheus Metrics
Enabling prometheus metrics will expose a
/metricsendpoint in Prometheus format, which can be scraped by Prometheus and visualized in Grafana.
This endpoint is automatically secured with the same credentials as the monitoring page if authentication is enabled.
- PROMETHEUS_ENABLED - Enable Prometheus metrics endpoint. Defaults to
False.
[!WARNING] Enabling prometheus metrics will increase the resource usage in all the monitored nodes, as the metrics are constantly streamed as long as the server is running. It is recommended to use this option with a high polling
intervalto reduce the resource usage.
License & copyright
© Vignesh Rao
Licensed under the MIT License
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 Distributions
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 pyobservability-5.0.2-py3-none-any.whl.
File metadata
- Download URL: pyobservability-5.0.2-py3-none-any.whl
- Upload date:
- Size: 57.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9b74b63b0921adabd63266452c1201fc073b32a58dad430b178363f08787b7a
|
|
| MD5 |
4860b6a31f9b390c73e5e508da099d87
|
|
| BLAKE2b-256 |
42994e19941ac44dfe7246c15da29a77e66106ee5efddc1c909ec0d4bcaeaa6f
|