๐Ÿ“—
smiley book
  • Smiley Books
  • AI
    • Readme
    • openai-whisper
      • ์ƒ˜ํ”Œ ์‹คํ–‰ํ•ด๋ณด๊ธฐ
      • GPU ์„œ๋ฒ„ ์ค€๋น„ํ•˜๊ธฐ
      • API๋กœ whisper๋ฅผ ์™ธ๋ถ€์— ์˜คํ”ˆํ•˜๊ธฐ
      • ํ”„๋กฌํ”„ํŠธ ์ง€์›
      • ์‹ค์‹œ๊ฐ„ message chat
      • ํ™”๋ฉด ์ด์˜๊ฒŒ ๋งŒ๋“ค๊ธฐ์™€ ๋กœ๊ทธ์ธ
      • ํŒŒ์ด์ฌ ๊ฐ€์ƒํ™˜๊ฒฝ
      • ์‹ค์‹œ๊ฐ„ voice chat
      • fine tunning(๋ฏธ์„ธ ์กฐ์ •) ์œผ๋กœ ์„ฑ๋Šฅ ์˜ฌ๋ฆฌ๊ธฐ
      • app์—์„œ api๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ ์‹ค์‹œ๊ฐ„์œผ๋กœ ํ…์ŠคํŠธ๋กœ ๋ฐ”๊ฟ”๋ณด๊ธฐ
    • ollama - llm์„ ์‰ฝ๊ฒŒ ๋‚ด์ปด์—์„œ ์‹คํ–‰
      • ollama webui
      • ollama docker
    • stable diffusion
      • SDXL - text to image
      • SD-webui
    • ChatGPT
      • ๋‹ต๋ณ€์ด ๋Š๊ธธ๋•Œ
      • ์—ญํ• ์„ ์ •ํ•˜์ž
      • ๊ตฌ์ฒด์ ์ธ ์งˆ๋ฌธ
      • ๊ฒฐ๊ณผํ˜•ํƒœ๋ฅผ ์ง€์ •
      • ํ”„๋กฌํ”„ํŠธ๋ฅผ ์—ฌ๋Ÿฌ์ค„๋กœ ์‚ฌ์šฉํ•˜์ž.
      • ๋งˆํ‹ด ํŒŒ์šธ๋Ÿฌ ๊ธ€ ๋ฒˆ์—ญ๋ณธ
    • Prompt Engineering
    • Auto-GPT
    • Gemini
      • google ai studio
      • gemini-api
      • embedding guide
    • Huggingface
      • huggingface ์‚ฌ์šฉ๋ฒ•
      • huggingface nlp ๊ณต๋ถ€์ค‘
    • kaggle
      • download dataset
    • langchain
      • langchain์„ ๊ณต๋ถ€ํ•˜๋ฉฐ ์ •๋ฆฌ
      • basic
      • slackbot
      • rag
      • document-loader
      • website-loader
      • confluence
      • memory
      • function-call
      • langsmith
      • agent-toolkit
  • Ansible
    • templates vs files and jinja2
    • dynamic inventory
    • limit ์˜ต์…˜ ๊ฐ•์ œํ•˜๊ธฐ
    • limit ์‚ฌ์šฉํ›„ gather_fact ๋ฌธ์ œ
  • AWS
    • AWS CLI
    • EKS
      • cluster manage
      • ALB Controller
      • external-dns
      • fargate
    • ECR
    • S3
    • Certificate Manager
  • Azure
    • Azure AD OAuth Client Flow
  • Container
    • Registry
    • ๋นŒ๋“œ์‹œ์— env๊ฐ’ ์„ค์ •ํ•˜๊ธฐ
  • DB
    • PXC
      • Operator
      • PMM
      • ์‚ญ์ œ
      • GTID
      • Cross Site Replication
    • Mssql
    • Mysql
  • dotnet
    • Thread Pool
    • Connection Pool
    • Thread Pool2
  • Devops
    • Recommendation
  • GIT
    • Basic
    • Submodule
  • GitHub
    • Repository
    • GitHub Action
    • GitHub PR
    • Self Hosted Runner
    • GitHub Webhook
  • GitLab
    • CI/CD
    • CI/CD Advance
    • Ssl renew
    • CI/CD Pass env to other job
  • Go Lang
    • ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ๊ตฌ์ถ•
    • multi os binary build
    • kubectl๊ฐ™์€ cli๋งŒ๋“ค๊ธฐ
    • azure ad cli
    • embed static file
    • go study
      • pointer
      • module and package
      • string
      • struct
      • goroutine
  • Kubernetes
    • Kubernetes๋Š” ๋ฌด์—‡์ธ๊ฐ€
    • Tools
    • Install with kubespray
    • Kubernetes hardening guidance
    • 11 ways not to get hacked
    • ArgoCD
      • Install
      • CLI
      • Repository
      • Apps
      • AWS ALB ์‚ฌ์šฉ
      • Notification slack
      • Backup / DR
      • Ingress
      • 2021-11-16 Github error
      • Server Config
      • auth0 ์ธ์ฆ ์ถ”๊ฐ€(oauth,OIDC)
    • Extension
      • Longhorn pvc
      • External dns
      • Ingress nginx
      • Cert Manager
      • Kube prometheus
    • Helm
      • Subchart
      • Tip
    • Loki
    • Persistent Volume
    • TIP
      • Job
      • Pod
      • Log
  • KAFKA
    • raft
  • KVM
    • kvm cpu model
  • Linux
    • DNS Bind9
      • Cert-Manager
      • Certbot
      • Dynamic Update
      • Log
    • Export and variable
    • Grep ์‚ฌ์šฉ๋ฒ•
  • Modeling
    • C4 model introduce
    • Mermaid
    • reference
  • Monitoring
    • Readme
    • 0. What is Monitoring
    • 1. install prometheus and grafana
    • 2. grafana provisioning
    • 3. grafana dashboard
    • 4. grafana portable dashboard
    • 5. prometheus ui
    • 6. prometheus oauth2
    • Prometheus
      • Metric type
      • basic
      • rate vs irate
      • k8s-prometheus
    • Grafana
      • Expolorer
    • Node Exporter
      • advance
      • textfile collector
  • Motivation
    • 3 Simple Rule
  • OPENNEBULA
    • Install(ansible)
    • Install
    • Tip
    • Windows vm
  • Reading
    • comfort zone
    • ๋ฐฐ๋ ค
    • elon musk 6 rule for insane productivity
    • Feynman Technique
    • how to interview - elon musk
    • ๊ฒฝ์ฒญ
    • Readme
  • Redis
    • Install
    • Master-slave Architecture
    • Sentinel
    • Redis Cluster
    • Client programming c#
  • SEO
    • Readme
  • Security
    • criminalip.io
      • criminalip.io
  • Stock
    • robinhood-python
  • Terraform
    • moved block
    • output
  • vault
    • Readme
  • VS Code
    • dev container
    • dev container on remote server
  • Old fashione trend
    • curity
    • MAAS
      • Install maas
      • Manage maas
      • Tip
