Search code examples
pythonnewrelic

How do I enable the NewRelic Python agent?


While trying to test my NewRelic configuration using newrelic-admin validate-config newrelic.ini as recommended by https://docs.newrelic.com/docs/python/testing-the-python-agent, I received the following error:

WARNING - The Python Agent is not enabled.

ERROR - Unable to register application for test, connection could not be established within 30.0 seconds.

What does the warning mean, and how do I enable the agent? Why does the agent need to be enabled to validate the config?


Solution

  • It turns out that one of the developer_mode or monitor_mode configuration options must be set to true in your configuration file to "enable" the agent.

    However, as it looks like the config validator actually spins up the agent using your configuration under a test app called "Python Agent Test" and tries to report to NewRelic, setting developer_mode to true enables the agent but still causes the tests to fail. Actually, it looks like the tests failing is a bug, as the error message is ERROR - Unexpected exception when attempting to harvest the metric data and send it to the data collector. Please report this problem to New Relic support for further investigation., and the traceback shows a failed assertion in newrelic.core.data_collector.send_request.

    Setting monitor_mode = true in the configuration file should successfully enable the agent and cause the tests to pass, with data for the PythonAgentTest application appearing in the NewRelic dashboard.