Add database servers to prometheus

master
Jeff Moe 7 years ago
parent 4a80029344
commit 694191339a

@ -35,38 +35,123 @@ vim /etc/default/prometheus-node-exporter
--collector.systemd --collector.systemd
################ ################
# For MySQL servers: ##############################################################################
# For MySQL servers, on all servers:
apt install prometheus-mysqld-exporter apt install prometheus-mysqld-exporter
# On sql1, log into database:
CREATE USER 'prometheus-mysqld-exporter'@'10.42.1.0/255.255.255.0' IDENTIFIED BY 'password' WITH MAX_USER_CONNECTIONS 3;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'prometheus-mysqld-exporter'@'10.42.1.0/255.255.255.0';
FLUSH PRIVILEGES;
# On sql1 sql2 sql3 sql4 servers:
# Edit
vim /etc/default/prometheus-mysqld-exporter
# Set this line (setting correct local IP):
export DATA_SOURCE_NAME="prometheus-mysqld-exporter:password@(10.42.1.171:3306)/"
# on prom1 /etc/prometheus/prometheus.yml
- job_name: 'mysql-monitor'# Job name
static_configs:
- targets: ['10.42.1.171:9104']
labels:
alias: db1# alias name given to this instance
# Add firewall rule to sql1 sql2 sql3 sql4
#-A INPUT -s 10.22.22.0/24 -p tcp --dport 9104 -j ACCEPT
-A INPUT -s 10.42.1.0/24 -p tcp --dport 9104 -j ACCEPT
##############################################################################
# Borg exporter: # Borg exporter:
https://github.com/teemow/prometheus-borg-exporter https://github.com/teemow/prometheus-borg-exporter
https://grafana.com/dashboards/1573 https://grafana.com/dashboards/1573
##############################################################################
# Email # Email
# graylog: # graylog:
##############################################################################
# Apache: # Apache:
https://grafana.com/dashboards/4859 https://grafana.com/dashboards/4859
https://grafana.com/dashboards/4865 https://grafana.com/dashboards/4865
##############################################################################
# nginx # nginx
https://grafana.com/dashboards/6482 https://grafana.com/dashboards/6482
https://grafana.com/dashboards/4368 https://grafana.com/dashboards/4368
https://grafana.com/dashboards/6787 https://grafana.com/dashboards/6787
##############################################################################
# postgres # postgres
https://grafana.com/dashboards/3300 https://grafana.com/dashboards/3300
https://grafana.com/dashboards/455 https://grafana.com/dashboards/455
https://grafana.com/dashboards/3742 https://grafana.com/dashboards/3742
https://grafana.com/dashboards/6742 https://grafana.com/dashboards/6742
# on pg1 pg2 pg3 pg4
apt install prometheus-postgres-exporter daemon
# See /usr/share/doc/prometheus-postgres-exporter/README.Debian
vim /etc/default/prometheus-postgres-exporter
DATA_SOURCE_NAME='user=prometheus host=/run/postgresql dbname=postgres'
# The run:
sudo -u postgres psql
# In database add:
------------------------------------------------------
CREATE USER prometheus;
ALTER USER prometheus SET SEARCH_PATH TO prometheus,pg_catalog;
CREATE SCHEMA prometheus AUTHORIZATION prometheus;
CREATE FUNCTION prometheus.f_select_pg_stat_activity()
RETURNS setof pg_catalog.pg_stat_activity
LANGUAGE sql
SECURITY DEFINER
AS $$
SELECT * from pg_catalog.pg_stat_activity;
$$;
CREATE FUNCTION prometheus.f_select_pg_stat_replication()
RETURNS setof pg_catalog.pg_stat_replication
LANGUAGE sql
SECURITY DEFINER
AS $$
SELECT * from pg_catalog.pg_stat_replication;
$$;
CREATE VIEW prometheus.pg_stat_replication
AS
SELECT * FROM prometheus.f_select_pg_stat_replication();
CREATE VIEW prometheus.pg_stat_activity
AS
SELECT * FROM prometheus.f_select_pg_stat_activity();
GRANT SELECT ON prometheus.pg_stat_replication TO prometheus;
GRANT SELECT ON prometheus.pg_stat_activity TO prometheus;
------------------------------------------------------
------------------------------------------------------
# Restart
# Add firewall rule
-A INPUT -s 10.52.1.0/24 -p tcp --dport 9187 -j ACCEPT
# prometheus.yml
# Some dashboards work with this
- job_name: 'postgres'
honor_labels: true
static_configs:
- targets: ['10.52.1.91:9187', '10.52.1.92:9187', '10.52.1.93:9187', '10.52.1.94:9187']
# Other dashboards work with this
- job_name: 'postgresql'
honor_labels: true
static_configs:
- targets: ['10.52.1.91:9187', '10.52.1.92:9187', '10.52.1.93:9187', '10.52.1.94:9187']
##############################################################################
# Unbound DNS # Unbound DNS
https://grafana.com/dashboards/3930 https://grafana.com/dashboards/3930
##############################################################################
#######################################################
# libvirt_exporter # libvirt_exporter
# FAIL
go get github.com/kumina/libvirt_exporter go get github.com/kumina/libvirt_exporter
go build github.com/kumina/libvirt_exporter go build github.com/kumina/libvirt_exporter
# Then copy this binary to targets sf-001 sf-002 sf-003 sf-004 # Then copy this binary to targets sf-001 sf-002 sf-003 sf-004
@ -74,3 +159,4 @@ go build github.com/kumina/libvirt_exporter
apt install libvirt-daemon apt install libvirt-daemon
##############################################################################

Loading…
Cancel
Save