To install Prometheus on a Red Hat server, you can follow these steps:
Open a terminal or connect to your Red Hat server via SSH.
Download the Prometheus binary package suitable for Red Hat from the official Prometheus download page. For example, to download the latest version of Prometheus, you can use the following command:
wget https://github.com/prometheus/prometheus/releases/latest/download/prometheus-2.51.1.linux-amd64.tar.gz
Extract the downloaded package using the following command:
tar xvfz prometheus-*.linux-amd64.tar.gz
Move into the extracted Prometheus directory:
cd prometheus-2.51.1.linux-amd64
Inside the Prometheus directory, you'll find the necessary binaries. Copy these binaries to appropriate system locations using the following commands:
sudo cp prometheus /usr/local/bin/
sudo cp promtool /usr/local/bin/
Create a new user to run Prometheus:
sudo useradd -M -r -s /bin/false prometheus
Create the necessary directories and set the ownership to the Prometheus user:
sudo mkdir /etc/prometheus
sudo mkdir /var/lib/prometheus
sudo chown prometheus:prometheus /etc/prometheus
sudo chown prometheus:prometheus /var/lib/prometheus
Copy the Prometheus configuration file to the /etc/prometheus
directory. You can use the default configuration file or provide your custom configuration file. For example:
sudo cp prometheus.yml /etc/prometheus/
Adjust the ownership and permissions of the configuration file:
sudo chown prometheus:prometheus /etc/prometheus/prometheus.yml
sudo chmod 644 /etc/prometheus/prometheus.yml
Create a systemd service unit file for Prometheus:
sudo vim /etc/systemd/system/prometheus.service
Paste the following content into the file and save it:
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/docs/introduction/overview/
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
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
Reload systemd to load the new service unit file:
sudo systemctl daemon-reload
Start Prometheus and enable it to start on system boot:
sudo systemctl start prometheus
sudo systemctl enable prometheus
Verify that Prometheus is running properly by checking its status:
sudo systemctl status prometheus
If everything is set up correctly, you should see a message indicating that the service is active and running.
Prometheus should now be installed and running on your Red Hat server. You can access the Prometheus web interface by visiting http://<your-server-ip>:9090
in your web browser, replacing <your-server-ip>
with the actual IP address or hostname of your Red Hat server.
To install Grafana on a Red Hat server, you can follow these steps:
Open a terminal or connect to your Red Hat server via SSH.
Add the Grafana repository by creating a new repository file:
sudo vim /etc/yum.repos.d/grafana.repo
[grafana]
name=grafana
baseurl=https://packages.grafana.com/oss/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
sslverify=1
This configuration file sets up the repository for Grafana.
sudo yum makecache
yum
:sudo yum install grafana
sudo systemctl start grafana-server
sudo systemctl enable grafana-server
sudo systemctl status grafana-server
If everything is set up correctly, you should see a message indicating that the service is active and running.
By default, Grafana listens on port 3000. You can access the Grafana web interface by visiting http://<your-server-ip>:3000
in your web browser, replacing <your-server-ip>
with the actual IP address or hostname of your Red Hat server.
Log in to Grafana using the default credentials:
Upon login, Grafana will prompt you to change the password.
That's it! You have successfully installed Grafana on your Red Hat server. You can now configure and customize Grafana for your monitoring and visualization needs.
First create the repository
sudo vim /etc/yum.repos.d/prometheus-node-exporter.repo
Then add the following to the repository
[prometheus_node_exporter]
name=Prometheus Node Exporter
baseurl=https://packagecloud.io/prometheus-rpm/release/el/$releasever/$basearch
gpgcheck=1
enabled=1
gpgkey=https://packagecloud.io/prometheus-rpm/release/gpgkey
Import the key
sudo rpm --import https://packagecloud.io/prometheus-rpm/release/gpgkey
Then do the install
sudo yum makecache
sudo yum install node_exporter
# If there is a problem with the gpgcheck
# sudo yum install node_exporter --nogpgcheck
Start it, persist it and make sure that its running
sudo systemctl start node_exporter
sudo systemctl enable node_exporter
sudo node_exporter --version
Access the Node Exporter metrics by visiting the following URL in your web browser or with curl
curl http://<your-server-ip>:9100/metrics
Replace with the actual IP address or hostname of your Red Hat 8 server.
Create the prometheus user
Step 1 – Add Prometheus system user and group: This user will manage the exporter service.
sudo groupadd --system prometheus
sudo useradd -s /sbin/nologin --system -g prometheus prometheus
(Make sure that this is the latest for the OS version you are on)
cd /opt
wget https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz
tar -xzvf node_exporter-1.5.0.linux-amd64.tar.gz
mv node_exporter-1.5.0.linux-amd64/node_exporter /usr/local/bin/node_exporter
chown prometheus:prometheus /usr/local/bin/node_exporter
chmod +x /usr/local/bin/node-exporter
Make sure that it works
node-exporter --version
Create a new service file:
sudo vim /etc/systemd/system/node_exporter.service
Add the following content
[Unit]
Description=Prometheus Node Exporter
After=network.target
User=prometheus
Group=prometheus
[Service]
Type=simple
Restart=always
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=multi-user.target
And now reload it
sudo systemctl daemon-reload
sudo systemctl enable node-exporter
sudo systemctl start node-exporter
wget https://github.com/gesellix/couchdb-prometheus-exporter/releases/download/v30.5.0/couchdb-prometheus-exporter_30.5.0_Linux_x86_64.tar.gz
tar -xzvf couchdb-prometheus-exporter_30.5.0_Linux_x86_64.tar.gz
chown prometheus:prometheus couchdb-prometheus-exporter
chmod +x couchdb-prometheus-exporter
mv -f couchdb-prometheus-exporter /usr/local/bin/
couchdb-prometheus-exporter --version
3 Set up the service to start it with
Create a new service file:
sudo vim /etc/systemd/system/couchdb-prometheus-exporter.service
4 Add the following content
[Unit]
Description=Prometheus Couchdb Exporter
After=network.target
User=prometheus
Group=prometheus
[Service]
Type=simple
Restart=always
ExecStart=/usr/local/bin/couchdb-prometheus-exporter
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable couchdb-prometheus-exporter
sudo systemctl start couchdb-prometheus-exporter
sudo systemctl status couchdb-prometheus-exporter
If everything is set up correctly, you should see a message indicating that the service is active and running.
curl http://<your-server-ip>:9189/metrics
Replace <your-server-ip>
with the actual IP address or hostname of your server.
You can now configure Prometheus to scrape metrics from the CouchDB Exporter endpoint.
Download the blackbox_exporter binary from the official GitHub repository: https://github.com/prometheus/blackbox_exporter/releases
wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.24.0/blackbox_exporter-0.24.0.linux-386.tar.gz
tar -xzvf blackbox_exporter-*.tar.gz
cd blackbox_exporter-*
chmod +x blackbox_exporter
Move the executable to /usr/local/bin/blackbox_exporter
mv /opt/blackbox_exporter-0.24.0.linux-386/blackbox_exporter /usr/local/bin/blackbox_exporter
chown prometheus:prometheus /usr/local/bin/blackbox_exporter
Move the blackbox.yml file to /etc/prometheus
mv /opt/blackbox_exporter-0.24.0.linux-386/blackbox.yml /etc/prometheus/
chown prometheus:prometheus /etc/prometheus/blackbox.yml
3 Set up the service to start it with
Create a new service file:
sudo vim /etc/systemd/system/blackbox_exporter.service
Add the following content
[Unit]
Description=Prometheus Blackbox Exporter
After=network.target
User=prometheus
Group=prometheus
[Service]
Type=simple
Restart=always
ExecStart=/usr/local/bin/blackbox_exporter \
--config.file=/etc/prometheus/blackbox.yml
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable blackbox_exporter
sudo systemctl start blackbox_exporter
blackbox_exporter --version
blackbox_exporter, version 0.24.0 (branch: HEAD, revision: 0b0467473916fd9e8526e2635c2a0b1c56011dff)
build user: root@4802268d1578
build date: 20230516-11:12:46
go version: go1.20.4
platform: linux/386
tags: netgo
vim /etc/prometheus/prometheus.yml
- job_name: 'blackbox'
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets:
- https://epwprs.dpw.gov.za
- https://kwantu.net
- https://kwantu.me
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: <ipaddress of blackbox exporter>:9115 # Address of your blackbox_exporter