grafana使用Prometheus数据源监控mongo数据库
数据库改用mongo后,监控需求就需要整合进grafana里,由于一直在坚持docker化部署,那么此次也不例外。
1. 安装Prometheus:
What is Prometheus?
Prometheus is an open-source systems monitoring and alerting toolkit originally built at SoundCloud. Since its inception in 2012, many companies and organizations have adopted Prometheus, and the project has a very active developer and user community. It is now a standalone open source project and maintained independently of any company. To emphasize this, and to clarify the project's governance structure, Prometheus joined the Cloud Native Computing Foundation in 2016 as the second hosted project, after Kubernetes.
主要的意思就是Prometheus是一个开源的系统监控和告警工具包,通过HTTP endpoints来收集要监控的系统的指标。跟着官网的first step,只需要下载最新版本,配置prometheus.yml,启动即可,比较的简单, 因此我们docker化安装也较为容易。
1) 安装镜像
[root@vhost18 prometheus]# docker search prometheus
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
prom/prometheus [OK]
basi/prometheus-swarm A sample image that can be used as a base fo… [OK]
infinityworks/prometheus-rancher-exporter Exposes Service/Stack/Host status from the R… [OK]
linuxtips/prometheus_alpine Image to run Prometheus on Alpine Linux. #VA… [OK]
sscaling/jmx-prometheus-exporter A docker image containing a released version… [OK]
argussecurity/cassandra-prometheus Docker Official Cassandra image, with Promet… [OK]
安装STARS最多的那个就是了。
2)编写配置文件,参考官网
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every seconds. Default is every minute.
evaluation_interval: 15s # Evaluate rules every seconds. The default is every minute.
# scrape_timeout is set to the global default (10s). # Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager: # Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml" # 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']
3)启动容器
docker run -d --name prom -p : -v /data/prometheus/:/etc/prometheus/ prom/prometheus
4)看下日志是否启动成功
docker logs -f prom level=info ts=--11T11::.73690446Z caller=main.go: msg="Starting Prometheus" version="(version=2.5.0, branch=HEAD, revision=67dc912ac8b24f94a1fc478f352d25179c94ab9b)"
level=info ts=--11T11::.737024426Z caller=main.go: build_context="(go=go1.11.1, user=root@578ab108d0b9, date=20181106-11:40:44)"
level=info ts=--11T11::.737054274Z caller=main.go: host_details="(Linux 3.10.0-693.5.2.el7.x86_64 #1 SMP Fri Oct 20 20:32:50 UTC 2017 x86_64 72be1c67c847 (none))"
level=info ts=--11T11::.737077772Z caller=main.go: fd_limits="(soft=1048576, hard=1048576)"
level=info ts=--11T11::.737095504Z caller=main.go: vm_limits="(soft=unlimited, hard=unlimited)"
level=info ts=--11T11::.757770232Z caller=main.go: msg="Starting TSDB ..."
level=info ts=--11T11::.757939887Z caller=web.go: component=web msg="Start listening for connections" address=0.0.0.0:
level=info ts=--11T11::.769272192Z caller=main.go: msg="TSDB started"
level=info ts=--11T11::.769349241Z caller=main.go: msg="Loading configuration file" filename=/etc/prometheus/prometheus.yml
level=info ts=--11T11::.772044947Z caller=main.go: msg="Completed loading of configuration file" filename=/etc/prometheus/prometheus.yml
level=info ts=--11T11::.77209973Z caller=main.go: msg="Server is ready to receive web requests."
5) 访问http://ip:9090
成功的话会出现以下页面

2. 安装mongodb_exporter
刚说到Prometheus是根据endpoints来获取指标数据的,由于grafana没有直接的插件来获取mongo数据库的指标数据,这时候就可以用得上mongodb_exporter了,参考1,参考2。
1)安装镜像
可以直接build刚刚参考1和参考2的Dockerfile,也可以像安装Prometheus一样直接search,我这边为了简单采用直接search的方式,方式重复不累赘描述。
2)启动镜像
docker run -d --name mongo-explorer -p : eses/mongodb_exporter --mongodb.uri mongodb://monitor:monitor@ip:port
参数需要的mongo地址直接命令传入,无需export 。
如何知道端口和参数呢,一种是看官方说明,另一种直接启动一个空镜像看日志就知道了。
3) 检查下日志
[root@vhost18 prometheus]# docker logs -f mongo-explorer
### Warning: the exporter is in beta/experimental state and field names are very
### likely to change in the future and features may change or get removed!
### See: https://github.com/percona/mongodb_exporter for updates
mongodb_exporter version: unknown, git commit hash: unknown
Listening on :
4)访问http://ip:9090
成功的话会出现以下页面

3. mongodb_exporter整合进Prometheus
1) 修改配置
只需要在prometheus.yml上添加如下框

