pushgatewayをインストールする
code:cmd.sh
cd /tmp
tar zxvf pushgateway-0.9.0.linux-amd64.tar.gz
cd pushgateway-0.9.0.linux-amd64/
sudo mv pushgateway /usr/local/
sudo vi /lib/systemd/system/pushgateway.service
code:/lib/systemd/system/pushgateway.service
Description=pushgateway for Prometheus
Restart=always
User=prometheus
ExecStart=/usr/local/pushgateway
ExecReload=/bin/kill -HUP $MAINPID
TimeoutStopSec=20s
SendSIGKILL=no
WantedBy=multi-user.target
code:cmd.sh
sudo systemctl enable pushgateway.service
sudo systemctl start pushgateway.service
# ufwでポートを閉じてるときは開けておく
sudo ufw allow 9091/tcp
code:cmd.sh
sudo vi /etc/prometheus/prometheus.yml
code:/etc/prometheus/prometheus.yml
(略)
- job_name: pushgateway
metrics_path: '/metrics'
scheme: http
static_configs:
- targets: [
'ホスト:9091'
]
code:cmd.sh
sudo systemctl reload prometheus