🎀 prometheus(ν”„λ‘œλ©”ν…Œμš°μŠ€) μ„€μΉ˜ 및 μ‹€ν–‰

기운찬곰·2020λ…„ 8μ›” 28일
1

prometheus

λͺ©λ‘ 보기
2/2
post-thumbnail

μ΄ˆλ³΄κ°œλ°œμžκ°€ λ°°μš°λŠ” λ‹¨κ³„μ—μ„œμ˜ 포슀트 κΈ€μž…λ‹ˆλ‹€. λΆ€μ‘±ν•œ 점이 많이 μžˆμ„ 수 μžˆμŠ΅λ‹ˆλ‹€. μ΄ν•΄ν•΄μ£Όμ„Έμš”..πŸ˜‚πŸ˜‚


πŸš€ μ‹œμž‘μ— μ•žμ„œμ„œ...

이번 μ‹œκ°„μ—λŠ” ν”„λ‘œλ©”ν…Œμš°μŠ€λ₯Ό μ„€μΉ˜ν•˜κ³  μ‹€ν–‰ν•΄λ³΄λŠ” μ‹œκ°„μ„ 갖도둝 ν•˜κ² μŠ΅λ‹ˆλ‹€. μ €λŠ” AWS t2.microλ₯Ό μ‚¬μš©ν•΄μ„œ λ¦¬λˆ…μŠ€ ν™˜κ²½μ—μ„œ ν…ŒμŠ€νŠΈλ₯Ό μ§„ν–‰ν–ˆμŠ΅λ‹ˆλ‹€.


ν”„λ‘œλ©”ν…Œμš°μŠ€ μ‹€ν–‰

1단계. ν”„λ‘œλ©”ν…Œμš°μŠ€ λ‹€μš΄

https://prometheus.io/download/

$ wget https://github.com/prometheus/prometheus/releases/download/v2.20.1/prometheus-2.20.1.linux-amd64.tar.gz

버전은 ν˜„μž¬ 2.20.1 κΈ°μ€€μœΌλ‘œ μ§„ν–‰ν–ˆμŠ΅λ‹ˆλ‹€. 참고둜 wget은 μ›Ή μ„œλ²„λ‘œλΆ€ν„° μ½˜ν…μΈ λ₯Ό κ°€μ Έμ˜€λŠ” 컴퓨터 ν”„λ‘œκ·Έλž¨μœΌλ‘œ 이라고 λ³΄μ‹œλ©΄ λ©λ‹ˆλ‹€.


2단계. μ••μΆ•ν•΄μ œ

$ tar zxvf prometheus-2.20.1.linux-amd64.tar.gz

3단계. 이동 ν›„ 파일 λ‚΄μš© 확인

$ cd prometheus-2.20.1.linux-amd64/
$ nano prometheus.yml
# my global config
global:
  scrape_interval:     10s # Set the scrape interval to every 10 seconds. Default is every 1 minute.
  evaluation_interval: 10s # Evaluate rules every 10 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.                                                                                        
    static_configs:
    - targets: ['localhost:9090']
  

μ•„λ§ˆ μ²˜μŒμ—λŠ” μ΄λ ‡κ²Œ λ˜μ–΄μžˆμ„ κ²λ‹ˆλ‹€.

  • global (기본적인 μ „μ—­μ„€μ •)

    • scrape_interval : μ–Όλ§ˆλ‚˜ 자주 λ©”νŠΈλ¦­(targets)을 μˆ˜μ§‘ν• μ§€ μ„€μ •. κΈ°λ³Έ 1λΆ„
    • evaluation_interval : μ–Όλ§ˆλ‚˜ 자주 κ·œμΉ™(rules)을 평가할지 μ„€μ •. κΈ°λ³Έ 1λΆ„
  • scrape_configs (λ©”νŠΈλ¦­μ„ μˆ˜μ§‘ν•  μ—”λ“œν¬μΈνŠΈλ‘œ μ—¬κΈ°μ„œλŠ” prometheus μ„œλ²„ μžμ‹ μ„ κ°€λ¦¬ν‚€λŠ” 섀정을 ν–ˆλ‹€. μ—¬λŸ¬κ°œ 섀정이 κ°€λŠ₯ν•˜λ‹€.)

    • job_name : 작 이름 μ„€μ •
    • static_config : κΈμ–΄ν•˜λŠ” 방법에 λŒ€ν•œ λͺ©ν‘œ 및 νŒŒλΌλ―Έν„° μ„ΈνŠΈλ₯Ό 지정.

