ํ”„๋กœ๋ฉ”ํ…Œ์šฐ์Šค ์„ค์น˜ ์‚ฝ์งˆ

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}']