Commit 938f1ee4 authored by JooHan Hong's avatar JooHan Hong

prometheus init

parent 31e8c83e
Pipeline #5195 passed with stages
in 48 seconds
[![logo](https://www.hongsnet.net/images/logo.gif)](https://www.hongsnet.net)
# 개요
Prometheus을 이용한 www.hongsnet.net Container를 모니터링 한다.
# 구성
![source_overview](./images/container-monitoring.png)
> !참고 : Node 및 VM은 Zabbix에서 모니터링을 수행하기 때문에 node-exporter는 실행되지 않는다.
- **k8s**
> 현재 진행중
- **Swarm**
구성은 Docker Stack을 이용할 것이며, yml 파일의 내역은 다음과 같다.
```bash
# cat docker-stack.yml
version: '3'
services:
prometheus:
image: prom/prometheus
deploy:
mode: global
placement:
constraints: [node.hostname == TB2-DOCKER]
volumes:
- /GLUSTERFS/PROM/DATA/prometheus/data:/prometheus
- /GLUSTERFS/PROM/DATA/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- /GLUSTERFS/PROM/DATA/prometheus/alert.rules:/etc/prometheus/alert.rules
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--web.enable-admin-api'
- '--storage.tsdb.retention.time=1y'
ports:
- '9090:9090'
depends_on:
- cadvisor
cadvisor:
image: google/cadvisor:latest
deploy:
mode: global
ports:
- "8080:8080"
volumes:
- /:/rootfs:ro
- /var/run:/var/run:rw
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
grafana:
image: grafana/grafana
deploy:
mode: global
placement:
constraints: [node.hostname == TB2-DOCKER]
volumes:
- /GLUSTERFS/PROM/DATA/grafana/data:/var/lib/grafana
- /GLUSTERFS/PROM/DATA/grafana/grafana.ini:/etc/grafana/grafana.ini
environment:
- GF_SECURITY_ADMIN_PASSWORD=ghdwngkstjqj
depends_on:
- prometheus
ports:
- "3000:3000"
depends_on:
- prometheus
alertmanager:
image: prom/alertmanager
deploy:
mode: global
placement:
constraints: [node.hostname == TB2-DOCKER]
volumes:
- /GLUSTERFS/PROM/DATA/alertmanager:/etc/alertmanager/
depends_on:
- prometheus
ports:
- '9093:9093'
```
> !중요 : cadvisor 를 제외한 구성요소는 다음의 설정에 따라 Manager Node에서만 수행된다.
```python
placement:
constraints: [node.hostname == TB2-DOCKER]
```
이제 **monitor** 서비스를 다음과 같이 실행한다.
```bash
# docker stack deploy -c docker-stack.yml monitor
```
* [ **Manager Node** ]
```bash
# docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
xodct3yxupq6 monitor_alertmanager global 1/1 prom/alertmanager:latest *:9093->9093/tcp
zlay4qoq8gg7 monitor_cadvisor global 4/4 google/cadvisor:latest *:8080->8080/tcp
pfljlqixrepi monitor_grafana global 1/1 grafana/grafana:latest *:3000->3000/tcp
1kakkg4asokp monitor_prometheus global 1/1 prom/prometheus:latest *:9090->9090/tcp
hjsvav9409zy web_hongsnet global 3/3 registry.hongsnet.net/joohan.hong/docker/hongsnet:latest *:80->80/tcp
```
* [ **Worker Nodes** ]
```bash
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
93c7bdfd3dde google/cadvisor:latest "/usr/bin/cadvisor -…" 22 hours ago Up 22 hours 8080/tcp monitor_cadvisor.t3zbiuhkpam480yfqgc78tzgn.oa8wy24n0dm7t11w0lav9k5lu
dca11cc1625a registry.hongsnet.net/joohan.hong/docker/hongsnet:latest "/usr/bin/supervisor…" 42 hours ago Up 42 hours 80/tcp web_hongsnet.t3zbiuhkpam480yfqgc78tzgn.yyewdmnoun7jnq1l19jrip590
```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment