Configure Prometheus and Node Exporter to get metric for Grafana

bayu nugraha
3 min readOct 6, 2020

--

##1. Download Packet Prometheus Server

cd /opt

sudo wget https://github.com/prometheus/prometheus/releases/download/v2.20.1/prometheus-2.20.1.linux-amd64.tar.gz

sudo tar xvfz prometheus-2.20.1.linux-amd64.tar.gz

##2. Config Prometheus Server

cd prometheus-2.20.1.linux-amd64

vi config.yml

global:

scrape_interval: 15s

evaluation_interval: 15s

scrape_configs:

- job_name: ‘prometheus’

static_configs:

- targets: [‘192.168.0.8:9090’]

##3.Check config before we running the Prometheus

./promtool check config config.yml

##4. Running Prometheus Server as a Service

vi /etc/systemd/system/prometheus_server.service

[Unit]

Description=Prometheus Server

[Service]

User=root

ExecStart=/opt/prometheus-2.20.1.linux-amd64/prometheus — config.file=/opt/prometheus-2.20.1.linux-amd64/config.yml — web.external-url=http://192.168.0.8:9090/

[Install]

WantedBy=default.target

##5. Start Prometheus Server Service

sudo systemctl daemon-reload

sudo systemctl enable prometheus_server.service

sudo systemctl start prometheus_server.service

systemctl status prometheus_server.service

journalctl -u prometheus_server

##6. Check Prometheus

Open Browser and type, http://192.168.0.8:9090/metrics

##1. Download Paket Node Exporter to add VM that we want to monitor,

ssh to vm/server

cd /opt

sudo wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-1.0.1.linux-amd64.tar.gz

sudo tar xvfz node_exporter-1.0.1.linux-amd64.tar.gz

cd node_exporter-1.0.1.linux-amd64

##2. Running Node Exporter as a Service

vi /etc/systemd/system/node_exporter.service

[Unit]

Description=Node Exporter

[Service]

User=root

ExecStart=/opt/node_exporter-0.18.1.linux-amd64/node_exporter — web.listen-address=192.168.111.2:9100

[Install]

WantedBy=default.target

— web.listen-address is IP address vm/server which is can communicate with IP Prometheus 192.168.0.8 through ping command.

##3. Start Node Exporter Service

sudo systemctl daemon-reload

sudo systemctl enable node_exporter.service

sudo systemctl start node_exporter.service

sudo systemctl status node_exporter.service

sudo journalctl -u node_exporte

##1. Add IP vm/sever to Prometheus server

ssh to vm/server Prometheus

cd /opt/prometheus-2.20.1.linux-amd64

vi config.yml

global:

scrape_interval: 15s

evaluation_interval: 15s

scrape_configs:

- job_name: ‘prometheus’

static_configs:

- targets: [‘192.168.0.8:9090’]

- targets: [‘192.168.111.2:9090’]

##2. Reload and Restart Prometheus

sudo systemctl daemon-reload

sudo systemctl restart prometheus_server.service

sudo systemctl status prometheus_server.service

##3. Check Prometheus

Open browser http://192.168.0.8:9090/targets

##1. Add data Prometheus to Grafana

Go to Grafana web, go to Config > Data Source, Select Prometheus, and fill in the blank like picture below:

Save and Test.

##2. Create Dashboard, Add Query

Select Query Prometheus 2 (192.168.0.8:9090), fill in Metrics like picture above

Tab Visualization, setting value, you can refer to picture above

Tab General, change Title name, and back,

We success to monitor status Prometheus.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

bayu nugraha
bayu nugraha

Written by bayu nugraha

Linux Administrator, Network Administrator, Cloud Engineer, DevOps Enthusiast, Docker, Jenkins, Git, Gitlab, Kubernetes, Ansible.

No responses yet

Write a response