说先说一下结构,由于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的StateUP。(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相关推荐

  1. 使用Prometheus+Grafana 监控MySQL/MONGODB

    使用Prometheus+Grafana 监控MySQL/MONGODB 之前就久仰 Prometheus 大名,因为有用zabbix 进行监控,就没去安装它.现在正好用上监控MONGO+MYSQL. ...

  2. zabbix系列(十二) 监控MongoDB业务数据

    目录 一.简介 二.部署说明 2.1编写python程序进行获取mogno数据 2.2.上传python脚本至服务器,并测试通过 2.3.配置zabbix web页面,获取数据入库 2.4 .配置gr ...

  3. grafana 监控mysql_Prometheus+Grafana监控MySQL性能

    今天来写一篇监控MySQL数据库的的监控方案:Prometheus+Grafana监控mysql性能 1.监控方案介绍 祖传老图修一修: 解释一波:①mysqld_exporter用来收集数据库的性能 ...

  4. Promethus+Grafana监控解决方案

    Promethus+Grafana监控解决方案 参考文章: (1)Promethus+Grafana监控解决方案 (2)https://www.cnblogs.com/allenhu320/p/113 ...

  5. 十一、Grafana监控系统

    @Author : By Runsen @Date : 2020/6/19 作者介绍:Runsen目前大三下学期,专业化学工程与工艺,大学沉迷日语,Python, Java和一系列数据分析软件.导致翘 ...

  6. [Cacti] cacti监控mongodb性能实战

    前言: 为了更好的使用mongodb,须要监控出mongodb的一些基础使用情况,比方Flush数.连接数.内存使用率.Index操作.Slave延迟等等,这些能够通过配置cacti监控mongodb ...

  7. 基于Prometheus+Grafana监控SQL Server数据库

    墨墨导读:本文整理了基于Prometheus+Grafana监控SQL Server数据库的全过程,分享至此,希望对大家有帮助. 搭建SQL Server环境 使用容器建立SQL Server环境非常 ...

  8. Prometheus+Grafana监控PostgreSQL

    Prometheus+Grafana监控PostgreSQL Prometheus:2.32.0 Grafana:8.3.3 PG:13.2 Linux:CentOS7.6 docker:18.06. ...

  9. 使用zabbix监控MongoDB

    现在公司几个游戏项目主要使用MongoDB来存储游戏数据,所以对MongoDB的监控非常重要.关于MongoDB的其他监控方法详见以下几篇文章: MongoDB监控一 MongoDB监控二 mongo ...

最新文章

  1. Qt编译PX4源码,参考如下进行配置
  2. android qt 对比_QT for android 比较完美解决 全屏问题
  3. 从pymongo 提取最近100条数据
  4. 云图说 | 3分钟创建一个游戏类工作负载
  5. 拳王虚拟项目公社:闲鱼操作卖资源如何赚钱?闲鱼怎么卖虚拟资源?卖什么资源赚钱?
  6. MFC避免窗口闪烁的方法(OnEraseBkgnd) .
  7. 交换局域网(链路层+以太网+交换机)
  8. MongoDB 概述、下载安装、配置 、启动与连接
  9. matlab常用符号意思,matlab常用的符号
  10. html5中Canvas API
  11. 程序化交易系统的搭建
  12. [解题报告]Ural 1011 Conductors
  13. 2021年焊工(初级)考试题及焊工(初级)考试报名
  14. stm32f407的串口调试助手乱码
  15. 水文专业对计算机要求,来了来了,高考志愿这么填!
  16. 扫描版模糊pdf优化方法
  17. 【安卓学习之第三方库】 Rxpay学习:支付宝微信支付
  18. unity 3d游戏开发_使用Unity 5开发3D游戏
  19. 现代微型计算机的字长,计算机的字长
  20. Codeforces Round #834 (Div. 3) E. The Humanoid

热门文章

  1. 手机各种版本比较 各种类型介绍 市售各种类型手机 行货 港版机
  2. 【愚公系列】2023年06月 网络安全(交通银行杯)-美女与野兽
  3. 网页制作动态技术----PHP
  4. 什么是私域、公域、商域流量
  5. RabbitMQ镜像队列实现原理
  6. 陌陌: 基于地理位置的陌生人社交平台
  7. PS制作文字图片的倒影
  8. 宏的定义和调用,输出字符串
  9. 通常情况下,我们每天花一两个小时学习建站,一个月左右就能掌握一种简单开源程序建站
  10. 此乃谎言_停止相信电视的谎言:关于“增强”图像的真实真相