Powered by GitBook
On this page
  • ๊ตฌ์„ฑ
  • ๋ชจ๋‹ˆํ„ฐ๋งํ•  ๋…ธ๋“œ ์„ค์ • ์ถ”๊ฐ€
  • ๋ชจ๋‹ˆํ„ฐ๋ง ํ•˜๊ธฐ
  • ์œˆ๋„์šฐ node ๋ชจ๋‹ˆํ„ฐ๋ง
  • ์•Œ๋ฆผ
  • ์•Œ๋ฆผ ๊ทœ์น™ ์ถ”๊ฐ€
  • ์•Œ๋žŒ ๋งค๋‹ˆ์ € ์„ค์น˜

Was this helpful?

  1. Monitoring
  2. Prometheus

basic

PreviousMetric typeNextrate vs irate

Last updated 1 year ago

Was this helpful?

source-code :

์„œ๋ฒ„๋‚˜ ํ”„๋กœ๊ทธ๋žจ์„ ๋ชจ๋‹ˆํ„ฐ๋ง ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•œ๋‹ค.

ํŠน์ง•์€ pull๋ฐฉ์‹์ด๋ผ๋Š”๊ฒƒ. ์ด๊ฒƒ์ด ์‹ ์˜ ํ•œ์ˆ˜

Prometheus ์„œ๋ฒ„๊ฐ€ ๋…ธ๋“œ์— ๋ฐ์ดํ„ฐ๋ฅผ ์š”์ฒญํ•˜๋ฉด ๋…ธ๋“œ๋‚˜ ํ”„๋กœ๊ทธ๋žจ๋“ฑ์€ ๋ฐ์ดํ„ฐ๋ฅผ ๋ณด๋‚ด์ฃผ๋ฉด ๋œ๋‹ค. ๋…ธ๋“œ๋Š” ์ „ํ˜€ prometheus ์„œ๋ฒ„์— ๋Œ€ํ•ด ์•Œ ํ•„์š”๊ฐ€ ์—†๊ณ  ๋ฐ์ดํ„ฐ์˜ ์ „๋‹ฌ์— ๋Œ€ํ•ด์„œ ๊ณ ๋ฏผํ•˜์ง€ ์•Š์•„๋„ ๋œ๋‹ค.

  • push : ๊ฐ๊ฐ ๋ชจ๋‹ˆํ„ฐ๋˜๋Š” ์„œ๋ฒ„์—์„œ ์ฃผ๊ธฐ์ ์œผ๋กœ ๋ชจ๋‹ˆํ„ฐ๋ง ์„œ๋ฒ„๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ๋ณด๋‚ด๋Š” ๋ฐฉ์‹

  • pull : ๊ฐ๊ฐ ๋ชจ๋‹ˆํ„ฐ๋˜๋Š” ์„œ๋ฒ„์—์„œ ๋ฐ๋ชฌ๋งŒ ๋Œ๊ณ ์žˆ๊ณ  ๋ชจ๋‹ˆํ„ฐ๋ง ์„œ๋ฒ„์—์„œ request๋ฅผ ๋˜์ €์„œ pullํ•˜๋Š” ๋ฐฉ์‹