PrometheusλŠ” μ΄λŸ¬ν•œ λŒ€μƒμ—μ„œ `λ©”νŠΈλ¦­ HTTP μ—”λ“œ 포인트`λ₯Ό `슀크랩`ν•˜μ—¬ λͺ¨λ‹ˆν„°λ§ λŒ€μƒμ—μ„œ `λ©”νŠΈλ¦­μ„ μˆ˜μ§‘`ν•©λ‹ˆλ‹€. PrometheusλŠ” μžμ‹ μ— λŒ€ν•΄ λ™μΌν•œ λ°©μ‹μœΌλ‘œ 데이터λ₯Ό λ…ΈμΆœν•˜κΈ° λ•Œλ¬Έμ— μžμ‹ μ˜ μƒνƒœλ₯Ό 긁어 λͺ¨μœΌκ³  λͺ¨λ‹ˆν„°λ§ ν•  μˆ˜λ„ μžˆμŠ΅λ‹ˆλ‹€. μžμ‹ μ— λŒ€ν•œ λ°μ΄ν„°λ§Œ μˆ˜μ§‘ν•˜λŠ” Prometheus μ„œλ²„λŠ” μ‹€μ œλ‘œλŠ” 그닀지 μœ μš©ν•˜μ§€ μ•Šμ§€λ§Œ 쒋은 μ‹œμž‘ μ˜ˆμž…λ‹ˆλ‹€.

(μ—¬κΈ°μ„œ μ•Œ 수 μžˆλŠ” 것은 PrometheusλŠ” λ©”νŠΈλ¦­μ„ μˆ˜μ§‘ν•˜λŠ” 역할을 ν•˜λŠ” λ™μ‹œμ—, μžμ‹ μ΄ μ΅μŠ€ν¬ν„° 역할을 λ³‘ν–‰ν•΄μ„œ μˆ˜ν–‰ ν•  수 μžˆλ‹€λŠ” 점인듯 ν•©λ‹ˆλ‹€.)


4단계. μ‹€ν–‰

$ ./prometheus

ν”„λ‘œλ©”ν…Œμš°μŠ€ μ„œλ²„λ₯Ό μ‹€ν–‰ν•˜λ©΄ 총 두 가지 μ‚¬μ΄νŠΈμ— μ ‘κ·Όν•  수 μžˆμŠ΅λ‹ˆλ‹€.

μ²«λ²ˆμ§ΈλŠ” http://μžμ‹ μ˜ipμ£Όμ†Œ:9090/metrics μž…λ‹ˆλ‹€. ν”„λ‘œλ©”ν…Œμš°μŠ€λŠ” μ•„λž˜μ™€ 같은 λ©”νŠΈλ¦­μ„ μˆ˜μ§‘ν•˜κ²Œ λ©λ‹ˆλ‹€.


λ‘λ²ˆμ§Έλ‘œλŠ” http://μžμ‹ μ˜ipμ£Όμ†Œ:9090/ μž…λ‹ˆλ‹€. μ—¬κΈ°μ„œλŠ” PromQL을 μ¨μ„œ λ©”νŠΈλ¦­ μ€‘μ—μ„œ λ‚΄κ°€ μ›ν•˜λŠ” 정보λ₯Ό κ°€μ Έμ˜¬ 수 μžˆμŠ΅λ‹ˆλ‹€.

Targets 메뉴λ₯Ό 듀어가보면 job이 prometheus이고 μ’€ 전에 봀던 /metrics이 endpoint인 것을 μ•Œ 수 μžˆμŠ΅λ‹ˆλ‹€.


마침

λ‹€μŒμ‹œκ°„μ—λŠ” λ©”νŠΈλ¦­μ— λŒ€ν•œ ꡬ쑰 μ„€λͺ…κ³Ό ꡬ쑰λ₯Ό μ΄ν•΄ν•œ λ‹€μŒ PromQL을 μ‚¬μš©ν•΄λ³΄λŠ” μ‹œκ°„μ„ 갖도둝 ν•˜κ² μŠ΅λ‹ˆλ‹€.

μ°Έκ³ λ¬Έν—Œ

profile
배움을 μ’‹μ•„ν•©λ‹ˆλ‹€. μƒˆλ‘œμš΄ 것을 μ’‹μ•„ν•©λ‹ˆλ‹€.

1개의 λŒ“κΈ€

comment-user-thumbnail
2022λ…„ 5μ›” 13일

κ°œμΆ”

λ‹΅κΈ€ 달기