SigNoz Cloud - This page is relevant for SigNoz Cloud editions.
Self-Host - This page is relevant for self-hosted SigNoz editions.

Send logs from Python to SigNoz using OpenTelemetry

Prerequisites

Send logs to SigNoz

Auto-instrumentation automatically captures logs from your Python application with trace correlation.

Step 1: Install dependencies

Install the OpenTelemetry distro and OTLP exporter:

pip install opentelemetry-distro opentelemetry-exporter-otlp

Install the instrumentation packages:

opentelemetry-bootstrap -a install

Step 2: Set environment variables

export OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true
export OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.<region>.signoz.cloud:443"
export OTEL_EXPORTER_OTLP_HEADERS="signoz-ingestion-key=<your-ingestion-key>"
export OTEL_SERVICE_NAME="python-app"

Replace the following:

If using a local OTel Collector, use:

export OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true
export OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4317"
export OTEL_SERVICE_NAME="python-app"

Step 3: Run your application

Run your application with the opentelemetry-instrument wrapper:

opentelemetry-instrument python main.py

For web frameworks like FastAPI or Flask:

opentelemetry-instrument uvicorn main:app --host 0.0.0.0 --port 8000

Log Correlation

OpenTelemetry auto-instrumentation automatically injects trace_id and span_id into your logs when a tracing context is active, allowing you to correlate logs with traces in SigNoz.

Info

By default, auto-instrumentation collects traces, metrics, and logs. To collect only logs, disable traces and metrics:

export OTEL_TRACES_EXPORTER="none"
export OTEL_METRICS_EXPORTER="none"

Validate Logs

Captured logs can be viewed in the Logs Explorer section.

Python Logs
Python Application Logs
Python Logs Detailed View
Python Application Logs Detailed View

Setup OpenTelemetry Collector (Optional)

What is the OpenTelemetry Collector?

Think of the OTel Collector as a middleman between your app and SigNoz. Instead of your application sending data directly to SigNoz, it sends everything to the Collector first, which then forwards it along.

Why use it?

  • Cleaning up data — Filter out noisy traces you don't care about, or remove sensitive info before it leaves your servers.
  • Keeping your app lightweight — Let the Collector handle batching, retries, and compression instead of your application code.
  • Adding context automatically — The Collector can tag your data with useful info like which Kubernetes pod or cloud region it came from.
  • Future flexibility — Want to send data to multiple backends later? The Collector makes that easy without changing your app.

See Switch from direct export to Collector for step-by-step instructions to convert your setup.

For more details, see Why use the OpenTelemetry Collector? and the Collector configuration guide.

Troubleshooting

Why do I see "404 Not Found" errors?

This usually happens if the endpoint URL is incorrect.

  • Cloud: https://ingest.<region>.signoz.cloud:443
  • Self-Hosted: http://localhost:4317

Why are my logs not appearing in SigNoz?

  • Check if the application started successfully and is actually generating logs.
  • Verify your <region> and <your-ingestion-key> are correct.
  • Ensure OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED is set to true (if using auto-instrumentation).

Next Steps

Get Help

If you need help with the steps in this topic, please reach out to us on SigNoz Community Slack.

If you are a SigNoz Cloud user, please use in product chat support located at the bottom right corner of your SigNoz instance or contact us at cloud-support@signoz.io.

Last updated: December 14, 2025

Edit on GitHub

Was this page helpful?