๊ตฌ์„ฑ

  • prometheus : ๋ฐ์ดํ„ฐ๋ฅผ ์š”์ฒญํ•˜๊ณ  ๊ฐ€์ ธ์˜จ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•˜๊ณ  ์ฟผ๋ฆฌํ•จ

  • exporter: ์š”์ฒญ์„ ๋ฐ›์œผ๋ฉด ๋ฐ์ดํ„ฐ๋ฅผ ๋งŒ๋“ค์–ด์„œ ์š”์ฒญ์ž์—๊ฒŒ ๋ฆฌํ„ดํ•ด ์ค€๋‹ค.

  • push gateway : ๋ฐ๋ชฌํ˜•ํƒœ๋กœ ํ”„๋กœ๊ทธ๋žจ์ด ๋– ์žˆ๋Š”๊ฒŒ ์•„๋‹ˆ๊ณ  ๋ฐฐ์น˜ํ˜•ํƒœ๋กœ ์‹คํ–‰๋˜๊ณ  ์‚ฌ๋ผ์ง€๋Š” ํ”„๋กœ์„ธ์Šค๋Š” pull์„ ํ• ์ˆ˜๊ฐ€ ์—†์œผ๋ฏ€๋กœ ์ด๊ฑธ ์ด์šฉํ•ด์„œ prometheus์— ๋ณด๋‚ด์ค€๋‹ค.

  • alarm manager : ๋ฐ์ดํ„ฐ๊ฐ€ ํŠน์ • ์กฐ๊ฑด์ด ๋˜๋ฉด ์•Œ๋ฆผ์„ ์•Œ๋ ค์ค€๋‹ค. (์Šฌ๋ž™ ๋˜๋Š” ์ด๋ฉ”์ผ ๋“ฑ๋“ฑ ๋งŽ๋‹ค.)

  • dashboard : ์›นํ™”๋ฉด์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ๋ณด์—ฌ์ค€๋‹ค. ๊ธฐ๋ณธ์ ์ธ ํ™”๋ฉด์ด prometheus๊ฐ€ ๊ฐ€์ง€๊ณ  ์žˆ์œผ๋‹ˆ Grafana๋ฅผ ๋Œ€๋ถ€๋ถ„ ์‚ฌ์šฉํ•œ๋‹ค.

๋ชจ๋‹ˆํ„ฐ๋งํ•  ๋…ธ๋“œ ์„ค์ • ์ถ”๊ฐ€

global:
  scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']

prometheus.yml์„ ์„ค์ •ํ•˜๊ณ  ๋‚˜์„œ ๋„์ปค๋ฅผ ์‹คํ–‰ํ•˜์ž.

docker-compose up -d

์„œ๋น„์Šค๊ฐ€ ์‹คํ–‰๋˜๋ฉด ๋กœ์ปฌ์—์„œ ํ™•์ธํ•ด๋ณด์ž

![]({{ site.baseurl }}/assets/2019-11-25-15-25-24.png)

์ด์ œ ํ™•์ธํ•ด๋ณด์ž.

๋‹ค์Œ๊ทธ๋ฆผ์ฒ˜๋Ÿผ up์„ ๋„ฃ๊ณ  ์—”ํ„ฐ๋ฅผ ์ฒ˜๋ณด๋ฉด

![]({{ site.baseurl }}/assets/2019-11-25-15-29-07.png)

up์€ Prometheus๊ฐ€ ์ถ”๊ฐ€ํ•˜๋Š” ํŠน๋ณ„ํ•œ ํ˜•ํƒœ์˜ ๋ฉ”ํŠธ๋ฆญ์ด๋‹ค. 1์€ ์„ฑ๊ณต์ด๋ผ๋Š” ์˜๋ฏธ์ด๋‹ค.

๋ชจ๋‹ˆํ„ฐ๋ง ํ•˜๊ธฐ

  • Node Exporter ์„ค์น˜ (linux)

์ด์ œ ๋ชจ๋‹ˆํ„ฐ๋ง ํ•  ์„œ๋ฒ„๋ฅผ ์„ค์ •ํ•˜์ž. Prometheus๊ฐ€ ์š”์ฒญํ•˜๋ฉด ๋ฐ์ดํ„ฐ๋ฅผ ๋งŒ๋“ค์–ด์„œ ์ค€๋‹ค.

Node Exporter๋Š” cpu ๋ฉ”๋ชจ๋ฆฌ ๋””์Šคํฌ๊ณต๊ฐ„ ๋””์Šคํฌ i/o ๋„คํŠธ์›Œํฌ ๋Œ€์—ญํญ ๊ฐ™์€ ๋ชจ๋“  ํ‘œ์ค€ ๋ฉ”ํŠธ๋ฆญ์„ ์ œ๊ณตํ•œ๋‹ค.

๋…ธ๋“œ exporter๋Š” ๋ฐ”์ด๋„ˆ๋ฆฌ๋กœ ์„ค์น˜

wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz

tar -xvzf node_exporter-0.18.1.linux-amd64.tar.gz

cd node_exporter-0.18.1.linux-amd64/

mv node_exporter /usr/local/bin/

vi /etc/systemd/system/node_exporter.service

[Unit]
Description=Node Exporter
After=network.target

[Service]
User=root
Group=root
Type=simple
ExecStart=/usr/local/bin/node_exporter

[Install]
WantedBy=multi-user.target
systemctl daemon-reload

systemctl start node_exporter

systemctl enable node_exporter

๋ชจ๋‹ˆํ„ฐ๋ง ๋‹นํ•˜๋Š” ์„œ๋ฒ„์— ๋ฉ”ํŠธ๋ฆญ์„ ๊ฐ€์ ธ์™€๋ณด์ž.

๊ฒฐ๊ณผ๊ฐ€ ์ญ‰ ๋‚˜์˜จ๋‹ค node exporter๋Š” ๋™์ž‘ํ•œ๋‹ค. ์ด์ œ ํ”„๋กœ๋ฉ”ํ…Œ์šฐ์Šค๊ฐ€ ์ฃผ๊ธฐ์ ์œผ๋กœ ์ด๊ฑธ ๊ฐ€์ ธ์˜ค๋ฉด๋œ๋‹ค.

Prometheus ์„ค์ •์— ์ถ”๊ฐ€ํ•˜์ž.

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']

  - job_name: 'node_exporter'
    static_configs:
      - targets: ['192.168.0.101:9100']
      # - targets: ['192.168.0.101:9100','192.168.0.102:9100'] #์—ฌ๋Ÿฌ๋Œ€๋ฉด ์ด๋ ‡๊ฒŒ ์ถ”๊ฐ€ํ•˜๋ฉด๋œ๋‹ค.

Prometheus ํƒ€๊ฒŸ์— ์ถ”๊ฐ€๊ฐ€ ๋œ๊ฑด์ง€ ํ™•์ธํ•˜์ž.

node01์—์„œ ์žฌ๋ถ€ํŒ…ํ•ด๋ณด์ž ์„œ๋น„์Šค๋งŒ ๊บผ๋„ ๋จ.

ssh node01
systemctl stop node_exporter
systemctl status node_exporter
systemctl start node_exporter
systemctl status node_exporter

์ด์ œ http://localhost:9090/graph ์—์„œ up์„ ํ™•์ธํ•ด๋ณด์ž ๋‚ด๋ ค๊ฐ”๋‹ค๊ฐ€ ์˜ฌ๋ผ์˜จ๊ฒƒ์„ ํ™•์ธํ• ์ˆ˜ ์žˆ๋‹ค.

![]({{ site.baseurl }}/assets/2020-01-11-09-53-36.png)

Prometheus ์ž˜ ๋™์ž‘ํ•˜๊ณ  node exporter๋„ ์ž˜ ๋™์ž‘ํ•˜๋Š”๊ฒƒ์„ ์•Œ์ˆ˜๊ฐ€ ์žˆ๋‹ค.

์ด์ œ docker-compose๋กœ ๋งŒ๋“ค์–ด์„œ๋ณด์ž.

version: '3.7'
services:
  localhost:
    image: prom/prometheus
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
      - prometheus_data:/prometheus
    ports:
      - 9090:9090
    restart: always

volumes:
  prometheus_data: {}
docker-compose up -d

์œˆ๋„์šฐ node ๋ชจ๋‹ˆํ„ฐ๋ง

https://github.com/martinlindhe/wmi_exporter

https://grafana.com/grafana/dashboards/2129 theme

https://github.com/martinlindhe/wmi_exporter/releases ๋‹ค์šดํ›„ ์„ค์น˜ํ•˜๋ฉด ์„œ๋น„์Šค๋กœ ์„ค์น˜ ์™„๋ฃŒ

![]({{ site.baseurl }}/assets/2019-12-07-07-21-23.png)

msi downloadํ›„ ๋…ธ๋“œ์— ์„ค์น˜

์„ค์น˜ ๋…ธ๋“œ์—์„œ ๋‹ค์Œ ํ™•์ธ

์™ธ๋ถ€์—์„œ ๋‹ค์Œ ํ…Œ์ŠคํŠธ

Prometheus์— ์ถ”๊ฐ€ํ•˜์—ฌ ๋ถ™์ด์ž. 9182 ํฌํŠธ๋ฅผ ์“ด๋‹ค.

vi prometheus.yml

global:
  scrape_interval: 15s
