DEV Community

Alexander Isora šŸ¦„
Alexander Isora šŸ¦„

Posted on • Edited on

Guide: Installing New Relic Agent on Nginx

I was so excited when setting up New Relic. The tool seemed so fresh and slick!

Everything was going smoothly until I started to setup nginx agent. The process has been finished, but there was an error.

āŠ˜  NGINX Open Source Integration  (unsupported)
  Installation incomplete. Follow the instructions at the URL below to complete the installation process.
Enter fullscreen mode Exit fullscreen mode

This happened on every machine šŸ˜•
Re-installing did no help šŸ˜•
The docs they offered were too messy and also did not help šŸ˜•
I started to search their forum. It turns out to be a popular problem. The only solution they offered is to contact support. But I need to pay before getting access to support. Such a shame! šŸ˜¤

So I spend a few hours with ChatGPT and a barrel of coffee and figured it out. Here is a step-by-step guide on how to install a New Relic agent on your nginx.

The guide

1) Proceed with the agent install process as they say in the docs.

Use the generated cURL link to install the New Relic agent. Then install the nginx agent: sudo apt install nri-nginx.

2) Throw in those to create a config file.

cd /etc/newrelic-infra/integrations.d
sudo cp nginx-config.yml.sample nginx-config.yml
sudo cp /etc/newrelic-infra/logging.d/nginx-log.yml.example /etc/newrelic-infra/logging.d/nginx-log.yml
Enter fullscreen mode Exit fullscreen mode

3) Check if your nginx has the required monitoring module called http_stub_status_module.

nginx -V 2>&1 | grep -o with-http_stub_status_module
Enter fullscreen mode Exit fullscreen mode

If your nginx does not have it, get it. Mine had.

4) Change the status URL:

cd /etc/newrelic-infra/integrations.d
sudo nano nginx-config.yml
Enter fullscreen mode Exit fullscreen mode

Set STATUS_URL to something like this:

STATUS_URL: https://my-domain.com/status where my-domain.com is a domain from your nginx config.

5) Restart it.

sudo systemctl restart newrelic-infra
Enter fullscreen mode Exit fullscreen mode

6) Add the status page and the IP of your server:

cd /etc/nginx/sites-enabled && nano default
Enter fullscreen mode Exit fullscreen mode
server {
    # other stuff
    server_name my-domain.com;    

    location /status {
        stub_status on; 
        access_log off;
        allow 1.1.1.1; # set your server IP here šŸšØ
    }
    # other stuff
}
Enter fullscreen mode Exit fullscreen mode

7) Reload nginx:

sudo service nginx reload
Enter fullscreen mode Exit fullscreen mode

Go to New Relic and have fun.

Top comments (2)

Collapse
 
alvaradodaniel3 profile image
alvaradodaniel3

Hi, @alexanderisora!

Thank you so much for the shout-out! We always love to hear about our users' experiences using New Relic, especially with GPT being a new integration of ours.

As a thank you, Iā€™d love to send you some swag! Please email me directly at dalvarado@newrelic.com for details.

Furthermore, feel free to follow us on our New Relic Dev.to page for more updates and how-to's on all things observability and monitoring.

Happy monitoring!
Daniel

Collapse
 
alexanderisora profile image
Alexander Isora šŸ¦„

cool! will do. thanks.