Monitor Nginx with New Relic Plugin: Nginx
To setup Nginx New Relic Plugin, there are some prerequisites stated below:
- Ruby (>= 1.8.7)
- Bundler for Ruby
- At least one running Nginx or Nginx Plus instance with ngx_http_stub_status, a module: http://wiki.nginx.org/HttpStubStatusModule (enabled by default on Nginx package install)
- a New Relic account
Lets start to setup all above mentioned requirements:
1. Install Ruby
sudo apt-get install ruby-full
2. Install Bundler
gem install bundler
3. Setup a instance that runs Nginx or Nginx Plus on it. To install Nginx you can follow link. And to configure Nginx with your application, you can follow link.
4. Setup New relic account here.
Now we are ready with all the prerequisites requied to set New Relic Nginx plugin.
Lets begin setup for plugin:
1. Install nginx-nr-agent
To install this agent, edit source list first.
sudo vi /etc/apt/sources.list
Add the following line in it
deb http://nginx.org/packages/ubuntu/ trusty nginx
deb-src http://nginx.org/packages/ubuntu/ trusty nginx
save and exit. Now run
sudo apt-get update
Install the nginx-nr-agent
sudo apt-get install nginx-nr-agent
2. Now add your licence key in the following file
sudo vi /etc/nginx-nr-agent/nginx-nr-agent.ini
[global]
newrelic_license_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
add the source in the same file at the end
[source1]
name=myserver
url=http://127.0.0.1/status
3. Add Status page setting in nginx conf file.
Remember, here myserver.conf will be the conf file that you made while configuring nginx with your application. Replace myserver.conf with your server conf file name.
First open the server configuration file:
sudo vi /etc/nginx/myserver.conf
Add following lines:
location /status {
# Turn on nginx stats
stub_status on;
# I do not need logs for stats
access_log off;
# Security: Only allow access from localhost IP #
allow 127.0.0.1;
# Send rest of the world to /dev/null #
deny all;
}
Save and Exit.
4. Now reload the setting of nginx
sudo service nginx reload
5. check if the nginx is returning the status or not from the localhost
curl localhost/status
output should be as below:
Active connections: 1
server accepts handled requests
12967 12967 19118
Reading: 0 Writing: 1 Waiting: 0
6. Now since the nginx is returning the status, we can start the plugin
sudo service nginx-nr-agent start
Nginx Plugin setup is done. You can see stats of Nginx on Plugin Tab of New Relic now.
0 comments:
Post a Comment