Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusion about setting the path for python integration #330

Open
ashleyxue529 opened this issue Apr 10, 2023 · 2 comments
Open

Confusion about setting the path for python integration #330

ashleyxue529 opened this issue Apr 10, 2023 · 2 comments
Labels

Comments

@ashleyxue529
Copy link

Apologies in advance as this might be a dumb question, but what is the correct way to set up the logging file/path for a Python integration with this buildpack? I've been following this guide

For context, I do have a working setup like this:

  1. /datadog/conf.d/python.d/conf.yaml at the root of my app that gets correctly copied over to /app/.apt/etc/datadog-agent on Heroku deploy
  2. conf.yaml looks like this
init_config:

instances:

##Log section
logs:
  - type: file
    path: "/app/log/python/general.log"
    service: "backend"
    source: python
    sourcecategory: sourcecode
  1. [This is the step in question] I manually had to create and push up a /log/python/general.log file to my codebase and manually set an env var after deploying to use this path in my Django logging config (using the django-datadog-logger linked in the Datadog docs here
API_LOG_ROOT = os.environ.get("API_LOG_ROOT", None)
if API_LOG_ROOT is not None:
    LOGGING = {
        "version": 1,
        "disable_existing_loggers": False,
        "formatters": {
            "console": {"format": "[{levelname}][{module}] {message}", "style": "{"},
            "json": {
                "()": "django_datadog_logger.formatters.datadog.DataDogJSONFormatter"
            },
        },
        "handlers": {
            "console": {
                "level": "INFO",
                "class": "logging.StreamHandler",
                "formatter": "console",
            },
            "warning": {
                "level": "WARNING",
                "class": "logging.FileHandler",
                "filename": API_LOG_ROOT,
                "formatter": "json",
            },
        },
        "loggers": {
            "": {
                "handlers": ["console", "warning"],
                "level": "INFO",
                "propagate": True,
            },
        },
    }

Is there a better way to do this? I don't really want this /app/log/python/general.log dir+file kept in my repo (I had to comment out *.log from my .gitignore which I also don't want) and I feel like I shouldn't have to be manually maintaining a API_LOG_ROOT env var on top of it all

Thanks!

@arapulido
Copy link
Collaborator

Hello @ashleyxue529 This is outside the scope of the buildpack, it is a question more for the logs team. How are you sending the logs to Datadog? through the heroku log drain? or the Datadog agent?

@ashleyxue529
Copy link
Author

Ah sorry, is there a better place to post this question? Through the agent. I write logs to a .log file similar to how the agent writes logs to datadog.log/datadog-apm.log which then get routed to Datadog I believe.

Pretty much just following https://docs.datadoghq.com/logs/log_collection/python/ and following the buildpack docs here https://docs.datadoghq.com/agent/basic_agent_usage/heroku/#enabling-other-integrations, which is why I posted the question here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants