prometheus + grafana安装部署(centos6.8)

prometheus + grafana安装部署(centos6.8)
1.Grafana介绍
Grafana是一个跨平台的开源的度量分析和可视化工具,可以通过将采集的数据查询然后可视化的展示,并及时通知。它主要有以下六大特点:

1、展示方式:快速灵活的客户端图表,面板插件有许多不同方式的可视化指标和日志,官方库中具有丰富的仪表盘插件,比如热图、折线图、图表等多种展示方式;
2、数据源:Graphite,InfluxDB,OpenTSDB,Prometheus,Elasticsearch,CloudWatch和KairosDB等;
3、通知提醒:以可视方式定义最重要指标的警报规则,Grafana将不断计算并发送通知,在数据达到阈值时通过Slack、PagerDuty等获得通知;
4、混合展示:在同一图表中混合使用不同的数据源,可以基于每个查询指定数据源,甚至自定义数据源;
5、注释:使用来自不同数据源的丰富事件注释图表,将鼠标悬停在事件上会显示完整的事件元数据和标记;
6、过滤器:Ad-hoc过滤器允许动态创建新的键/值过滤器,这些过滤器会自动应用于使用该数据源的所有查询。

一、prometheus介绍
Prometheus是一个开源的系统监控和报警的工具包,最初由SoundCloud发布。

特点:

多维数据模型(有metric名称和键值对确定的时间序列)
灵活的查询语言
不依赖分布式存储
通过pull方式采集时间序列,通过http协议传输
支持通过中介网关的push时间序列的方式
监控数据通过服务或者静态配置来发现
支持图表和dashboard等多种方式
组件:

Prometheus 主程序,主要是负责存储、抓取、聚合、查询方面。
Alertmanager 程序,主要是负责实现报警功能。
Pushgateway 程序,主要是实现接收由Client push过来的指标数据,在指定的时间间隔,由主程序来抓取。
*_exporter 这类是不同系统已经实现了的集成。
架构:

prometheus部署
1、下载安装包prometheus-1.6.2.linux-amd64.tar.gz
https://github.com/prometheus/prometheus/releases/tag/v1.6.2

2、解压

tar -xvf prometheus-1.6.2.linux-amd64.tar.gz
cd prometheus-1.6.2.linux-amd64

3、配置prometheus.yml
scrape_interval: 15s # 默认15秒到目标处抓取数据
4、启动

nohup ./prometheus -config.file=prometheus.yml &nohup /opt/prometheus-1.6.2.linux-amd64/prometheus &

5、WEB页面访问http://localhost:9090/ ,可以看到Prometheus的graph页面。

备注:参考文章 http://www.cnblogs.com/vovlie/p/Prometheus_install.html

二、grafana部署
1、下载安装
下载地址:https://grafana.com/grafana/download

wget https://dl.grafana.com/oss/release/grafana-7.0.6-1.x86_64.rpm
sudo yum install grafana-7.0.6-1.x86_64.rpm

2、启动服务

service grafana-server start

3、访问页面http://localhost:3000 ,默认账号、密码admin/admin
4、Prometheus 和 Grafana 的对接

https://prometheus.io/docs/visualization/grafana/

(dashboard id 怎么获取,grafana官方有个中央仓库,和maven仓库一样,收集了网友制作好的dashboard,每个dashboard有个唯一 id,dashboard仓库地址:https://grafana.com/dashboards)

三、mysql监控部署
在需要监控的mysql上安装 node_exporter和 mysqld_exporter

下载 https://prometheus.io/download/

tar -xvf node_exporter-0.14.0.linux-amd64.tar.gz
cd node_exporter-0.14.0.linux-amd64
nohup ./node_exporter &
tar -xvf mysqld_exporter-0.10.0.linux-amd64.tar.gz
cd mysqld_exporter-0.10.0.linux-amd64

vi .my.cnf
[client]
user=root
password=root
./mysqld_exporter -config.my-cnf=".my.cnf" &

服务端配置,文件prometheus.yml

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']
      
  - job_name: 'mysql'
    static_configs:
      - targets: ['10.10.83.162:9104']
        labels:
          instance: db-10.10.83.162

参考:
https://www.cnblogs.com/sfnz/p/6566951.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值