【Linux】【Services】【SaaS】Docker+kubernetes(12. 部署prometheus/grafana/Influxdb实现监控)
阅读原文时间:2022年02月20日阅读:3

1.简介

1.1. 官方网站:

promethos:https://prometheus.io/

grafana:https://grafana.com/

1.2. 架构图

2. 环境

2.1. 机器列表

功能与组件

机器名

Public IP

Private IP

Processor Cores

RAM

Storage

备注

DNS/NTP/Ansible/Prometheus服务器

HCTJOSINFRA01

10.30.2.81

172.16.0.81

 

 

 

 

DNS/NTP/Ansible/Prometheus服务器

HCTJOSINFRA02

10.30.2.82

172.16.0.82

 

 

 

 

2.2. 软件版本

promethos:2.1

grafana:5.0

3. 安装与配置

3.1. promethos

下载

https://github.com/prometheus/prometheus/releases/download/v2.1.0/prometheus-2.1.0.linux-amd64.tar.gz

解压

tar zxfv prometheus-2.1.0.linux-amd64.tar.gz -C /opt/prometheus/

直接后台启动

./prometheus --config.file=prometheus.yml &

3.2. exporter

常见exporter

https://prometheus.io/download/

以node_exporter为例监控机器

tar zxvf node_exporter-0.15.2.linux-amd64.tar.gz -C /opt/prometheus_exporters/

默认启动就好

/opt/prometheus_exporters/node_exporter &

修改配置文件/opt/prometheus/prometheus-2.1.0.linux-amd64/prometheus.yml

[root@hctjosinfra01 prometheus-2.1.0.linux-amd64]# grep -E -v "^[[:space:]]*$|^[[:space:]]*#" /opt/prometheus/prometheus-2.1.0.linux-amd64/prometheus.yml
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
alerting:
alertmanagers:

  • static_configs:
    • targets:
      rule_files:
      scrape_configs:
  • job_name: 'prometheus' static_configs:
    • targets: ['localhost:9090']
  • job_name: 'linux_server' static_configs:
    • targets: ['172.16.0.81:9100']
      labels:
      instance: linux_server

重启下prometheus-server

3.3. grafana

下载

https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.0.0-1.x86_64.rpm

安装

yum install grafana-5.0.0-1.x86_64.rpm

修改配置文件/etc/grafana/grafana.ini

[database]
url = mysql://grafana:grafana@172.16.0.25:3306/grafana
[security]
admin_user = admin
admin_password = admin

可以启动了

systemctl start grafana-server

输入机器IP:3000进入界面,添加数据源Prometheus(都是图形化的,就不赘述了)