Tuesday, 30 May 2023

How to send logs from a python application to Datadog using ddtrace?

Let's say that I have a python routine that runs periodically using cron. Now, let's say that I want to send logs from it to Datadog. I thought that the simples way to do it would be via Datadog's agent, e.g. using ddtrace...

import ddtrace

ddtrace.patch_all()

import logging

logger = logging.getLogger(__name__)
logger.warning("Dummy log")

...but this is not working. I've tried with both DD_LOGS_INJECTION=true and DD_LOGS_ENABLED=true but looking at the docs it seems that I have to configure something so the Agent will tail the log files. However, by looking at type: file I'd guess that I could send logs without having to worry with creating those configuration files.

What would you say is the simplest way to send logs do Datadog and how to do that from a python application?



from How to send logs from a python application to Datadog using ddtrace?

No comments:

Post a Comment