# Manual Install

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](/production-checklist/bindplane/high-availability/prometheus/installation.md)\
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
sudo groupadd --system prometheus
sudo useradd -s /sbin/nologin --system -g prometheus prometheus
```

### Download Release

Download the [v2.47.2 release](https://github.com/prometheus/prometheus/releases/tag/v2.47.2).

{% tabs %}
{% tab title="AMD64" %}

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

{% endtab %}

{% tab title="ARM64" %}

```bash
curl -L \
    -o prometheus.tar.gz \
    https://github.com/prometheus/prometheus/releases/download/v2.47.2/prometheus-2.47.2.linux-arm64.tar.gz
```

{% endtab %}
{% endtabs %}

Extract the archive to your working directory.

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

### Binary Installation

Install binaries to `/usr/bin`.

```bash
sudo cp prometheus/prometheus /usr/bin/prometheus
sudo cp prometheus/promtool /usr/bin/promtool
```

### Configuration

Configure the Prometheus configuration directories and files.

```bash
sudo mkdir /etc/prometheus

sudo touch \
    /etc/prometheus/prometheus.yml \
    /etc/prometheus/rules.yml \
    /etc/prometheus/web.yml

sudo chmod 0750 /etc/prometheus
sudo chmod 0600 /etc/prometheus/prometheus.yml
sudo chmod 0600 /etc/prometheus/rules.yml
sudo chmod 0600 /etc/prometheus/web.yml
sudo chown -R prometheus:prometheus /etc/prometheus
```

Configure the Prometheus storage directories and files.

```bash
sudo mkdir /var/lib/prometheus
sudo mkdir /var/lib/prometheus/tsdb

sudo mv prometheus/console_libraries /var/lib/prometheus
sudo mv prometheus/consoles /var/lib/prometheus

sudo chmod 0750 /var/lib/prometheus
sudo chown -R prometheus:prometheus /var/lib/prometheus
```

Populate `prometheus.yml`.

```bash
sudo tee /etc/prometheus/prometheus.yml <<'EOF'
scrape_configs: []
rule_files: [/etc/prometheus/rules.yml]
EOF
```

Populate `rules.yml`.

```bash
sudo tee /etc/prometheus/rules.yml <<'EOF'
groups:
- name: configuration-rollups
  interval: 1m
  rules:
  - record: bindplane_agent_measurements:rollup:rate:1m
    expr: sum without (agent) (rate(bindplane_agent_measurements{}[1m9s999ms] offset 10s))
- name: 5m-configuration-rollups
  interval: 5m
  rules:
  - record: bindplane_agent_measurements:rollup:rate:5m
    expr: sum without (agent) (rate(bindplane_agent_measurements:1m{}[5m59s999ms] offset 10s))
- name: 1h-configuration-rollups
  interval: 1h
  rules:
  - record: bindplane_agent_measurements:rollup:rate:1h
    expr: sum without (agent) (rate(bindplane_agent_measurements:15m{}[1h14m59s999ms] offset 10s))
EOF
```

Leave `web.yml` alone for now. See the [TLS](/production-checklist/bindplane/high-availability/prometheus/configuration.md#transport-layer-security-tls) section for details on how to secure communication between Bindplane and Prometheus.

### Systemd Service

Create the Systemd service.

```bash
sudo touch /usr/lib/systemd/system/prometheus.service
sudo chmod 0640 /usr/lib/systemd/system/prometheus.service

sudo tee /usr/lib/systemd/system/prometheus.service <<'EOF'
[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/bin/prometheus \
--config.file /etc/prometheus/prometheus.yml \
--web.config.file /etc/prometheus/web.yml \
--storage.tsdb.retention.time 2d \
--web.enable-remote-write-receiver \
--web.listen-address :9090 \
--storage.tsdb.path /var/lib/prometheus/tsdb \
--web.console.templates=/var/lib/prometheus/consoles \
--web.console.libraries=/var/lib/prometheus/console_libraries

[Install]
WantedBy=multi-user.target
EOF
```

Enable and start Prometheus.

```bash
sudo systemctl enable prometheus
sudo systemctl start prometheus
sudo systemctl status prometheus
```

### Validate

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

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bindplane.com/production-checklist/bindplane/high-availability/prometheus/manual-install.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
