博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
prometheus+grafana
阅读量:6906 次
发布时间:2019-06-27

本文共 2917 字,大约阅读时间需要 9 分钟。

prometheus 是由SoundCloud开发的开源监控报警系统和时序列数据库(TSDB),prometheus是一个监控采集与数据存储框架(监控server端),具体采集什么数据依赖于具体的exporter(监控client端)

grafana是一个高颜值的监控绘图程序,也是一个可视化面板(Dashboard),grafana的厉害之处除了高颜值,还支持多种数据源(支持Graphite、zabbix、InfluxDB、Prometheus和OpenTSDB作为数据源)、支持灵活丰富的dashboard配置选项

一、安装prometheus
  • prometheus+grafana
  1. prometheus程序包
  2. node_exporter:监控主机磁盘、内存、CPU等硬件性能指标的采集程序包
  3. mysql_exporter:监控mysql各种性能指标的采集程序包
  4. alertmanager: 监控告警
1、安装prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.5.0/prometheus-2.5.0.linux-amd64.tar.gztar -zxvf prometheus-2.5.0.linux-amd64.tar.gz -C /data/mv /data/prometheus-2.5.0.linux-amd64 /data/prometheus#依次下载并解压node_exporter、mysql_exporter
  • 配置prometheus
  • 进入prometheus目录,配置prometheus.yml配置文件(要注意yml缩进语法规则)
    prometheus+grafana
# 规则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:9090
  • 启动prometheus进程

    /data/prometheus/prometheus  --storage.tsdb.retention=30d &# 30d表示prometheus只保留30天以内的数据

    控制台查看

    http://172.20.2.214:9090#访问,点击Status->Targets,查看刚prometheus.yml配置文件创建的job_name

    prometheus+grafana

  • 添加系统服务启动脚本
2、安装grafana
  • 下载安装包
    https://grafana.com/grafana/download# grafana程序包https://github.com/percona/grafana-dashboards/releases# grafana-dashboards包wget https://github.com/percona/grafana-dashboards/archive/v1.16.0.tar.gz
  • 解压安装包
    wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.3.4-1.x86_64.rpmyum localinstall grafana-5.3.4-1.x86_64.rpmsystemctl start grafana-server
  • 配置grafana

a、打开grafana页面(默认账户密码:admin/admin,默认端口3000),配置数据来源。

prometheus+grafana

b、点击+Add data source,HTTP的URL填写prometheus服务所在的服务器ip及服务端口,然后点击保存并测试。

prometheus+grafana

  • grafana中导入grafana-dashboards

    解压grafana-dashboards包,该包提供了大量的json格式文件的grafana dashboards,根据需要自行选择。
    prometheus+grafana

  • grafana页面中,导入需要的json文件
    prometheus+grafana
    prometheus+grafana
3、监控节点部署
  • 添加主机监控

a、添加prometheus主机为例,解压exporter压缩包

tar zxvf node_exporter-0.15.2.linux-amd64.tarmv node_exporter-0.15.2.linux-amd64 node_exporter

b、启动node_exporter程序

cd node_exporternohup ./node_exporter &

c、配置prometheus.yml文件,如果其中已定义了监控主机的配置文件host.yml,则只需把主机IP信息填入即可动态生效。

prometheus+grafana

如果需要在添加新的实例,可直接把实例IP放在同一个targets下即可。

d、添加mysql监控

tar -zxvf mysqld_exporter-0.11.0.linux-amd64.tar.gz
  • 配置
    监控数据库需要的主机IP、数据库端口、数据库帐号和密码的环境变量(注意:该账号需要单独创建,需要对所有库所有表至少具有PROCESS, REPLICATION CLIENT, SELECT权限)
  • 启动exporter
    nohup ./mysqld_exporter &

注意事项:如果grafana中没获取到数据,可检查配置的Data Sources中的name是否与监控项的一致

转载于:https://blog.51cto.com/somethingshare/2381264

你可能感兴趣的文章
python 的urlparse学习
查看>>
vmtouch命令 -
查看>>
spring boot 实际应用(一) 内置tomcat 实现JMX配置
查看>>
MacOS X APK 最新版本 反编译
查看>>
SharePOint 2010 Mysettings 不能编辑用户信息
查看>>
Spring Boot打包部署和环境配置
查看>>
javascript基本语法总结
查看>>
【算法学习笔记】22.算法设计初步 二分查找 上下界判断
查看>>
451. 根据字符出现频率排序
查看>>
网易面试题:和为n连续正数序列
查看>>
mysql 数据类型
查看>>
C语言 指针练习-直接插入排序法
查看>>
2.Java实现基于SOAP的XML文档网络传输及远程过程调用(RPC)-
查看>>
7.zookeeper集群搭建(windows环境下)
查看>>
spring中aop的注解实现方式简单实例
查看>>
Java发送邮件Utils
查看>>
JFreeChart与struts2整合实例
查看>>
利用Arraylist数组简单实现随机双色球Demo
查看>>
使用OpenCV&&C++进行模板匹配
查看>>
P3007 [USACO11JAN]大陆议会The Continental Cowngress(2-SAT)
查看>>