安装prometheus+grafana监控mysql redis kubernetes等
1.prometheus安装
wget https://github.com/prometheus/prometheus/releases/download/v1.5.2/prometheus-1.5.2.linux-amd64.tar.gz tar -zxvf prometheus-1.5..linux-amd64.tar.gz -C /opt/prometheus --strip-components= cd /opt/prometheus mv prometheus.yml prometheus.yml-bak # vi prometheus.yml
global:
scrape_interval: 10s
evaluation_interval: 10s scrape_configs:
- job_name: linux
static_configs:
- targets: ['192.168.0.8:9100']
labels:
instance: db-0.8 - job_name: mysql
static_configs:
- targets: ['192.168.0.8:9104']
labels:
instance: db-0.8
启动 nohup /opt/prometheus/prometheus &
web界面 http://192.168.0.15:9090/graph

2.grafana安装
wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.0.1-1480694114.x86_64.rpm
yum localinstall grafana-4.0.-.x86_64.rpm service grafana-server start
至此安装完成。
浏览器打开 http://192.168.0.15:3000 ,输入默认用户名密码 (admin/admin) 可以进入 Grafana 。
然后配置数据源:


Prometheus: URL: http://192.168.0.15:9090/
即可完成 Prometheus 和 Grafana 的对接。
3.替换grafana的dashboards
Grafana 并没有太多的配置好的图表模板,除了 Percona 开源的一些外,很多需要自行配置。
下载dashboards
(https://github.com/percona/grafana-dashboards) git clone https://github.com/percona/grafana-dashboards.git
cp -r grafana-dashboards/dashboards /var/lib/grafana/ 编辑 Grafana config vi /etc/grafana/grafana.ini [dashboards.json]
enabled = true
path = /var/lib/grafana/dashboards systemctl restart grafana-server
4.客户端安装
(1)mysql:在需要监控的mysql上安装 node_exporter和 mysqld_exporter
wget https://github.com/prometheus/node_exporter/releases/download/0.13.0/node_exporter-0.13.0.linux-amd64.tar.gz
wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.9.0/mysqld_exporter-0.9.0.linux-amd64.tar.gz tar -zxvf node_exporter-0.13..linux-amd64.tar.gz -C /opt/prometheus_exporters --strip-components=
tar -zxvf mysqld_exporter-0.9..linux-amd64.tar.gz -C /opt/prometheus_exporters --strip-components= 运行node_exporter :
nohup /opt/prometheus_exporters/node_exporter & mysqld_exporter需要连接到Mysql,所以需要Mysql的权限,我们先为它创建用户并赋予所需的权限: mysql> GRANT REPLICATION CLIENT, PROCESS ON *.* TO 'prom'@'localhost' identified by 'amnt@#*IK<1qaz';
mysql> GRANT SELECT ON performance_schema.* TO 'prom'@'localhost';
mysql> flush privileges; 创建.my.cnf文件并运行mysqld_exporter: $ cd /usr/local/services/prometheus_exporters
$ cat << EOF > .my.cnf
[client]
user=prom
password=abc123
EOF
$ nohup /opt/prometheus_exporters/mysqld_exporter -config.my-cnf=".my.cnf" &
(2).redis 在redis服务器安装node_exporter和redis_exporter
wget https://github.com/oliver006/redis_exporter/releases/download/v0.10.8/redis_exporter-v0.10.8.linux-amd64.tar.gz
wget https://github.com/prometheus/node_exporter/releases/download/0.13.0/node_exporter-0.13.0.linux-amd64.tar.gz
tar -zxvf node_exporter-0.13.0.linux-amd64.tar.gz -C /opt/prometheus_exporters --strip-components=1
tar -zxvf redis_exporter-v0.10.8.linux-amd64.tar.gz -C /opt/prometheus_exporters --strip-components=1
启动
nohup /opt/prometheus_exporters/node_exporter &
nohup /opt/prometheus_exporters/redis_exporter redis//192.168.0.17:6379 &
配置prometheus.yml 加入
- job_name: redis_exporter
static_configs:
- targets: ['192.168.0.17:9121']
下载grafana的redis的prometheus-redis_rev1.json模板
wget https://grafana.com/api/dashboards/763/revisions/1/download
在grafana中导入json模板

过一段时间就能看到图形了

(3).
kubernetes 模板配置
因为prometheus和kubernetes是结合的,所以导入模板后,直接配置prometheus.yml即可
模板下载:https://grafana.com/dashboards/315
prometheus.yml 加入以下配置 - job_name: kubernetes-nodes-cadvisor
static_configs:
- targets: ['192.168.0.19:4194','192.168.0.21:4194']
labels:
instance: kubernetes-nodes-cadvisor
kubernetes_sd_configs:
- role: node
relabel_configs:
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
metric_relabel_configs:
- action: replace
source_labels: [id]
regex: '^/machine\.slice/machine-rkt\\x2d([^\\]+)\\.+/([^/]+)\.service$'
target_label: rkt_container_name
replacement: '${2}-${1}'
- action: replace
source_labels: [id]
regex: '^/system\.slice/(.+)\.service$'
target_label: systemd_service_name
replacement: '${1}'
等待片刻可见图形:

最终prometheus配置:
# cat prometheus.yml
global:
scrape_interval: 10s
evaluation_interval: 10s scrape_configs:
- job_name: node
static_configs:
- targets: ['192.168.0.8:9100','192.168.0.19:9100','192.168.0.21:9100','192.168.0.17:9100']
labels:
instance: node - job_name: mysql
static_configs:
- targets: ['192.168.0.8:9104']
labels:
instance: db-0.8 - job_name: redis_exporter
static_configs:
- targets: ['192.168.0.17:9121'] - job_name: kubernetes-nodes-cadvisor
static_configs:
- targets: ['192.168.0.19:4194','192.168.0.21:4194']
labels:
instance: kubernetes-nodes-cadvisor
kubernetes_sd_configs:
- role: node
relabel_configs:
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
metric_relabel_configs:
- action: replace
source_labels: [id]
regex: '^/machine\.slice/machine-rkt\\x2d([^\\]+)\\.+/([^/]+)\.service$'
target_label: rkt_container_name
replacement: '${2}-${1}'
- action: replace
source_labels: [id]
regex: '^/system\.slice/(.+)\.service$'
target_label: systemd_service_name
replacement: '${1}'
参考文档:
https://segmentfault.com/a/1190000007040144
http://www.tuicool.com/articles/vEVjai
https://github.com/prometheus
dashboards模板下载:https://grafana.com/dashboards
redis模板:https://github.com/oliver006/redis_exporter
启动 nohup /opt/prometheus_exporters/redis_exporter redis//192.168.0.17:6379 &
Prometheus监控 - Alertmanager报警模块:http://blog.csdn.net/y_xiao_/article/details/50818451
安装prometheus+grafana监控mysql redis kubernetes等的更多相关文章
- [转帖]安装prometheus+grafana监控mysql redis kubernetes等
安装prometheus+grafana监控mysql redis kubernetes等 https://www.cnblogs.com/sfnz/p/6566951.html plug 的模式进行 ...
- prometheus+grafana监控mysql
prometheus+grafana监控mysql 1.安装配置MySQL官方的 Yum Repository(有mysql只需设置监控账号即可) [root@localhost ~]# wget - ...
- Prometheus+Grafana监控MySQL、Redis数据库
俗话说,没有监控的系统就是在裸奔,好的监控就是运维人员的第三只手,第三只眼.本文将使用prometheus及Grafana搭建一套监控系统来监控主机及数据库(MySQL.Redis). 1. 安装G ...
- Prometheus + Grafana 监控(mysql 和redis)
1.监控MySQL(mysqld-exporter) https://github.com/prometheus/mysqld_exporter/releases/download/v0.11.0/m ...
- 使用Prometheus+Grafana监控MySQL实践
一.介绍Prometheus Prometheus(普罗米修斯)是一套开源的监控&报警&时间序列数据库的组合,起始是由SoundCloud公司开发的.随着发展,越来越多公司和组织接受采 ...
- prometheus+grafana监控mysql最佳实践
导航 前言 环境准备 安装Docker 安装prometheus 安装mysqld_exporter prometheus采集数据 安装grafana grafana配置数据源 感谢您的阅读,预计阅读 ...
- 技术分享 | Prometheus+Grafana监控MySQL浅析
GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. 简介 Prometheus 一套开源的监控&报警&时间序列数据库的组合,通常 Kubernetes 中都会 ...
- prometheus+grafana监控Linux和kubernetes的例子
1.安装和配置prometheus tar zxvf prometheus-.linux-amd64.tar.gz -C /usr/local/ ln -sv /usr/local/prometheu ...
- [转帖]Prometheus+Grafana监控Kubernetes
原博客的位置: https://blog.csdn.net/shenhonglei1234/article/details/80503353 感谢原作者 这里记录一下自己试验过程中遇到的问题: . 自 ...
随机推荐
- python报错UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8 in position 0 解决方案
环境:mac+python 2.7 场景描述:在使用python修改excel内容修改表格内容为中文保存时报以下错误 此时已经设置了utf-8了 但保存时仍然报错错 此时将python中的中文使用un ...
- c#访问存储过程
// 2015/07/04 // 访问存储过程 using System; using System.Collections.Generic; using System.Linq; using Sys ...
- Java中显示图片的方法
最近在做一个swing小项目,其中需要把存储在硬盘中的图片文件显示出来,总结了如下方法: 1. Graphics g = getGraphics();String name = "E:/Ca ...
- Trick 小记
1.\[P(A|BC) = \frac{P(AB|C)}{P(B|C)}\] 2. In EM algorithm, the usual expectation function can be wri ...
- 《经久不衰的Spring框架:@ResponseBody 中文乱码》
问题背景 本文并不是介绍@ResponseBody注解,也不是中文乱码问题的大汇总笔记,这些网上都有很多内容了.这边仅对几年前,一个卡壳了挺久时间的问题的解决过程做一个记录,以警惕自己,达到自醒得目的 ...
- 详解JavaScript闭包
要想完全明白JavaScript的闭包,要先明白js中的一些基础原理,然后我再给出一些例子来讲解闭包. 在执行JavaScript时会创建一个执行环境(excution context),执行环境定义 ...
- 每天一个Linux命令(01)--ls命令
ls命令是Linux下最常用的命令.ls命令就是list的缩写,缺省下ls用来打印当前目录的清单,如果ls指定其他目录,那么就会显示指定目录里的文件及文件夹清单.通过ls命令不仅可以查看Linux文件 ...
- HttpClient 工具
什么是httpclient HTTP 协议可能是现在 Internet 上使用得最多.最重要的协议了,越来越多的 Java 应用程序需要直接通过 HTTP 协议来访问网络资源.虽然在 JDK 的 ja ...
- 利刃 MVVMLight 4:绑定和绑定的各种使用场景
一.绑定: 主要包含元素绑定和非元素绑定两种. 1.元素绑定,是绑定的最简单形式,源对象是WPF的元素,并且源对象的属性是依赖项属性. 根据我们之前的知识 ,依赖项属性具有内置的更改通知支持.所以当我 ...
- Spring Cache扩展:注解失效时间+主动刷新缓存
*:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* ...