安装prometheus+grafana监控mysql redis kubernetes等

  1. https://www.cnblogs.com/sfnz/p/6566951.html
  2.  
  3. plug 的模式进行处理.

1.prometheus安装

  1. wget https://github.com/prometheus/prometheus/releases/download/v1.5.2/prometheus-1.5.2.linux-amd64.tar.gz
  2.  
  3. tar -zxvf prometheus-1.5.2.linux-amd64.tar.gz -C /opt/prometheus --strip-components=1
  4.  
  5. cd /opt/prometheus
  6.  
  7. mv prometheus.yml prometheus.yml-bak
  8.  
  9. # vi prometheus.yml
  10. global:
  11. scrape_interval: 10s
  12. evaluation_interval: 10s
  13.  
  14. scrape_configs:
  15. - job_name: linux
  16. static_configs:
  17. - targets: ['192.168.0.8:9100']
  18. labels:
  19. instance: db-0.8
  20.  
  21. - job_name: mysql
  22. static_configs:
  23. - targets: ['192.168.0.8:9104']
  24. labels:
  25. instance: db-0.8

启动 nohup /opt/prometheus/prometheus &

web界面 http://192.168.0.15:9090/graph

2.grafana安装

  1. wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.0.1-1480694114.x86_64.rpm
  2. yum localinstall grafana-4.0.1-1480694114.x86_64.rpm
  3.  
  4. 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 开源的一些外,很多需要自行配置。

  1. 下载dashboards
  2. (https://github.com/percona/grafana-dashboards)
  3.  
  4. git clone https://github.com/percona/grafana-dashboards.git
  5. cp -r grafana-dashboards/dashboards /var/lib/grafana/
  6.  
  7. 编辑 Grafana config
  8.  
  9. vi /etc/grafana/grafana.ini
  10.  
  11. [dashboards.json]
  12. enabled = true
  13. path = /var/lib/grafana/dashboards
  14.  
  15. systemctl restart grafana-server

4.客户端安装

(1)mysql:在需要监控的mysql上安装 node_exporter和 mysqld_exporter

  1. wget https://github.com/prometheus/node_exporter/releases/download/0.13.0/node_exporter-0.13.0.linux-amd64.tar.gz
  2. wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.9.0/mysqld_exporter-0.9.0.linux-amd64.tar.gz
  3.  
  4. tar -zxvf node_exporter-0.13.0.linux-amd64.tar.gz -C /opt/prometheus_exporters --strip-components=1
  5. tar -zxvf mysqld_exporter-0.9.0.linux-amd64.tar.gz -C /opt/prometheus_exporters --strip-components=1
  6.  
  7. 运行node_exporter
  8. nohup /opt/prometheus_exporters/node_exporter &
  9.  
  10. mysqld_exporter需要连接到Mysql,所以需要Mysql的权限,我们先为它创建用户并赋予所需的权限:
  11.  
  12. mysql> GRANT REPLICATION CLIENT, PROCESS ON *.* TO 'prom'@'localhost' identified by 'amnt@#*IK<1qaz';
  13. mysql> GRANT SELECT ON performance_schema.* TO 'prom'@'localhost';
  14. mysql> flush privileges;
  15.  
  16. 创建.my.cnf文件并运行mysqld_exporter
  17.  
  18. $ cd /usr/local/services/prometheus_exporters
  19. $ cat << EOF > .my.cnf
  20. [client]
  21. user=prom
  22. password=abc123
  23. EOF
  24. $ nohup /opt/prometheus_exporters/mysqld_exporter -config.my-cnf=".my.cnf" &

(2).redis 在redis服务器安装node_exporter和redis_exporter

  1. wget https://github.com/oliver006/redis_exporter/releases/download/v0.10.8/redis_exporter-v0.10.8.linux-amd64.tar.gz
  1. 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 加入

  1. - job_name: redis_exporter
  2. static_configs:
  3. - 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

  1. prometheus.yml 加入以下配置
  2.  
  3. - job_name: kubernetes-nodes-cadvisor
  4. static_configs:
  5. - targets: ['192.168.0.19:4194','192.168.0.21:4194']
  6. labels:
  7. instance: kubernetes-nodes-cadvisor
  8. kubernetes_sd_configs:
  9. - role: node
  10. relabel_configs:
  11. - action: labelmap
  12. regex: __meta_kubernetes_node_label_(.+)
  13. metric_relabel_configs:
  14. - action: replace
  15. source_labels: [id]
  16. regex: '^/machine\.slice/machine-rkt\\x2d([^\\]+)\\.+/([^/]+)\.service$'
  17. target_label: rkt_container_name
  18. replacement: '${2}-${1}'
  19. - action: replace
  20. source_labels: [id]
  21. regex: '^/system\.slice/(.+)\.service$'
  22. target_label: systemd_service_name
  23. replacement: '${1}'

等待片刻可见图形:

最终prometheus配置:

  1. # cat prometheus.yml
  2. global:
  3. scrape_interval: 10s
  4. evaluation_interval: 10s
  5.  
  6. scrape_configs:
  7. - job_name: node
  8. static_configs:
  9. - targets: ['192.168.0.8:9100','192.168.0.19:9100','192.168.0.21:9100','192.168.0.17:9100']
  10. labels:
  11. instance: node
  12.  
  13. - job_name: mysql
  14. static_configs:
  15. - targets: ['192.168.0.8:9104']
  16. labels:
  17. instance: db-0.8
  18.  
  19. - job_name: redis_exporter
  20. static_configs:
  21. - targets: ['192.168.0.17:9121']
  22.  
  23. - job_name: kubernetes-nodes-cadvisor
  24. static_configs:
  25. - targets: ['192.168.0.19:4194','192.168.0.21:4194']
  26. labels:
  27. instance: kubernetes-nodes-cadvisor
  28. kubernetes_sd_configs:
  29. - role: node
  30. relabel_configs:
  31. - action: labelmap
  32. regex: __meta_kubernetes_node_label_(.+)
  33. metric_relabel_configs:
  34. - action: replace
  35. source_labels: [id]
  36. regex: '^/machine\.slice/machine-rkt\\x2d([^\\]+)\\.+/([^/]+)\.service$'
  37. target_label: rkt_container_name
  38. replacement: '${2}-${1}'
  39. - action: replace
  40. source_labels: [id]
  41. regex: '^/system\.slice/(.+)\.service$'
  42. target_label: systemd_service_name
  43. 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

欢迎加入python/Django群:480058958 喜欢读书的人可加生活.读书.新知群:475749546

[转帖]安装prometheus+grafana监控mysql redis kubernetes等的更多相关文章

  1. 安装prometheus+grafana监控mysql redis kubernetes等

    1.prometheus安装 wget https://github.com/prometheus/prometheus/releases/download/v1.5.2/prometheus-1.5 ...

  2. prometheus+grafana监控mysql

    prometheus+grafana监控mysql 1.安装配置MySQL官方的 Yum Repository(有mysql只需设置监控账号即可) [root@localhost ~]# wget - ...

  3. Prometheus+Grafana监控MySQL、Redis数据库

    俗话说,没有监控的系统就是在裸奔,好的监控就是运维人员的第三只手,第三只眼.本文将使用prometheus及Grafana搭建一套监控系统来监控主机及数据库(MySQL.Redis). 1.  安装G ...

  4. Prometheus + Grafana 监控(mysql 和redis)

    1.监控MySQL(mysqld-exporter) https://github.com/prometheus/mysqld_exporter/releases/download/v0.11.0/m ...

  5. 使用Prometheus+Grafana监控MySQL实践

    一.介绍Prometheus Prometheus(普罗米修斯)是一套开源的监控&报警&时间序列数据库的组合,起始是由SoundCloud公司开发的.随着发展,越来越多公司和组织接受采 ...

  6. prometheus+grafana监控mysql最佳实践

    导航 前言 环境准备 安装Docker 安装prometheus 安装mysqld_exporter prometheus采集数据 安装grafana grafana配置数据源 感谢您的阅读,预计阅读 ...

  7. 技术分享 | Prometheus+Grafana监控MySQL浅析

    GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. 简介 Prometheus 一套开源的监控&报警&时间序列数据库的组合,通常 Kubernetes 中都会 ...

  8. prometheus+grafana监控Linux和kubernetes的例子

    1.安装和配置prometheus tar zxvf prometheus-.linux-amd64.tar.gz -C /usr/local/ ln -sv /usr/local/prometheu ...

  9. prometheus+grafana监控redis

    prometheus+grafana监控redis redis安装配置 https://www.cnblogs.com/autohome7390/p/6433956.html redis_export ...

随机推荐

  1. [Luogu] 次小生成树

    https://www.luogu.org/problemnew/show/P4180#sub 严格次小生成树,即不等于最小生成树中的边权之和最小的生成树 首先求出最小生成树,然后枚举所有不在最小生成 ...

  2. CSP-S 模拟测试 45 题解

    由于咕掉的题解太多了,所以只能趁改完不动题的时间,来补补坑qwq,还是太弱了. 考试过程: 到新机房的第一次考试,貌似海星? 第一题一开始就觉得是个贪心,但以为所有小怪兽都要打完,所以想复杂了,但后来 ...

  3. HZWER

    我们的征途是星辰大海 2016年3月13日8,8077 尊敬的各位老师.亲爱的同学们: 大家好,我是高三(1)班的黄哲威.今天很荣幸能和大家分享一些有关竞赛的心得体会. 去年7月15日,第32届全国信 ...

  4. spoj5973

    SP5973 SELTEAM - Selecting Teams #include <bits/stdc++.h> using namespace std; typedef long lo ...

  5. 快速掌握Python的捷径-Python基础前传(1)

    文: jacky(朱元禄) 开文序 最近看新闻,发现高考都考Python了,随着人工智能的火热,学数据科学的人越来越多了!但对于数据行业本身来说,现象级的火热,这并不是什么好事. 方丈高楼平地起,无论 ...

  6. selenium-爬取小说

    selenium-爬取小说 1 import requests 2 from bs4 import BeautifulSoup 3 import sys 4 from selenium import ...

  7. Java基础_线程的使用及创建线程的三种方法

    线程:线程是操作系统能够进行运算调度的最小单位.它被包含在进程之中,是进程中的实际运作单位.一条线程指的是进程中一个单一顺序的控制流,一个进程中可以并发多个线程,每条线程并行执行不同的任务. 进程:进 ...

  8. HTML/HTML5 知识点思维导图

    1 - 浏览器 | 浏览器页面构成 2 - 浏览器 | 浏览器内核相关知识点 3 - W3C | 对WEB标准以及W3C的理解与认识? 4 - 标签 | Doctype相关知识点 5 - 标签 | m ...

  9. IntelliJ IDEA 2017.3 搭建一个多模块的springboot项目(三)

    你得先看完前两篇文章才可以进行第三章.这章我又新建了一个模块,起名叫project-core.建立方式与(一)里面一致,一个普通的maven模块.不需要勾选archetype的那种. 大家自己建好后, ...

  10. 简易总结react-hook三大基础

    react-hook的最重要的三大基础 import { useEffect, useState, useContext } from 'react' 1.每一个简单的一句话总结 useEffect ...