Difference between revisions of "Prometheus"
(Created page with "Placeholder text. =Prometheus= ==Downloading Prometheus== You may need to check the Prometheus documentation/downloads for the latest version [https://prometheus.io/downloa...") |
(Initial commit of the Prometheus page) |
||
| Line 36: | Line 36: | ||
<nowiki>sudo cp -r consoles/ /etc/prometheus/ | <nowiki>sudo cp -r consoles/ /etc/prometheus/ | ||
sudo cp -r console_libraries/ /etc/prometheus/</nowiki> | sudo cp -r console_libraries/ /etc/prometheus/</nowiki> | ||
| + | |||
| + | Then we need to move the provided .yml file for prometheus to the 'etc/prometheus/' directory: | ||
| + | <nowiki>sudo cp prometheus.yml /etc/prometheus/prometheus.yml</nowiki> | ||
| + | |||
| + | <nowiki>sudo chown -R prometheus:prometheus /etc/prometheus /var/lib/prometheus</nowiki> | ||
==Create Systemd Service for Prometheus== | ==Create Systemd Service for Prometheus== | ||
| + | Create the service file itself: | ||
| + | <nowiki>sudo vim /etc/systemd/system/prometheus.service</nowiki> | ||
| + | |||
| + | Include the following: | ||
| + | <nowiki> | ||
| + | [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 \ | ||
| + | --storage.tsdb.retention.time=15d \ | ||
| + | --web.enable-lifecycle \ # Each line requires a trailing \ EXCEPT the last line of the ExecStart block | ||
| + | --web.listen-address=:PORT # Uses 9090 by default if web.listen-address is not provided, can use a different port if specified here | ||
| + | |||
| + | [Install] | ||
| + | Wantedby=multi-user.target | ||
| + | </nowiki> | ||
| + | |||
| + | Once the service file is created and all the files/directories are where they should be, the Prometheus service can be started: | ||
| + | <nowiki> | ||
| + | #Reload the daemons | ||
| + | sudo systemctl daemon-reload | ||
| + | |||
| + | #Start the prometheus service | ||
| + | sudo systemctl start prometheus | ||
| + | |||
| + | #Check the status of Prometheus | ||
| + | sudo systemctl status prometheus | ||
| + | |||
| + | #If the service starts successfully, enable the service to start on every boot | ||
| + | sudo systemctl enable prometheus | ||
| + | </nowiki> | ||
| + | |||
| + | Then we can verify that Prometheus is running and listening on the specified port: | ||
| + | <nowiki>curl http://localhost:PORT/-/healthy</nowiki> | ||
| + | If it is working properly, the output should look like: | ||
| + | <nowiki>Prometheus Server is Healthy</nowiki> | ||
==Configure Prometheus== | ==Configure Prometheus== | ||
Revision as of 02:21, 28 March 2026
Placeholder text.
Prometheus
Downloading Prometheus
You may need to check the Prometheus documentation/downloads for the latest version here.
Copy the URL for the version you need from that page (should be a Github link) and paste it into the below:
wget INSERT_LINK_HERE
Extract the file:
tar xfvz prometheus-WHATEVER-VERSION-YOU-HAVE.tar.gz
Creating Prometheus User
Create a user account for Prometheus, without a home folder and with a nologin shell:
sudo useradd --no-create-home --shell /usr/sbin/nologin prometheus<nowiki> ==Create Prometheus Directories== Create the below directories: <nowiki>sudo mkdir -p /etc/prometheus /var/lib/prometheus
Copy the two files below, from within the 'prometheus-WHATEVER-VERSION-YOU-HAVE' directory, to '/usr/local/bin/'
sudo cp prometheus /usr/local/bin/ sudo cp promtool /usr/local/bin/
Change ownership of the files to the prometheus user we created:
sudo chown prometheus:prometheus /usr/local/bin/prometheus /usr/local/bin/promtool
Copy the below directories, again from within the 'prometheus-WHATEVER-VERSION-YOU-HAVE' directory, to the '/etc/prometheus/' directory:
sudo cp -r consoles/ /etc/prometheus/ sudo cp -r console_libraries/ /etc/prometheus/
Then we need to move the provided .yml file for prometheus to the 'etc/prometheus/' directory:
sudo cp prometheus.yml /etc/prometheus/prometheus.yml
sudo chown -R prometheus:prometheus /etc/prometheus /var/lib/prometheus
Create Systemd Service for Prometheus
Create the service file itself:
sudo vim /etc/systemd/system/prometheus.service
Include the following:
[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 \
--storage.tsdb.retention.time=15d \
--web.enable-lifecycle \ # Each line requires a trailing \ EXCEPT the last line of the ExecStart block
--web.listen-address=:PORT # Uses 9090 by default if web.listen-address is not provided, can use a different port if specified here
[Install]
Wantedby=multi-user.target
Once the service file is created and all the files/directories are where they should be, the Prometheus service can be started:
#Reload the daemons sudo systemctl daemon-reload #Start the prometheus service sudo systemctl start prometheus #Check the status of Prometheus sudo systemctl status prometheus #If the service starts successfully, enable the service to start on every boot sudo systemctl enable prometheus
Then we can verify that Prometheus is running and listening on the specified port:
curl http://localhost:PORT/-/healthy
If it is working properly, the output should look like:
Prometheus Server is Healthy