textfile collector
sample ์ ๋ณผ์์๋ ๊ณณ
https://github.com/prometheus-community/node-exporter-textfile-collector-scripts
์ฌ๊ธฐ์ ๋๋ถ๋ถ ์คํฌ๋ฆฝํธ๋ฅผ ์ฐพ์์ ์๋ค.
๊ฐ๋ต์ ์ธ ์ค๋ช
๋ด๊ฐ ํน์ ํด๋์ xxx.prom ํ์ผ์ ๋ง๋ค๋ฉด node-exporter ๊ฐ ํด๋น ํ์ผ์ ์ฝ์ด์ prometheus ์์ ์์งํ ์ ์๊ฒ ํด์ค๋ค.
xxx.prom์ ๋ฐ๋ก ๋ง๋ค์ง ๋ง๊ณ ์์ํ์ผ๋ก ๋ง๋ค์ด๊ณ ๋ํ prom์ผ๋ก ๋ณต์ฌ๋ฅผ ํ๋๊ฒ ์ผ๋ฐ์ ์ธ ์ฌ์ฉ๋ฐฉ์์ด๋ค ์๋๋ฉด xxx.prom ํ์ผ์ด ์์ฑ๋์ง ์์ ์ํ์์ prometheus๊ฐ ์ฝ์ผ๋ฉด ์ค๋ฅ๊ฐ ๋ฐ์ํ๊ธฐ ๋๋ฌธ์ด๋ค.
์์
mkdir -p /tmp/textfile
# $$ ๋ ํ์ฌ pid๋ฅผ ์๋ฏธํ๋ค. ๊ทธ๋ฌ๋ฏ๋ก ํ์ฌ pid๋ฅผ ํ์ผ๋ช
์ ๋ฃ์ด์ ์ค๋ณต์ ๋ฐฉ์งํ๋ค.
echo my_custom_metric $(date +%s) > /tmp/textfile/my_custom_metric.prom.$$
cat my_custom_metric.prom.67931
> my_custom_metric 1705297858
mv /tmp/textfile/my_custom_metric.prom.$$ /tmp/textfile/my_custom_metric.prom
node-exporter ์คํ
node_exporter --collector.textfile.directory="/tmp/textfile"
ํ์ธ
curl localhost:9100/metrics | grep my_custom_metric
๋ณด์ธ๋ค.
ํฌ๋ก ํญ์ผ๋ก ๊ณ์ ๋ฐ์ดํฐ๋ฅผ ์จ์ฃผ๋ฉด ๋๋ค.
๊ผญ ํ๋ก๋ฉํ ์ฐ์ค ๋ฐ์ดํฐ ํํ๋ก ์จ์ค์ผํ๋ค.
Last updated
Was this helpful?