prometheus
This is an old revision of the document!
Table of Contents
Prometheus monitoring
- Grafana prometheus dashboard: https://grafana.com/grafana/dashboards/1860
- Grafana prometheus percona mysqld dashboard: https://grafana.com/grafana/dashboards/7362
Agent node_exporter install
sudo useradd node_exporter -s /sbin/nologin wget https://github.com/prometheus/node_exporter/releases/download/v*/node_exporter-*.*-amd64.tar.gz tar xvfz node_exporter-*.*-amd64.tar.gz sudo cp node_exporter-*.*-amd64/node_exporter /usr/sbin/
Create a systemd service file /etc/systemd/system/node_exporter.service
:
[Unit] Description=Node Exporter [Service] User=node_exporter EnvironmentFile=/etc/sysconfig/node_exporter ExecStart=/usr/sbin/node_exporter $OPTIONS [Install] WantedBy=multi-user.target
Create a sysconfig file:
sudo mkdir -p /etc/sysconfig sudo echo "OPTIONS=\"--collector.textfile.directory /var/lib/node_exporter/textfile_collector\"" > /etc/sysconfig/node_exporter
Reload systemd configuration and configure node_exporter to auto-start on system boot:
sudo systemctl daemon-reload sudo systemctl enable node_exporter sudo systemctl start node_exporter
Once the Node Exporter is installed, verify that metrics are being exported:
curl http://localhost:9100/metrics
Agent mysqld_exporter install
Prepare MySQL user for agent:
GRANT REPLICATION CLIENT, PROCESS ON *.* TO 'mysqld_exporter'@'localhost' IDENTIFIED BY 'My_Secure_Password'; GRANT SELECT ON performance_schema.* TO 'mysqld_exporter'@'localhost'; FLUSH PRIVILEGES;
Install mysqld_exporter:
wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz tar zxvf mysqld_exporter-0.12.1.linux-amd64.tar.gz cd mysqld_exporter-0.12.1.linux-amd64 chown prometheus. mysqld_exporter mv mysqld_exporter /usr/local/bin/ cd .. rm -rf mysqld_exporter-0.12.1.linux-amd64*
Create a systemd service file /etc/systemd/system/mysqld_exporter.service
:
[Unit] Description=MySQL Exporter Service Wants=network.target After=network.target [Service] User=prometheus Group=prometheus Environment="DATA_SOURCE_NAME=mysqld_exporter:password@unix(/var/run/mysqd/mysqld.sock)" Type=simple ExecStart=/usr/local/bin/mysqld_exporter Restart=always [Install] WantedBy=multi-user.target
Reload systemd configuration and configure mysqld_exporter to auto-start on system boot:
sudo systemctl daemon-reload sudo systemctl enable mysqld_exporter sudo systemctl start mysqld_exporter
prometheus.1569784417.txt.gz · Last modified: 2019/09/29 22:13 by dreiggy