How to configure Prometheus server in linux

0 votes

Hi Guys,

I am trying to monitor metrics of my VM using Prometheus server. Can someone tell me how can I configure Prometheus server on Linux?

May 27, 2020 in DevOps & Agile by akhtar
• 38,260 points
1,169 views

2 answers to this question.

0 votes

Hi@akhtar

You can follow the below given steps to configure Prometheus server on Linux:

  • Download the Prometheus software from the link given below.

https://github.com/prometheus/prometheus/releases/download/v2.18.1/prometheus-2.18.1.linux-amd64.tar.gz
  •  To unpack the tar.gz file use the below given command.

 $ tar -xzf  prometheus-2.18.1.linux-amd64.tar.gz
  • Now start prometheus service. Go inside the prometheus-2.18.1.linux-amd64/ and run the prometheus program file.

$ ./prometheus

For WebUI, you can browse localhost:9090

Hope this is helpful.

answered May 27, 2020 by MD
• 95,460 points
+1 vote

Hi there ,

Setup Prometheus Configuration

All the prometheus configurations should be present in /etc/prometheus/prometheus.yml file.

Step 1: Create the prometheus.yml file.

sudo vi /etc/prometheus/prometheus.yml

Step 2: Copy the following contents to the prometheus.yml file.

global:
  scrape_interval: 10s

scrape_configs:
  - job_name: 'prometheus'
    scrape_interval: 5s
    static_configs:
      - targets: ['localhost:9090']

Step 3: Change the ownership of the file to prometheus user.

sudo chown prometheus:prometheus /etc/prometheus/prometheus.yml

Setup Prometheus Service File

Step 1: Create a prometheus service file.

sudo vi /etc/systemd/system/prometheus.service

Step 2: Copy the following content to the file.

[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \
    --config.file /etc/prometheus/prometheus.yml \
    --storage.tsdb.path /var/lib/prometheus/ \
    --web.console.templates=/etc/prometheus/consoles \
    --web.console.libraries=/etc/prometheus/console_libraries

[Install]
WantedBy=multi-user.target

Step 3: Reload the systemd service to register the prometheus service and start the prometheus service.

sudo systemctl daemon-reload
sudo systemctl start prometheus

Check the prometheus service status using the following command.

sudo systemctl status prometheus

The status should show the active state.

Access Prometheus Web UI

Now you will be able to access the prometheus UI on 9090 port of the prometheus server.

http://<prometheus-ip>:9090/graph

You should be able to see the UI.

Right now we have just configured prometheus. You need to register the target in the prometheus.yml file to get the metrics from the source systems.

Thank you,hope my answer will help you.

answered Jul 9, 2020 by Suhana
• 340 points

Related Questions In DevOps & Agile

0 votes
1 answer

How to add Node Exporter in Prometheus server?

Hi@akhtar, To add Node Exporter in Prometheus server, you have to ...READ MORE

answered May 28, 2020 in DevOps & Agile by MD
• 95,460 points
2,608 views
0 votes
1 answer

How to disable linux user authentication on ldap server

You can try the below steps: passwd -l ...READ MORE

answered Apr 27, 2018 in DevOps & Agile by shubham
• 7,340 points
1,873 views
0 votes
1 answer

How to get the file count in amazon bucket linux cli

Hi@Shahzeb, You can do this task using the ...READ MORE

answered Apr 27, 2020 in DevOps & Agile by MD
• 95,460 points
3,672 views
0 votes
1 answer

How to install grafana tool in Linux?

Hi@akhtar, To download Grafana in Linux system, you ...READ MORE

answered May 29, 2020 in DevOps & Agile by MD
• 95,460 points
1,095 views
0 votes
1 answer

How to configure maven in CentOS/ RHEL system?

Hi@akhtar, You can follow the below given steps ...READ MORE

answered Jun 3, 2020 in DevOps & Agile by MD
• 95,460 points
3,942 views
0 votes
2 answers

How to configure Maven in Jenkins?

HI... How to configure Maven in Jenkins- I HOPE ...READ MORE

answered Jul 14, 2020 in DevOps & Agile by anonymous

edited Jul 15, 2020 by Sirajul 52,433 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,990 views
+2 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP