SDKs
Python SDK
Install the Logdash Python SDK, send your first log and your first metric.
Install the package, add your ingest key and the first log lands in the dashboard within a second. Everything below is copied from the Python SDK README.
Install
pip install logdash Initialise
Copy the ingest key from your domain's settings in Logdash and keep it in an environment variable. The key identifies the domain the data lands in, and app names the program that sends, such as api or worker. See Apps.
import os
from logdash import create_logdash
logdash = create_logdash({
"api_key": os.environ["LOGDASH_API_KEY"],
"app": "api",
}) Send a log
import os
from logdash import create_logdash
logdash = create_logdash({"api_key": os.environ["LOGDASH_API_KEY"]})
logger = logdash.logger
logger.info("Application started successfully")
logger.error("An unexpected error occurred")
logger.warn("Low disk space warning") Send a metric
Metrics are named numbers. Set one to an absolute value or mutate it by a delta, and Logdash charts the history.
import os
from logdash import create_logdash
logdash = create_logdash({"api_key": os.environ["LOGDASH_API_KEY"]})
metrics = logdash.metrics
# to set absolute value
metrics.set("users", 0)
# to modify existing metric
metrics.mutate("users", 1) Send an event
Events go to web analytics of the domain, next to the custom events of your website, with the same rules for names and properties.
import os
from logdash import create_logdash
logdash = create_logdash({"api_key": os.environ["LOGDASH_API_KEY"]})
logdash.track(
"agent_run",
props={"model": "opus", "tools": 3},
# the signed-in user's internal ID, never an email address
user_id="42",
) Flush before exit
The SDK sends in the background. In a short-lived process, such as a cron job, a CLI or a serverless function, send what is still queued before the process exits.
logdash.flush() Works with
- FastAPI
- Django
- Flask
- Celery
FAQ
Is the API key required?
metrics.set and metrics.mutate need a key to show up anywhere.Where do the logger and metrics objects come from?
create_logdash returns a client. Read logdash.logger for logging and logdash.metrics for counters and gauges.Is there a Django or Flask integration?
create_logdash is the whole surface, so build one client at startup and import it where you need it.Copied from the python-sdk README at 8dac044 on 2026-11-09.