2) 重启prometheus
docker restart prom
3) 检查
访问http://172.28.64.10:9090/targets,能看到数据源就表示成功了。

4. grafana中添加数据源

5. 安装仪表盘
到grafana官网直接搜mongo,找到自己需要的仪表盘就可以了,后续在自己改造。
grafana使用Prometheus数据源监控mongo数据库的更多相关文章
- grafana使用json数据源监控数据
功能实现完后有部分数据一直在波动,就产生了想把这个数据波动集成到grafana形成可视化界面的监控,但grafana不支持mongo数据库又懒得去用其他工具转换,特意看了下grafana的databa ...
- mongo数据库相关目录
mongodb的docker化安装 mongodb的windows系统下安装 grafana使用Prometheus数据源监控mongo数据库 mongodb副本集的docker化安装 mongodb ...
- 使用 Docker 部署 Grafana + Prometheus 监控 MySQL 数据库
一.背景 在平时开发过程当中需要针对 MySQL 数据库进行监控,这里我们可以使用 Grafana 和 Prometheus 来实现监控功能.Grafana 是一款功能强大的仪表盘面板,支持多种数据源 ...
- Grafana+Zabbix+Prometheus 监控系统
环境说明 软件 版本 操作系统 IP地址 Grafana 5.4.3-1 Centos7.5 192.168.18.231 Prometheus 2.6.1 Centos7.5 192.168.18. ...
- Grafana+Prometheus+node_exporter监控,Grafana无法显示数据的问题
环境搭建: 被测linux机器上部署了Grafana,Prometheus,node_exporter,并成功启动了它们. Grafana中已经创建了Prometheus数据源,并测试通过,并且导入了 ...
- windows下部署Grafana +prometheus平台监控
1.Prometheus简介 Prometheus基于Golang编写,编译后的软件包,不依赖于任何的第三方依赖.用户只需要下载对应平台包,解压并且添加基本的配置即可正常启Prometheus S ...
- Grafana、Prometheus、mtail-日志监控
一:日志如何监控 在上一篇博客Grafana.Prometheus-监控平台中,简单了解了Grafana与Prometheus对项目做特定的监控打点,可视化的配置操作. 但是对于没有设置监控或者不容易 ...
- Prometheus MySQL监控+grafana展示
前言 最近爱上了研究各种杂七杂八的技术. Prometheus是现如今最火的监控软件之一.做为一个运维DBA,不会这个可就OUT了. 本篇博客,演示一下prometheus之通过mysql expor ...
- 【集群监控】Docker上部署Prometheus+Alertmanager+Grafana实现集群监控
Docker部署 下载 sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.re ...
随机推荐
- Android SharedPreferences存储map的方法
在网上查了一些资料后,精简改写后得出自己想用的形式,记录一下 public static void putHashMapData(Context context, String key, Map< ...
- tcp/ip 调优示例
# Kernel sysctl configuration file for Linux # # Version 1.12 - 2015-09-30 # Michiel Klaver - IT Pro ...
- 【NLP_Stanford课堂】词形规范化
一.为什么要规范化 在做信息检索的时候,一般都是精确匹配,如果不做规范化,难以做查询,比如用U.S.A去检索文本,结果文本里实际上存的是USA,那么实际上应该能查到的结果查不到了. 所以需要对所有内容 ...
- python实现oracle数据泵导出功能
脚本如下:[oracle@ycr python]$ more dump.py #/usr/bin/python#coding:utf8 import sysimport osimport time n ...
- mysql使用mysqld_multi工具启动多实例
先给出实验环境/etc/my.cnf文件内容修改内容为:添加了[mysqld_multi]标签和多出来两个数据库的标签[mysqld3307]和[mysqld3308]配置完成后启动方法,举一例:my ...
- 一点一点学写Makefile(3)-增加第三方库和头文件
我们在写代码的时候不一定都是有自己来完成,一个工程中会大量使用一些比较优秀的动态库.静态库等,我们在使用这些库完成所有的代码后,需要在编译的时候将这些库使用的头文件添加到我们的工程上,将他的库文件也添 ...
- 真的有用吗?(GitHub)
为什么要新建一个GitHub账号 一个程序员不知道GitHub,那我就笑笑,呵呵哒.什么是GitHub呢? 就我知道的git,谈一下.Git是一个版本控制软件,这个软件最初是Linux之父林纳斯. ...
- 【甘道夫】NN HA 对于 Client 透明的实验
之前转载过一篇[伊利丹]写的NN HA实验记录.该博客描写叙述了主备NN透明切换的过程,也就是说,当主NN挂掉后,自己主动将备NN切换为主NN了,Hadoop集群正常执行. 今天我继续做了一个实验.目 ...
- listview加载显示图片
public class ImageAndTextListAdapter extends ArrayAdapter<ImageAndText> { private ListView lis ...
- ettercap_缺少组件问题
原因:缺少WinPcap组件解决:安装即可