Quick start
Goal: see logs, traces and errors from your code in a Kibana dashboard in about 5 minutes.
1. Prerequisites
- Python 3.10+
- Docker running (
docker infowithout errors) with Compose v2 (docker compose version) - Free ports on
127.0.0.1: 9200 (Elasticsearch), 5601 (Kibana), 4317 and 4318 (OTLP). If one of them is taken, pick another ininit(step 3).
On macOS with Colima: colima start --cpu 4 --memory 6 --disk 30.
The project must be inside your $HOME (Colima only shares that folder with Docker).
2. Install
cd my-project
uv init && uv add "obskitpy[requests]" # with uv (recommended)
# or: pip install "obskitpy[requests]"
# development version: uv add "obskitpy[requests] @ git+https://github.com/pedrowill-dev/obskitpy.git#subdirectory=obskitpy"
3. Run the wizard
With uv, prefix the commands with
uv run(e.g.uv run obskitpy init); with pip, activate the venv first.
obskitpy init
The wizard talks to you, checks the environment and does the rest:
- Service name (default: the folder name).
- Is a stack already running? It looks for obskitpy stacks that are up on the machine and asks whether you want to add this automation to it (same containers and same dashboard; in the dash you pick the project in the selector at the top) or create a separate stack. If you add it, the interface, the ports and the stack startup come from the existing stack.
- Where do you want to view the logs? - Kibana: full-featured, to explore in depth and build your own panels. - dash-obskitpy: a built-in dashboard, light and to the point, without Kibana (starts faster). - Both: dash-obskitpy day to day and Kibana to investigate.
- Ports: if one is taken, it picks the next free one and tells you.
- Start the stack now? It shows progress and waits until everything is healthy.
- Run an example app? It generates
obskitpy_demo.pyand runs it, so the dashboard starts with data. - Open in the browser?
Prefer no questions (scripts, CI)? Choose everything with flags:
obskitpy init --service my-service --local dash-obskitpy --yes --up --demo
Something failed? The CLI tries to fix it by itself (busy ports, missing Compose, stopped Colima) and obskitpy doctor
shows what is missing (Docker, Compose, memory, ports).
More details in CLI and library and dash-obskitpy.
4. Instrument your code
import logging, time
import obskitpy
log = logging.getLogger("orders")
shutdown = obskitpy.setup("my-service") # use the same name as in `init`
@obskitpy.traced()
def validate(n):
if n % 3 == 0:
raise ValueError(f"order {n} is invalid")
@obskitpy.traced("process-batch")
def batch():
for n in range(1, 10):
try:
validate(n)
log.info("order ok", extra={"order": n})
except ValueError:
log.exception("order failed")
time.sleep(0.1)
batch()
shutdown() # always call it before exiting: flushes pending logs/traces/metrics
The name passed to
obskitpy.setup(...)must be the same asOBSKITPY_SERVICEinobservability/.env, because the panels filter by it.
5. See the result
The simplest way to run your program already pointed at the stack (and start the stack if it is stopped):
obskitpy run python app.py
Run the script and open the dashboard with obskitpy open (or the link printed by up):
| You chose | Address |
|---|---|
| dash-obskitpy | http://localhost:8600 |
| Kibana | http://localhost:5601/app/dashboards#/view/<service>-observability |
The first data takes a few seconds to become searchable in Elasticsearch. If the panels are empty, wait ~30 s and refresh. Also check the time window (top right corner): the default is Last 24 hours.
6. Next steps
- Add your own panels and version them: Dashboards
- Business metrics, span attributes, producing errors: obskitpy guide
- A complete real project: news example
- Something went wrong? Troubleshooting
Shut down
obskitpy down # stops the containers and keeps the data
obskitpy down -v # stops them and deletes the data
✎ Edit this page on GitHub