YavarTechWorks
Published in

YavarTechWorks

Netdata configuration with Nginx

In this article, I will explain Netdata and Netdata configuration with Nginx.

What is Netdata?

Netdata is real-time health monitoring and performance troubleshooting for systems and applications.

Why do we Netdata?

Netdata used to monitor systems all processes. It helps you instantly diagnose slowdowns and anomalies in your infrastructure with thousands of metrics, interactive visualizations, and insightful health alarms. Plus, long-term storage comes ready out-of-the-box, so can collect, monitor, and maintain your metrics in one insightful place.

Installation

We can install Netdata in various ways. But here, I install using docker.

$ docker run -d --name=netdata \
-p 19999:19999 \
-v /etc/passwd:/host/etc/passwd:ro \
-v /etc/group:/host/etc/group:ro \
-v /proc:/host/proc:ro \
-v /sys:/host/sys:ro \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
--cap-add SYS_PTRACE \
--security-opt apparmor=unconfined --network=host \
netdata/netdata

Once you installed successfully then open this URL http://localhost:19999/

Then you can see the above screen in the browser.

Nginx

Nginx is one of the most popular web servers in the world and is responsible for hosting some of the largest and highest-traffic sites on the internet. It is more resource-friendly than Apache in most cases and can be used as a web server or a reverse proxy.

Follow this link for Nginx installation.

Once your installation is completed successfully then you can this URL in your browser http://server_domain_or_IP

For getting to know your IP address run below command on your terminal.

$ ip address

The above output will open in your terminal. This is the indication of Nginx running successfully.

Netdata Configuration with Nginx

Setup stub_status in your Nginx configuration.

$ cd /etc/nginx
$ cd /sites-available
$ vim default

Add below lines in the default file.

location /stub_status {
stub_status;
}

Once you added below line restart your Nginx.

$ sudo nginx -t
$ sudo systemctl restart nginx

If the above command run successfully then we have to make changes in Netdata also.

Access Netdata

We installed Netdata in our machine using docker. So we need to access docker container.

$ docker container ls
$ docker exec -it <container name> /bin/bash

Below I have given an example of access Netdata bash terminal using container name.

$ docker exec -it netdata /bin/bash

Using the above command we can access the bash terminal of Netdata.

$ cd /etc/netdata
$ ./edit-config go.d/nginx.conf

Needs only url to server’s stub_status. Here is an example for local servers:

jobs:                                                                           
- name: local
url: http://localhost/stub_status

- name: local
url: http://127.0.0.1/stub_status

If these changes want to reflect in our machine we need to run docker again.

$ docker stop <Container id>
$ docker start <Container id>

Below I have given an example of running the docker again.

$ docker stop b3c310ebe66e
$ docker start b3c310ebe66e

Then reload the Netdata page. You can see the below output.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Edison Devadoss

Software developer / JavaScript / React / React Native / Firebase / Node.js / C Programming / Book Reader / Story Teller