使用grafana监控mongodb
说先说一下结构,由于grafana本身数据源没有mongodb,所以需要在中间加上Prometheus来对mongodb监控.
服务器端组件:
prometheus #服务端
Grafana #前端展示,
客户端组件:
node_exporter
mongodb_exporter
mongodb,Prometheus,node_exporter,node_exporter 都安装在192.168.23.10
grafana 安装在另外一台机器上
首先安装go
$ yum install go
$ go version
go version go1.6.3 linux/amd64
下载安装Prometheus(https://prometheus.io/download/)
$ wget https://github.com/prometheus/prometheus/releases/download/v1.6.2/prometheus-1.6.2.linux-amd64.tar.gz
$ tar xvf prometheus-1.6.2.linux-amd64.tar.gz -C /usr/local/
$ ln -sv /usr/local/prometheus-1.6.2.linux-amd64/ /usr/local/prometheus
$ cd /usr/local/prometheus
然后在Prometheus里面修改配置文件 prometheus . yml(添加你监管的ip地址):
# my global config
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.# scrape_timeout is set to the global default (10s).# Attach these labels to any time series or alerts when communicating with# external systems (federation, remote storage, Alertmanager).external_labels:monitor: 'codelab-monitor'# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:#- "first.rules"# - "second.rules"# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.# - job_name: 'prometheus'# metrics_path defaults to '/metrics'# scheme defaults to 'http'.# static_configs:# - targets: ['localhost:9090']- job_name: 'mongo1'static_configs:- targets: ['192.168.23.10:9001'] #这里是mongodb_exporter监听端口,在后面会说.
启动Prometheus: nohup ./Prometheus &
Prometheus内置了一个web界面,我们可通过http://monitor_host:9090
进行访问:
在Status
->Targets
页面下,我们可以看到我们配置的mongo1,Target的State
为UP
。(up为Prometheus已经检测到数据,需要安装好
node_exporter,mongodb_exporter下面会说)
可以用我传上去的:
mongodb_exporter:
https://download.csdn.net/download/locky_lll/10366804
node_exporter:
https://download.csdn.net/download/locky_lll/10366812
下一步我们需要安装并运行exporter,下载exporters并解压到被监控端服务器:
$ wget https://github.com/prometheus/node_exporter/releases/download/v0.14.0/node_exporter-0.14.0.linux-amd64.tar.gz
https://github.com/dcu/mongodb_exporter/releases/mongodb_exporter-linux-amd64(这个我是直接下导进去的)
安装运行node_exporter:
$ tar xvf node_exporter-0.14.0.linux-amd64.tar.gz -C /usr/local/
$ nohup /usr/local/node_exporter-0.14.0.linux-amd64/node_exporter &
安装运行mongodb_exporter:
$ nohup ./mongodb_exporter-linux-amd64 &
这时再返回Prometheus页面,你的mongodb Status就回变成 UP.
到这里,Prometheus监控mongoDB就完成了.
Grafana安装配置介绍(网上教程比较多,我就不一一写了)
1
2
|
$ wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.2.0-1.x86_64.rpm
$ sudo yum localinstall grafana-4.2.0-1.x86_64.rpm
|
编辑配置文件/etc/grafana/grafana.ini,修改dashboards.json段落下两个参数的值:
1
2
3
|
[dashboards.json]
enabled=true
path=/var/lib/grafana/dashboards
|
安装仪表盘(Percona提供)
1
2
|
$ git clone https://github.com/percona/grafana-dashboards.git
$ cp -r grafana-dashboards/dashboards /var/lib/grafana
|
运行以下命令为Grafana打个补丁,不然图表不能正常显示:
1
2
|
$sed-i's/expr=\(.\)\.replace(\(.\)\.expr,\(.\)\.scopedVars\(.*\)var\(.\)=\(.\)\.interval/expr=\1.replace(\2.expr,\3.scopedVars\4var \5=\1.replace(\6.interval, \3.scopedVars)/'/usr/share/grafana/public/app/plugins/datasource/prometheus/datasource.js
$sed-i's/,range_input/.replace(\/"{\/g,"\\"").replace(\/}"\/g,"\\""),range_input/; s/step_input:""/step_input:this.target.step/'/usr/share/grafana/public/app/plugins/datasource/prometheus/query_ctrl.js
|
最后我们运行Grafana服务
1
2
3
|
$systemctldaemon-reload
$systemctlstartgrafana-server
$systemctlstatusgrafana-server
|
grafana默认端口3000,可以访问ganfana.
然后我们到Data Sources
页面添加数据源:
然后在添加表盘时,可以load一个辨认已经做好的表盘:
https://grafana.com/dashboards/2583
完成后:
因为grafana是实时的,所以这个是我已经开了一天的图.
如果转载,需加出处.
使用grafana监控mongodb相关推荐
- 使用Prometheus+Grafana 监控MySQL/MONGODB
使用Prometheus+Grafana 监控MySQL/MONGODB 之前就久仰 Prometheus 大名,因为有用zabbix 进行监控,就没去安装它.现在正好用上监控MONGO+MYSQL. ...
- zabbix系列(十二) 监控MongoDB业务数据
目录 一.简介 二.部署说明 2.1编写python程序进行获取mogno数据 2.2.上传python脚本至服务器,并测试通过 2.3.配置zabbix web页面,获取数据入库 2.4 .配置gr ...
- grafana 监控mysql_Prometheus+Grafana监控MySQL性能
今天来写一篇监控MySQL数据库的的监控方案:Prometheus+Grafana监控mysql性能 1.监控方案介绍 祖传老图修一修: 解释一波:①mysqld_exporter用来收集数据库的性能 ...
- Promethus+Grafana监控解决方案
Promethus+Grafana监控解决方案 参考文章: (1)Promethus+Grafana监控解决方案 (2)https://www.cnblogs.com/allenhu320/p/113 ...
- 十一、Grafana监控系统
@Author : By Runsen @Date : 2020/6/19 作者介绍:Runsen目前大三下学期,专业化学工程与工艺,大学沉迷日语,Python, Java和一系列数据分析软件.导致翘 ...
- [Cacti] cacti监控mongodb性能实战
前言: 为了更好的使用mongodb,须要监控出mongodb的一些基础使用情况,比方Flush数.连接数.内存使用率.Index操作.Slave延迟等等,这些能够通过配置cacti监控mongodb ...
- 基于Prometheus+Grafana监控SQL Server数据库
墨墨导读:本文整理了基于Prometheus+Grafana监控SQL Server数据库的全过程,分享至此,希望对大家有帮助. 搭建SQL Server环境 使用容器建立SQL Server环境非常 ...
- Prometheus+Grafana监控PostgreSQL
Prometheus+Grafana监控PostgreSQL Prometheus:2.32.0 Grafana:8.3.3 PG:13.2 Linux:CentOS7.6 docker:18.06. ...
- 使用zabbix监控MongoDB
现在公司几个游戏项目主要使用MongoDB来存储游戏数据,所以对MongoDB的监控非常重要.关于MongoDB的其他监控方法详见以下几篇文章: MongoDB监控一 MongoDB监控二 mongo ...
最新文章
- Qt编译PX4源码,参考如下进行配置
- android qt 对比_QT for android 比较完美解决 全屏问题
- 从pymongo 提取最近100条数据
- 云图说 | 3分钟创建一个游戏类工作负载
- 拳王虚拟项目公社:闲鱼操作卖资源如何赚钱?闲鱼怎么卖虚拟资源?卖什么资源赚钱?
- MFC避免窗口闪烁的方法(OnEraseBkgnd) .
- 交换局域网(链路层+以太网+交换机)
- MongoDB 概述、下载安装、配置 、启动与连接
- matlab常用符号意思,matlab常用的符号
- html5中Canvas API
- 程序化交易系统的搭建
- [解题报告]Ural 1011 Conductors
- 2021年焊工(初级)考试题及焊工(初级)考试报名
- stm32f407的串口调试助手乱码
- 水文专业对计算机要求,来了来了,高考志愿这么填!
- 扫描版模糊pdf优化方法
- 【安卓学习之第三方库】 Rxpay学习:支付宝微信支付
- unity 3d游戏开发_使用Unity 5开发3D游戏
- 现代微型计算机的字长,计算机的字长
- Codeforces Round #834 (Div. 3) E. The Humanoid