Skip to content

Latest commit

 

History

History
202 lines (155 loc) · 9.01 KB

testing-python-agent.mdx

File metadata and controls

202 lines (155 loc) · 9.01 KB
title type tags metaDescription redirects freshnessValidatedDate
Testing the Python agent
troubleshooting
Agents
Python agent
Troubleshooting
How to test your Python agent by running the newrelic-admin validate-config (config file location) command.
/docs/agents/python-agent/troubleshooting/testing-python-agent
/docs/agents/python-agent/installation-configuration/testing-python-agent
/docs/python/testing-the-python-agent
/docs/agents/python-agent/installation-and-configuration/testing-python-agent
never

Problem

If you experience issues when installing or running the Python agent on a new host, test that the package is installed correctly and that it can contact our data collector service. If the data collector service is unreachable, it may be due to a blocked firewall. Perform these network connectivity tests to narrow down the cause of the problem.

Solution

Test connection [#connectivity-test]

The Python agent includes a built-in test app that can verify your connection to our collector. To verify with the test app, run this command with the path to your New Relic config file:

newrelic-admin validate-config LOCATION_OF_NEWRELIC.INI

This runs a test using the Python agent. The agent will report the sample data to the account that corresponds to the agent config file, and a test app named Python Agent Test for the reported sample data will appear in the APM UI.

After the test is completed, the UI will show the app as inactive. Follow standard procedures to delete the test app from the APM index.

Check log for errors [#check-for-errors]

If no data is transferred to the UI after five minutes, check the messages output from the test as well as the log file produced. If you encounter any problem that suggests an issue with being able to reach our data collector service, then try these troubleshooting procedures:

Here are examples of error messages you may find.

**ERROR - No license key was set in agent configuration.**
Ensure that the <InlinePopover type="licenseKey" /> has been specified in the agent configuration file or via the `NEW_RELIC_LICENSE_KEY` environment variable. Correct the problem with the license key, or get support at [support.newrelic.com](https://support.newrelic.com).

<Collapser id="invalid-license-key" title="An invalid license key was added to the agent configuration file."

<DoNotTranslate>**ERROR - Data collector indicates that an incorrect license key has been supplied by the agent.**</DoNotTranslate>

The value used by the agent is `...`. Correct the problem with the <InlinePopover type="licenseKey" />, or get support at [support.newrelic.com](https://support.newrelic.com).

<Collapser id="collector-not-contacted" title="The data collector service cannot be contacted."

<DoNotTranslate>**ERROR - Unable to register application for test, connection could not be established within 30.0 seconds.**</DoNotTranslate>

This is a fallback message when a connection cannot be established. It indicates that the data collector service cannot be reached or there is an issue in resolving the hostname for the data collector host.

<Collapser id="collector-unavailable" title="The data collector service is currently unavailable."

* <DoNotTranslate>**WARNING - Data collector is not contactable.**</DoNotTranslate>

  This is either due to a network issue or the data collector being restarted. If contact cannot be made after a period of time, get support at [support.newrelic.com](https://support.newrelic.com).
* <DoNotTranslate>**ERROR - ConnectionError(MaxRetryError('Max retries exceeded for url: ...,),)**</DoNotTranslate>

  This generally occurs when our data collector service is temporarily unavailable. Retry the test.

Verify network configuration [#network-configuration]

To verify the network connection, run the following:

newrelic-admin network-config newrelic.ini

Look for results similar to this:

host = 'collector.newrelic.com'
port = 0
proxy_host = None
proxy_port = None
proxy_user = None
proxy_pass = None
ssl = True
  • Port: A value of 0 for the port setting indicates that the appropriate port, such as 80 or 443, will be used depending on whether or not SSL is enabled.
  • Proxy: If you have configured the agent to use a proxy, make sure the proxy settings reflect this. If no proxy settings are specified but any HTTP connections to the wider Internet are necessary, then make sure the appropriate proxy settings appear in the agent configuration file.

Check hostname lookup [#host-name-lookup]

If the data collector appears unreachable:

  1. Check that the hostname for the primary data collector host can be resolved with UNIX system tools such as dig or nslookup.
  2. If this does not succeed, check the configuration of any domain name resolver files for your host.

Here is an example:

$ dig collector.newrelic.com

; <<>> DiG 9.8.3-P1 <<>> collector.newrelic.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62183
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 4

;; QUESTION SECTION:
;collector.newrelic.com.                IN      A

;; ANSWER SECTION:
collector.newrelic.com. 2453    IN      A       50.31.164.140

;; AUTHORITY SECTION:
newrelic.com.           1163    IN      NS      ns2.p21.dynect.net.
newrelic.com.           1163    IN      NS      ns1.p21.dynect.net.
newrelic.com.           1163    IN      NS      ns4.p21.dynect.net.
newrelic.com.           1163    IN      NS      ns3.p21.dynect.net.

;; ADDITIONAL SECTION:
ns1.p21.dynect.net.     3198    IN      A       208.78.70.21
ns2.p21.dynect.net.     8576    IN      A       204.13.250.21
ns3.p21.dynect.net.     7364    IN      A       208.78.71.21
ns4.p21.dynect.net.     8576    IN      A       204.13.251.21

;; Query time: 22 msec
;; SERVER: 192.168.178.1#53(192.168.178.1)
;; WHEN: Tue Jun 11 18:58:23 2013
;; MSG SIZE  rcvd: 206

Check network traffic routing [#route-network-traffic]

Our agents require your firewall to allow an outgoing connection to our [network](/docs/apm/new-relic-apm/getting-started/networks):
  • TCP port 443 if using HTTPS over a SSL connection
  • TCP port 80 if using a plain HTTP connection

If the hostname for the data collector host can be resolved, use UNIX system tools such as ping and traceroute to determine if network traffic can be routed to it. The network traffic path will vary. As long as the path reaches the final intended host, the length of the path and its hosts are not important.

If you cannot contact the data collector host, configure the agent to use any firewall HTTP proxy, or open the required outgoing ports in the firewall to allow connections to the data collector.

``` $ ping collector.newrelic.com PING collector.newrelic.com (50.31.164.140): 56 data bytes 64 bytes from 50.31.164.140: icmp_seq=0 ttl=239 time=234.204 ms 64 bytes from 50.31.164.140: icmp_seq=1 ttl=239 time=230.095 ms ... ```

<Collapser id="traceroute" title="Traceroute"

When using <DoNotTranslate>**traceroute**</DoNotTranslate>, tell it to use ports <DoNotTranslate>**80**</DoNotTranslate> and <DoNotTranslate>**443**</DoNotTranslate>.

```
$ traceroute -p 80 collector.newrelic.com
traceroute to collector.newrelic.com (50.31.164.140), 64 hops max, 52 byte packets
 1  ...
 2  ...
 3  ...
 4  * * *
 5  collector.newrelic.com (50.31.164.140)  232.590 ms  231.000 ms  232.041 ms

$ traceroute -p 443 collector.newrelic.com
traceroute to collector.newrelic.com (50.31.164.140), 64 hops max, 52 byte packets
 1  ...
 2  ...
 3  ...
 4  * * *
 5  collector.newrelic.com (50.31.164.140)  253.513 ms  231.134 ms  232.511 ms
```