πŸ“κΈ°λ‘

ν”„λ‘œλ©”ν…Œμš°μŠ€ μ„€μΉ˜ μ‚½μ§ˆ

Hugehoo 2023. 5. 21. 16:06

 

 

ssh μ„œλ²„μ—μ„œ λ„μ»€λ‘œ ν”„λ‘œλ©”ν…Œμš°μŠ€λ₯Ό μ‹€ν–‰ν•˜λŠ” κ³Όμ •μ—μ„œ μ§€μ†μ μœΌλ‘œ μ—λŸ¬κ°€ λ°œμƒν–ˆλ‹€. 

μ•„λž˜ λͺ…λ Ήμ–΄λ‘œ ν”„λ‘œλ©”ν…Œμš°μŠ€ μ»¨ν…Œμ΄λ„ˆλ₯Ό μ‹€ν–‰(μ‹œλ„)ν–ˆλ‹€.

docker run -d -p 9090:9090 -v /etc/prometheus:/etc/prometheus prom/prometheus

도컀 μ»¨ν…Œμ΄λ„ˆκ°€ μ œλŒ€λ‘œ μ‹€ν–‰λ˜μ§€ μ•Šμ€ κ±Έ 보고 docker logs {container name} λͺ…λ Ήμ–΄λ‘œ 둜그λ₯Ό 확인함

ts=2023-05-21T06:48:25.063Z caller=main.go:479 level=error msg="Error loading config (--config.file=/etc/prometheus/prometheus.yml)" file=/etc/prometheus/prometheus.yml err="parsing YAML file /etc/prometheus/prometheus.yml: \"http://{host-ip}:8080\" is not a valid hostname"

 

 

prometheus.yml

ssh μ„œλ²„μ— μž‘μ„±ν•œ prometheus.yml νŒŒμΌμ€ μ•„λž˜μ™€ κ°™λ‹€.

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: prometheus
    static_configs:
      - targets: ['http://{host-ip}:8080'] <<< http:// λ₯Ό μ§€μ›Œμ£Όμž
        metrics_path: '/actuator/prometheus' <<< 이걸 μ§€μ›Œμ£Όμž

 

μ •λ¦¬ν•˜λ©΄ http:// λ₯Ό μ§€μ›Œμ£Όκ³  metrics_path 라인도 μ‚­μ œν–ˆλ‹€. 

μ•„λž˜λŠ” prometheus.yml 의 μ΅œμ’… μˆ˜μ •λ³Έμ΄λ‹€.

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: prometheus
    static_configs:
      - targets: ['{host-ip}:{port}']