This is the fifth day of my participation in Gwen Challenge

Prometheus is an open source monitoring and alarm system and time series database (TSDB) developed by SoundCloud. Prometheus is a monitoring collection and data storage framework (monitoring server) that relies on its client, Which is referred to as “Mine”.

Grafana is a high appearance level monitoring and drawing application that is also a visual Dashboard. It also supports multiple data sources (Including Graphite, Zabbix, InfluxDB, Prometheus, and OpenTSDB) and flexible dashboard configuration options

Install Prometheus
  • prometheus.io/download/

  1. Prometheus package
  2. Node_exporter: a collection package that monitors host hardware performance indicators, such as disks, memory, and cpus
  3. Mysql_exporter: a collection package that monitors mysql performance indicators
  4. Alertmanager: monitors alarms
1. Install Prometheus
Wget tar ZXVF - https://github.com/prometheus/prometheus/releases/download/v2.5.0/prometheus-2.5.0.linux-amd64.tar.gz Linux -amd64 /data/ metheus -c /data/ mv /data/ Prometheus -2.5.0. Linux -amd64 /data/ Prometheus Download and unpack node_exporter and mysql_exporter in sequenceCopy the code
  • Configuration Prometheus
  • Go to the Prometheus directory and configure the Prometheus. Yml configuration file (note the yML indent syntax)

Global: alerting: AlertManagers: -static_configs: -targets: rule_files: scrape_configs: -file_sd_configs: - files: - host.yml job_name: Host metrics_path: /metrics relabel_configs: - source_labels: [__address__] regex: (.*) target_label: instance replacement: $1 - source_labels: [__address__] regex: (.*) target_label: __address__ replacement: $1:9100 - file_sd_configs: - files: - mysql.yml job_name: MySQL metrics_path: /metrics relabel_configs: - source_labels: [__address__] regex: (.*) target_label: instance replacement: $1 - source_labels: [__address__] regex: (.*) target_label: __address__ replacement: $1:9104 - job_name: prometheus static_configs: - targets: - localhost:9090Copy the code
  • Start the Prometheus process
/ data/Prometheus, Prometheus -- storage. TSDB. Retention = 30 d & # 30 d said Prometheus only keep within 30 days of dataCopy the code

Console view

http://172.20.2.214:9090 # Click on Status->Targets to check the job_name created in the promethes. yml configuration fileCopy the code

  • Add the system service startup script
Install Grafana
  • Downloading the Installation package
https://grafana.com/grafana/download # grafana package https://github.com/percona/grafana-dashboards/releases # Grafana - dashboards wget HTTP: / / https://github.com/percona/grafana-dashboards/archive/v1.16.0.tar.gzCopy the code
  • Decompress the installation package
Wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.3.4-1.x86_64.rpm yum localinstall Grafana 5.3.4-1. X86_64. RPM systemctl start grafana - serverCopy the code
  • Configuration grafana

aOpen grafana page (default account password: admin/admin, default port 3000) and configure the data source.

bClick +Add Data Source, enter the IP address and service port of the Prometheus server for the HTTP URL, and click Save and test.

  • Import grafana-dashboards into grafana

Unpack the Grafana-DashBoards package, which provides a large number of Grafana Dashboards for JSON-formatted files, as needed.

  • On the Grafana page, import the REQUIRED JSON file

3. Monitor node deployment
  • Adding Host Monitoring

A. Add the Prometheus host and decompress the Prometheus compression package

Tar ZXVF node_extude-0.15.2.linux-amd64. tar mv node_extude-0.15.2.linux-amd64. node_extude-0.15.2.linux-amd64. node_extude-0.15.2.linux-amd64. node_extude-0.15.2.linux-amd64Copy the code

B. Start the node_exporter program

cd node_exporter
nohup ./node_exporter &
Copy the code

cConfigure the promethe. yml file. If the host configuration file host.yml has been defined in the promethe. yml file, enter the host IP address to dynamically take effect.

If you need to add a new instance, just put the IP address of the instance under the same targets.

D. Add mysql monitor

The tar - ZXVF mysqld_exporter - 0.11.0. Linux - amd64. Tar. GzCopy the code
  • configuration

Environment variables for host IP, database port, database account, and password needed to monitor the database (note: this account needs to be created separately and must have at least PROCESS, REPLICATION CLIENT, and SELECT permissions for all tables in all libraries)

  • Start the exporter
nohup ./mysqld_exporter &
Copy the code

Note: If no Data is obtained in grafana, check whether name in Data Sources is the same as that in the monitoring item