# Installation Alertmanager

## ติดตั้ง Alertmanager

การติดตั้ง Alertmanager จะติดตั้งที่ environment ที่เราได้สร้างไว้ตอนติดตั้ง senlin client กับ Octavia client

* ใช้ wget ดาวน์โหลด alertmanager ซึ่งควรใช้เป็น [version](https://prometheus.io/download/) ล่าสุด จากใน [Github](https://github.com/prometheus/alertmanager)

{% code overflow="wrap" %}

```bash
wget https://github.com/prometheus/alertmanager/releases/download/v_version_/alertmanager-{version}.linux-amd64.tar.gz 
```

{% endcode %}

* สร้าง user ของ alertmanager เเละ มอบสิทธิ์ให้ userนี้ จัดการไฟล์เเละไดเรกทอรี่

{% code overflow="wrap" lineNumbers="true" %}

```bash
sudo groupadd -f alertmanager
sudo useradd -g alertmanager --no-create-home --shell /bin/false alertmanager
sudo mkdir -p /etc/alertmanager/templates
sudo mkdir /var/lib/alertmanager
sudo chown alertmanager:alertmanager /etc/alertmanager
sudo chown alertmanager:alertmanager /var/lib/alertmanager
```

{% endcode %}

* ใช้ `tar` เเตกไฟล์ alertmanager-{version}.linux-amd64.tar.gz เเละใช้ `mv` ย้ายไฟล์

{% code overflow="wrap" lineNumbers="true" %}

```bash
tar -xvf alertmanager-{version}.linux-amd64.tar.gz
mv alertmanager-{version}.linux-amd64 alertmanager-files
```

{% endcode %}

* copy ไฟล์ alertmanager เเละ amtool ไปที่ /usr/bin

{% code overflow="wrap" lineNumbers="true" %}

```bash
sudo cp alertmanager-files/alertmanager /usr/bin/
sudo cp alertmanager-files/amtool /usr/bin/
sudo chown alertmanager:alertmanager /usr/bin/alertmanager
sudo chown alertmanager:alertmanager /usr/bin/amtool
```

{% endcode %}

* ย้าย alertmanager.yml จาก alertmanager-files ไปที่ /etc/alertmanager เเละ มอบสิทธิ์ให้ user alertmanager จัดการไฟล์เเละไดเรกทอรี่

{% code overflow="wrap" lineNumbers="true" %}

```bash
sudo cp alertmanager-files/alertmanager.yml /etc/alertmanager/alertmanager.yml
sudo chown alertmanager:alertmanager /etc/alertmanager/alertmanager.yml
```

{% endcode %}

* สร้าง alertmanager service file

```bash
sudo vi /usr/lib/systemd/system/alertmanager.service
```

จากนั้น add config ดังนี้&#x20;

```yaml
[Unit]
Description=AlertManager
Wants=network-online.target
After=network-online.target

[Service]
User=alertmanager
Group=alertmanager
Type=simple
ExecStart=/usr/bin/alertmanager \
    --config.file /etc/alertmanager/alertmanager.yml \
    --storage.path /var/lib/alertmanager/

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

เเก้ไขสิทธิ์ของไฟล์

```bash
sudo chmod 664 /usr/lib/systemd/system/alertmanager.service
```

* ใช้ systemd  daemon-reload เเละ start alertmanager service รวมถึงเช็ค status

{% code overflow="wrap" lineNumbers="true" %}

```bash
sudo systemctl daemon-reload
sudo systemctl start alertmanager
sudo systemctl status alertmanager
sudo systemctl enable alertmanager.service
```

{% endcode %}

### เข้าหน้า Prometheus AlertManager UI

สามารถเข้าได้จาก http\://{Floating\_ip}:9093\
Ex.

<figure><img src="https://1352697161-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fq2BYmWTMiaonrEL8QBP2%2Fuploads%2FjkyU9qKJ8b2udwpibBlD%2Fimage.png?alt=media&#x26;token=913e363a-376d-4e2f-92d0-79b05ac0386a" alt=""><figcaption></figcaption></figure>

CREDIT: <https://developer.couchbase.com/tutorial-configure-alertmanager>


---

# 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-epc.gitbook.io/ncs-documents/public-api/what-is-ncs-public-api/getting-start-with-ncs-public-api/auto-scaling-openstack-instances-with-senlin-and-prometheus/installation-alertmanager.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.