scrape_configs:
---
- job_name: 'win_node_exporter'
  static_configs:
    - targets: ['10.1.5.40:9182', '10.1.5.57:9182']

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์œˆ๋„์šฐ๋„ ๋ชจ๋‹ˆํ„ฐ๋ง์ด ๋œ๋‹ค.

์•Œ๋ฆผ

node export node01์„๊บผ๋ณด์ž.

ssh node01 systemctl stop node_exporter

http://localhost:9090/targets ์—์„œ ์ฒดํฌํ•ด๋ณด๋ฉด ๊บผ์ง„๊ฒƒ์„ ์•Œ์ˆ˜ ์žˆ๋‹ค.

๊ทธ๋ž˜ํ”„์—์„œ up == 0 ์„ ๋„ฃ์–ด์„œ ๊บผ์ง„๊ฒƒ๋งŒ ํ™•์ธํ•ด๋ณด์ž.

1๊ฐœ๋งŒ ๋‚˜์˜จ๋‹ค.

![]({{ site.baseurl }}/assets/2019-11-25-18-48-03.png)

์ด์ œ ๋‹ค ๋œ๋“ฏ

์•Œ๋ฆผ ๊ทœ์น™ ์ถ”๊ฐ€

vi /data/git/docker/prometheus/prometheus.yml

global:
  ...
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.

rule_files:
  - "rules.yml"

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      - alertmanager:9093

vi rules.yml

groups:
  - name: example
    rules:
      - alert:InstanceDown
        expr: up == 0
        for: 1m
docker run -d -p 9090:9090 -v /data/git/docker/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml -v /data/git/docker/prometheus/rules.yml:/etc/prometheus/rules.yml --name prom prom/prometheus

http://localhost:9090/alerts

![]({{ site.baseurl }}/assets/2019-11-25-19-22-14.png)

์ด์ œ ์•Œ๋ฆผ์ด ํ™•๋ณด๊ฐ€ ๋ฌ๋‹ค.

์•Œ๋žŒ ๋งค๋‹ˆ์ € ์„ค์น˜

๋ฐ”์ด๋„ˆ๋ฆฌ์™€ ๋„์ปค๋กœ ์˜ฌ๋ฆฌ๋Š” ๋ฐฉ์‹ 2๊ฐ€์ง€๊ฐ€ ์žˆ๋‹ค. ๋„์ปค๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

ssh prometheus

vi alertmanager.yml

global:
  smtp_smarthost: 'localhost:25'
  smtp_from: 'alertmanager@example.org'
route:
  receiver: team-mails
receivers:
  - name: 'team-mails'
    email_configs:
      - to: 'teamsmiley@gmail.com'
docker run -p 9090:9090 -v /data/git/docker/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml -v /data/git/docker/prometheus/rules.yml:/etc/prometheus/rules.yml -v /data/git/docker/prometheus/alertmanager.yml:/etc/prometheus/alertmanager.yml prom/prometheus

./alertmanager๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ์ด๋ฉ”์ผ์„ ๋ฐ›๋Š”๋‹ค.

์ด์ œ ์›น๋ธŒ๋ผ์šฐ์ €๋ฅผ ํ†ตํ•ด ์„ ํ™•์ธํ•ด๋ณด๋ฉด ์•Œ์ˆ˜ ์žˆ๋‹ค.

์ฐธ๊ณ 

์ฐธ๊ณ 

https://github.com/teamsmiley/devops-public/tree/main/monitoring/2.grafana-provisioning
https://github.com/prometheus/prometheus/blob/master/documentation/examples/prometheus.yml
http://localhost:9090
https://prometheus.io/download
http://192.168.0.101:9100/metrics
https://github.com/teamsmiley/devops-public/blob/main/monitoring/6.prometheus-oauth/prometheus/prometheus.yaml
http://localhost:9090/targets
https://medium.com/@facundofarias/setting-up-a-prometheus-exporter-on-windows-b3e45f1235a5
http://localhost:9182/metrics
http://10.1.5.40:9182/metrics
https://github.com/prometheus/alertmanager/blob/master/doc/examples/simple.yml