Collecting Application Logs Using OTEL Python SDK

You can directly send logs of your application to SigNoz using the Python SDKs provided by opentlemetry. Please find an example here.

📝 Note

The default logging level in Python is WARNING.

To send all the logs to SigNoz please change the default log level to DEBUG.

import logging
logging.basicConfig(level=logging.DEBUG)

For SigNoz Cloud

For sending logs to SigNoz cloud, while running the above example set the below environment variables

  • The value of OTEL_EXPORTER_OTLP_ENDPOINT environment variable will be https://ingest.{region}.signoz.cloud:443 where depending on the choice of your region for SigNoz cloud, the otlp endpoint will vary according to this table.

    RegionEndpoint
    USingest.us.signoz.cloud:443
    INingest.in.signoz.cloud:443
    EUingest.eu.signoz.cloud:443
  • The value of OTEL_EXPORTER_OTLP_HEADERS environment variable will be signoz-access-token=<SIGNOZ_INGESTION_KEY> where <SIGNOZ_INGESTION_KEY> is your ingestion key

  • Your run command will look like

    OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.{region}.signoz.cloud:443" OTEL_EXPORTER_OTLP_HEADERS=signoz-access-token=<SIGNOZ_INGESTION_KEY> python3 example.py`
    

Was this page helpful?

On this page