Complimentary Gartner® Report! 'A CTO's Guide to Open-Source Software: Answering the Top 10 FAQs.'Read more

Prometheus Manual Installation

Installing Prometheus manually is accomplished by following the steps outlined on this page. The recommended approach is to install Prometheus using a Linux package. See the Linux Package documentation for details.

Prerequisites

Version

Prometheus version 2.47.2 or newer.

Create User and Group

Create a Prometheus user and group. This user will be used to execute the Prometheus process.

bash
1sudo groupadd --system prometheus
2sudo useradd -s /sbin/nologin --system -g prometheus prometheus

Download Release

Download the v2.47.2 release.

1curl -L \
2    -o prometheus.tar.gz \
3    https://github.com/prometheus/prometheus/releases/download/v2.47.2/prometheus-2.47.2.linux-amd64.tar.gz

Extract the archive to your working directory.

bash
1mkdir prometheus
2tar -xf prometheus.tar.gz --strip-components=1 -C prometheus

Binary Installation

Install binaries to /usr/bin.

bash
1sudo cp prometheus/prometheus /usr/bin/prometheus
2sudo cp prometheus/promtool /usr/bin/promtool

Configuration

Configure the Prometheus configuration directories and files.

bash
1sudo mkdir /etc/prometheus
2
3sudo touch \
4    /etc/prometheus/prometheus.yml \
5    /etc/prometheus/rules.yml \
6    /etc/prometheus/web.yml
7
8sudo chmod 0750 /etc/prometheus
9sudo chmod 0600 /etc/prometheus/prometheus.yml
10sudo chmod 0600 /etc/prometheus/rules.yml
11sudo chmod 0600 /etc/prometheus/web.yml
12sudo chown -R prometheus:prometheus /etc/prometheus

Configure the Prometheus storage directories and files.

bash
1sudo mkdir /var/lib/prometheus
2sudo mkdir /var/lib/prometheus/tsdb
3
4sudo mv prometheus/console_libraries /var/lib/prometheus
5sudo mv prometheus/consoles /var/lib/prometheus
6
7sudo chmod 0750 /var/lib/prometheus
8sudo chown -R prometheus:prometheus /var/lib/prometheus

Populate prometheus.yml.

bash
1sudo tee /etc/prometheus/prometheus.yml <<'EOF'
2scrape_configs: []
3rule_files: [/etc/prometheus/rules.yml]
4EOF

Populate rules.yml.

bash
1sudo tee /etc/prometheus/rules.yml <<'EOF'
2groups:
3- name: configuration-rollups
4  interval: 1m
5  rules:
6  - record: bindplane_agent_measurements:rollup:rate:1m
7    expr: sum without (agent) (rate(bindplane_agent_measurements{}[1m9s999ms] offset 10s))
8- name: 5m-configuration-rollups
9  interval: 5m
10  rules:
11  - record: bindplane_agent_measurements:rollup:rate:5m
12    expr: sum without (agent) (rate(bindplane_agent_measurements:1m{}[5m59s999ms] offset 10s))
13- name: 1h-configuration-rollups
14  interval: 1h
15  rules:
16  - record: bindplane_agent_measurements:rollup:rate:1h
17    expr: sum without (agent) (rate(bindplane_agent_measurements:15m{}[1h14m59s999ms] offset 10s))
18EOF

Leave web.yml alone for now. See the TLS section for details on how to secure communication between BindPlane OP and Prometheus

Systemd Service

Create the Systemd service.

bash
1sudo touch /usr/lib/systemd/system/prometheus.service
2sudo chmod 0640 /usr/lib/systemd/system/prometheus.service
3
4sudo tee /usr/lib/systemd/system/prometheus.service <<'EOF'
5[Unit]
6Description=Prometheus
7Documentation=https://prometheus.io/docs/introduction/overview/
8Wants=network-online.target
9After=network-online.target
10[Service]
11User=prometheus
12Group=prometheus
13Type=simple
14ExecStart=/usr/bin/prometheus \
15--config.file /etc/prometheus/prometheus.yml \
16--web.config.file /etc/prometheus/web.yml \
17--storage.tsdb.retention.time 2d \
18--web.enable-remote-write-receiver \
19--web.listen-address :9090 \
20--storage.tsdb.path /var/lib/prometheus/tsdb \
21--web.console.templates=/var/lib/prometheus/consoles \
22--web.console.libraries=/var/lib/prometheus/console_libraries
23
24[Install]
25WantedBy=multi-user.target
26EOF

Enable and start Prometheus.

bash
1sudo systemctl enable prometheus
2sudo systemctl start prometheus
3sudo systemctl status prometheus

Validate

You can validate that Prometheus is running with the following curl command.

bash
1curl -v -s localhost:9090/metrics