Monitoring and Detecting Modified Files using Tripwire on CentOS 7
0

Prometheus is an open supply monitoring system that permits you to acquire metrics from any configured goal system. Prometheus implements a multi-dimensional data-model with highly effective queries, nice visualization, exact alerting, and comes with many integrations.

Prometheus initially was created by SoundCloud in 2012, however has now turn into an unbiased open supply undertaking maintained independently by the open supply neighborhood – all elements can be found below the Apache 2 License on Github.

On this tutorial, I’ll present you learn how to set up and configure Prometheus and the node_exporter. We’ll set up Prometheus monitoring system after which configure the node_exporter to gather metrics from the server. We will likely be utilizing the CentOS 7 server for this tutorial information.

Stipulations

  • CentOS 7 server
  • Root privileges

What’s going to we do?

  1. Create a brand new consumer and obtain Prometheus
  2. Configure Prometheus As a Systemd Service
  3. Configure Firewalld
  4. Set up and Configure node_exporter
  5. Add node_exporter to the Prometheus Server
  6. Testing

Step 1 – Create a brand new Consumer and Obtain Prometheus

On this tutorial, the Prometheus service will run as a non-root consumer. So we have to create a brand new non-root consumer on the system. We’ll create a brand new consumer named ‘prometheus’, and all prometheus companies will likely be operating below the prometheus consumer.

Create new ‘prometheus’ consumer utilizing the command under.

useradd -m -s /bin/bash prometheus

A brand new consumer has been created. Now log in to the consumer and obtain prometheus utilizing the wget command.

su – prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.2.1/prometheus-2.2.1.linux-amd64.tar.gz

Extract the prometheus-xx.x.x.tar.gz file and rename the listing to ‘prometheus’.

tar -xzvf prometheus-2.2.1.linux-amd64.tar.gz
mv prometheus-2.2.1.linux-amd64/ prometheus/

Prometheus is downloaded to the server, and all prometheus information are on the ‘/residence/prometheus/prometheus’ listing.

Step 2 – Configure Prometheus As a Systemd Service

On this step, we are going to configure prometheus as a systemd service. We’ll create a brand new service file prometheus.service on the ‘/and so forth/systemd/system’ listing.

Go to the ‘/and so forth/systemd/system/’ listing and create new service file ‘prometheus.service’ utilizing vim editor.

cd /and so forth/systemd/system/
vim prometheus.service

Paste the prometheus service configuration under.


[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.goal

[Service]
Consumer=prometheus
Restart=on-failure

#Change this line if you happen to obtain the
#Prometheus on completely different path consumer
ExecStart=/residence/prometheus/prometheus/prometheus
  --config.file=/residence/prometheus/prometheus/prometheus.yml
  --storage.tsdb.path=/residence/prometheus/prometheus/knowledge

[Install]
WantedBy=multi-user.goal

Save and exit.

Now reload the systemd system utilizing the systemctl command under.

systemctl daemon-reload

Begin the prometheus service and allow it to launch everytime at system startup.

systemctl begin prometheus
systemctl allow prometheus

Configure Prometheus for systemd

The prometheus is now operating as a systemd service, verify it utilizing the command under.

systemctl standing prometheus

Be sure to get the ‘Operating’ service standing.

Or verify it utilizing the netstat command under.

netstat -plntu

Be sure to get the consequence as proven under.

Check that prometheus is running

Prometheus is operating by default below the port ‘9090’.

Step 3 – Configure Firewalld

Should you’re utilizing Firewalld in your system, add the port 9090 to the Firewalld listing ports.

Open port 9090 for the Prometheus entry utilizing firewall-cmd instructions under.

firewall-cmd –add-port=9090/tcp –permanent
firewall-cmd –reload

Now open your net browser and sort the server IP deal with with port 9090.

http://192.168.33.10:9090/graph

Kind ‘http_requests_total’ within the question area and click on the ‘Execute’ button.

Prometheus Graph

And you will note HTTP requests to the prometheus server with all information concerning the time, HTTP standing code, and technique and so forth.

Step 4 – Set up and Configure node_exporter

node_exporter is an exporter of machine metrics that may run on *Nix and Linux system.

On this tutorial, we are going to set up the node_exporter on the identical server prometheus. We’ll monitor and get the metric of the prometheus server.

Login to the prometheus consumer and obtain the ‘node_exporter’ utilizing the wget command.

su – prometheus
wget https://github.com/prometheus/node_exporter/releases/download/v0.16.0-rc.1/node_exporter-0.16.0-rc.1.linux-amd64.tar.gz

Extract the node_exporter and rename the listing to ‘node_exporter’.

tar -xzvf node_exporter-0.16.0-rc.1.linux-amd64.tar.gz
mv node_exporter-0.16.0-rc.1.linux-amd64 node_exporter

Subsequent, we are going to create new service file for the node_exporter. Again to the basis shell, goto the ‘/and so forth/systemd/system’ listing and create new node_exporter service file ‘node_exporter.service’ utilizing vim.

cd /and so forth/systemd/system/
vim node_exporter.service

There, paste node_exporter service configuration under.

[Unit]
Description=Node Exporter
Needs=network-online.goal
After=network-online.goal

[Service]
Consumer=prometheus
ExecStart=/residence/prometheus/node_exporter/node_exporter

[Install]
WantedBy=default.goal

Save and exit.

Now reload the systemd system.

systemctl daemon-reload

Then begin the node_exporter service and allow it to launch everytime at system startup.

systemctl begin node_exporter
systemctl allow node_exporter

Configure node_exporter systemd unit

The node_exporter service is now operating on the server – verify it utilizing the netstat command.

netstat -plntu

And you’re going to get the node-exporter is operating on port 9100.

Check node_exporter port

Step 5 – Add node_exporter to the Prometheus Server

On this step, we are going to add the node_exporter to the prometheus server. Login to the prometheus consumer and edit the configuration ‘prometheus.yml’ file.

Login to the prometheus consumer.

su – prometheus

Goto the ‘prometheus’ listing and edit the configuration file ‘prometheus.yml’.

cd prometheus/
vim prometheus.yml

Underneath the ‘scrape_config’ line, add new job_name node_exporter by copy-pasting the configuration under.

  - job_name: 'node_exporter'
    static_configs:
      - targets: ['localhost:9100']

Save and exit.

Add node_exporter to the Prometheus Server

Now restart the prometheus service.

systemctl restart prometheus

The node_exporter has been added to the prometheus server.

Step 6 – Testing Prometheus and node_exporter

Open your net browser after which enter the server IP deal with.

http://192.168.33.10:9090/

Kind the meminfo collector ‘node_memory_MemAvailable_bytes‘ within the question area and click on the ‘Execute’ button.

And you’re going to get the consequence as under.

Result for node_memory_MemAvailable_bytes

You’re going to get the accessible reminiscence on the server occasion ‘localhost:9100’, and the job_name ‘node-exporter’.

Or if you wish to entry the node_exporter uncooked knowledge, that you must add the node_exporter port 9100 to the firewalld.

firewall-cmd –add-port=9100/tcp
firewall-cmd –reload

After which kind the server IP deal with with port 9100.

http://192.168.33.10:9100/metrics

And you’re going to get the node_exporter uncooked knowledge as proven under.

Result Metrics

Set up and configuration of the prometheus monitoring system with the node_exporter on CentOS 7 has been accomplished efficiently.

How To Set up the Django Web Framework on Ubuntu 18.04

Previous article

Twitter suspends Alex Jones for urging individuals to maintain “battle rifles” prepared [Update]

Next article

You may also like

Comments

Leave a Reply

More in Apache