prometheus의 데이터를 grafana로 그래프로 보았습니다.
10914 단어 grafanaprometheus
prometheus
prometheus.yml
global:
external_labels:
monitor: 'codelab-monitor'
rule_files:
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
docker-compose.yml
prometheus:
image: prom/prometheus
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"
http://localhost:9090/metrics (사용 가능한 값은 여기에서 확인할 수 있음)
docker를 사용하지 않는 경우
wget "https://github.com/prometheus/prometheus/releases/download/v2.0.0-rc.2/prometheus-2.0.0-rc.2.linux-amd64.tar.gz"
tar xzf "prometheus-2.0.0-rc.2.linux-amd64.tar.gz"
cd prom*
./prometheus
모니터링 대상을 추가하는 방법
htps : // 기주 b. 이 m / p 어려워 s / 그래서 _ x rr r / ree a s
에서 node_exporter-0.15.0.linux-amd64.tar.gz 의
node_exporter
를 가져옵니다.시작. 9100에서 LISTEN
./node_exporter
또는 docker를 사용할 수 있습니다. 참고 : Prometheus에서 Docker 호스트 + 컨테이너를 모니터링하려고했습니다.
prometheus/node-exporter(22.8MB로 작음)
docker run -d \
-v "/proc:/host/proc:ro" \
-v "/sys:/host/sys:ro" \
-v "/:/rootfs:ro" \
--net="host" \
quay.io/prometheus/node-exporter
prometheus.yml에 대상 추가
global:
external_labels:
monitor: 'codelab-monitor'
rule_files:
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
+ - job_name: 'node'
+ static_configs:
+ - targets: ['localhost:9100']
설정 반영
./prometheus
node가 추가되었는지 확인.

총 CPU 합계 최대 100
100 - (avg by (instance) (irate(node_cpu{job="node",mode="idle"}[5m])) * 100)

추가 모니터링 대상을 추가하는 방법
prometheus.yml
+ - targets: ['192.168.100.53:9100']
# ymlを書き換えた後はHUPかければ良い (6秒位反映に時間がかかる)
killall -HUP prometheus
그래프 그리기 예
http://localhost:9100/metrics 방문하면
node_load1 0.13
등이 있으므로, 여기를 prometheus의 입력란에 붙여 넣으면 아래의 Console에 지정 방법이 표시된다.


grafana에 붙여넣어 그래프가 그려지는 것을 확인.

grafana
docker-compose.yml
grafana:
image: grafana/grafana
ports:
- "3000:3000"
http://localhost:3000
설정을 지정하려면 다음
docker-compose.yml
grafana:
image: grafana/grafana
container_name: grafana
environment:
- TZ=Asia/Tokyo
- GF_PATHS_DATA=/var/lib/grafana
- GF_PATHS_LOGS=/var/log/grafana
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin
# iframeの埋め込みに対応
- GF_SECURITY_ALLOW_EMBEDDING=true
# iframeの埋め込みを認証なしで表示
- GF_AUTH_ANONYMOUS_ENABLED=true
# Grafanaサーバーのアドレスを指定 (share時に便利)
- GF_SERVER_ROOT_URL=http://192.168.100.65:3000
ports:
- "3000:3000"


Templating init failed
가 나왔을 경우는 ip 주소를 지정하면 된다. (prometheus를 tar.gz에서 배포하고 실행 한 호스트와 grafana가 docker로 시작된 경우 ip 주소 지정이 필요합니다.) 
대시보드 -> 가져오기





그래프 편집
그래프 제목을 왼쪽 클릭 -> 편집

Metrics -> 쿼리 입력 -> (그래프가 표시되지 않으면) 오른쪽 눈 아이콘을 클릭

{{instance}}
로 하면 prometheus 에 등록되어 있는 ipaddress:port 가 표시된다. 끝나면 오른쪽 눈 아이콘 위의
×
부하를 걸어 본다
yes > /dev/null
flowchart-plugin
Reference
이 문제에 관하여(prometheus의 데이터를 grafana로 그래프로 보았습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/tukiyo3/items/da379f6e5844c99b65df텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)