Push Gateway Server
docker run -d -p 9091:9091 prom/pushgateway
Shell
복사
Node Server
docker run -d \
--net="host" \
--pid="host" \
-v "/:/host:ro,rslave" \
quay.io/prometheus/node-exporter:latest \
--path.rootfs=/host
Shell
복사
export PUSHGATEWAY_SERVER=http://43.201.48.75:9091 # Push Gateway 주소
export NODE_NAME=`hostname`
Shell
복사
cat << EOF > push_node_exporter_metrics.sh
#!/bin/bash
curl -s localhost:9100/metrics | curl --data-binary @- $PUSHGATEWAY_SERVER/metrics/job/node-exporter/instance/$NODE_NAME
EOF
Shell
복사
chmod +x push_node_exporter_metrics.sh
Shell
복사
sudo yum install cronie -y
sudo systemctl enable crond.service
sudo systemctl start crond.service
Shell
복사
crontab -e
# * * * * * /home-ec2-user/push_node_exporter_metrics.sh
Shell
복사
crontab -l
Shell
복사
<push-gateway IP>:<port>/metrics의 API 에서도 해당 메트릭을 확인가능하다.


