Skip to content

Latest commit

 

History

History
57 lines (44 loc) · 3.08 KB

README.md

File metadata and controls

57 lines (44 loc) · 3.08 KB

Advanced Example

This example demonstrates using the optional features and customizations Pyctuator is offering.

Running the example

Before running this example, you'll need SBA (Spring Boot Admin), MySQL and Redis running on the same machine the example application will be running.

It is recommended to start these services using the docker-compose.yml part of this example, from the examples/Advanced directory perform:

docker-compose --project-name example --file docker-compose.yml up --detach --force-recreate

Next, from the examples/Advanced directory, run the example application using poetry as follows:

poetry install
poetry run python advanced_example_app.py

Using the example

The example application, available from http://localhost:8000 exposes example APIs for accessing the DB and Redis:

Connect to Spring Boot Admin using http://localhost:8082.

Insights Details

Insights Details

  1. Monitor disk space (requires psutil):
  2. Monitor connection to the DB (requies sqlalchemy and drivers specific to the DB being used)
  3. Monitor Redis client (requires redis)
  4. Show build details
  5. Show Git details

Insights Metrics

If psutil is installed, Pyctuator provides various process metrics in the "Metrics" tab: Insights Metrics

Insights Environment

Pyctuator automatically exposes all environment variables, after scrubbing secrets, via the "Environment" tab under "systemEnvironment": Insights Environment System Variables

Additionally, Pyctuator can be configured to expose application-specific configuration via SBA (after scrubbing commonly identified secrets): Insights Environment App Config Note that SBA only support flattened configuration hierarchy, which is automatically handled by Pyctuator.

Further customization

Using Pyctuator, it is possible to have SBA monitor application-specific health aspects using custom health-providers.

Health status may include multiple checks and may also include details on failures or the apps health.

To demonstrate this, the example application exposes additional API for setting the health, http://localhost:8000/health - posting a JSON formatted pyctuator.health_provider.HealthDetails to set the current health status. Insights Details custom_health_up

For example, the call bellow will make the application report its down.

curl -X POST localhost:8000/health -d '{"status": "DOWN", "details": {"backend_connectivity": "Down", "available_resources": 41}}'

Insights Details custom_health_down