转自http://www.jianshu.com/p/fadcf4d92b0e

这里再配合InfluxdbGrafana可以构建一个非常漂亮的实时监控界面。

Grafana监控界面

采集数据(Metrics)-> 存储数据(InfluxDB) -> 显示数据(Grafana)。

资源有限,我把这一套服务搭建在了一台CentOS 7的服务器上。

安装influxdb

InfluxDB是Go语言写的一个时序型数据库,可以通过rpm的方式来安装它,这里最好能安装InfluxDB的最新版本,否则跟Grafana的交互会有一些不兼容。

wget https://dl.influxdata.com/influxdb/releases/influxdb-1.2.4.x86_64.rpm
sudo yum localinstall influxdb-1.2.4.x86_64.rpm
 

安装完成之后,启动并查看这个服务是否在正常运行:

systemctl start influxdb.service
[root@metrics ~]# systemctl status influxdb.service
● influxdb.service - InfluxDB is an open-source, distributed, time series database
Loaded: loaded (/usr/lib/systemd/system/influxdb.service; enabled; vendor preset: disabled)
Active: active (running) since 一 2016-04-25 17:50:04 CST; 1 day 1h ago
Docs: https://docs.influxdata.com/influxdb/
Main PID: 17871 (sh)
CGroup: /system.slice/influxdb.service
├─17871 /bin/sh -c /usr/bin/influxd -config /etc/influxdb/influxdb.conf >>/dev/nul...
└─17872 /usr/bin/influxd -config /etc/influxdb/influxdb.conf 4月 25 17:50:04 metrics systemd[1]: Started InfluxDB is an open-source, distributed...se.
4月 25 17:50:04 metrics systemd[1]: Starting InfluxDB is an open-source, distribute......
Hint: Some lines were ellipsized, use -l to show in full.

启动后打开 web 管理界面 http://192.168.2.183:8083/ 默认用户名和密码是 root 和 root. InfluxDB 的 Web 管理界面端口是 8083,HTTP API 监听端口是 8086,如果需要更改这些默认设定,修改 InfluxDB 的配置文件(/etc/influxdb/influxdb.conf)并重启就可以了。

安装 Grafana

Grafana是一个非常好看的监控界面,它的安装方式也非常简单,通过yum,一条命令就可以在server上完成安装。

wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.3.2-1.x86_64.rpm 
sudo yum localinstall grafana-4.3.2-1.x86_64.rpm 

完成安装之后,启动并检查它的状态:

[root@metrics ~]# systemctl start grafana-server.service
[root@metrics ~]# systemctl status grafana-server.service
● grafana-server.service - Starts and stops a single grafana instance on this system
Loaded: loaded (/usr/lib/systemd/system/grafana-server.service; disabled; vendor preset: disabled)
Active: active (running) since 一 2016-04-25 09:37:07 CST; 1 day 10h ago
Docs: http://docs.grafana.org
Main PID: 10309 (grafana-server)
CGroup: /system.slice/grafana-server.service
└─10309 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile= cfg:d...

用浏览器访问 Grafana,默认端口是3000,默认的帐号密码都是 admin(可以在配置文件中找到),登录之后配置数据库

设置数据源

Metrics Reporter

之前提到Metrics只需要配置它的Reporter就可以输出到对应的地方,对于Influxdb,在github上找到了一个InfluxdbReporter(https://github.com/davidB/metrics-influxdb)。

Maven中引入:

<dependency>
<groupId>com.github.davidb</groupId>
<artifactId>metrics-influxdb</artifactId>
<version>0.8.2</version>
</dependency>

并在代码中配置Influxdb的数据源:

@Bean(name = "influxdbReporter")
public ScheduledReporter influxdbReporter(MetricRegistry metrics) throws Exception { return InfluxdbReporter.forRegistry(metrics)
.protocol(InfluxdbProtocols.http("host_ip_address", port, "username", "password", "database"))
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.filter(MetricFilter.ALL)
.skipIdleMetrics(false)
.build();
}

启动项目之后,我们开始配置我们需要看到的图表信息:

配置图标信息

最后我们利用wrk测试工具并发访问连接:

➜  ~ wrk -t 10 -c 50 -d 5s http://127.0.0.1:8888/hello
Running 5s test @ http://127.0.0.1:8888/hello
10 threads and 50 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 6.59ms 12.17ms 210.05ms 92.16%
Req/Sec 1.40k 427.51 2.79k 71.80%
69902 requests in 5.04s, 10.28MB read
Requests/sec: 13873.71
Transfer/sec: 2.04MB

于此同时Grafana界面上系统实时的数据信息也展现出来了:

利用Metrics+influxdb+grafana构建监控平台(转)的更多相关文章

  1. 利用Metrics+influxdb+grafana构建监控平台

    https://blog.csdn.net/fishmai/article/details/51817429

  2. 微服务监控之二:Metrics+influxdb+grafana构建监控平台

    系统开发到一定的阶段,线上的机器越来越多,就需要一些监控了,除了服务器的监控,业务方面也需要一些监控服务.Metrics作为一款监控指标的度量类库,提供了许多工具帮助开发者来完成自定义的监控工作. 使 ...

  3. Spring Boot Actutaur + Telegraf + InFluxDB + Grafana 构建监控平台之应用数据分析

    本节将引入完美的granafa仪表板,在上节的基础上,并提出自己的一些监控数据的总结和看法 你可以有一个类似于这个的Dashboard,会引入监控Zimbra协作 本节环境采用的是centos7系统, ...

  4. Spring Boot Actutaur + Telegraf + InFluxDB + Grafana 构建监控平台

    完成一套精准,漂亮图形化监控系统从这里开始第一步 Telegraf是收集和报告指标和数据的代理 它是TICK堆栈的一部分,是一个用于收集和报告指标的插件驱动的服务器代理.Telegraf拥有插件或集成 ...

  5. influxdb + Grafana可视化监控平台

    在centos6.5上influxdb + Grafana监控平台配置: 1.RedHat and CentOS users can install the latest stable version ...

  6. Metrics.net + influxdb + grafana 构建WebAPI的自动化监控和预警

    前言 这次主要分享通过Metrics.net + influxdb + grafana 构建WebAPI的自动化监控和预警方案.通过执行耗时,定位哪些接口拖累了服务的性能:通过请求频次,设置适当的限流 ...

  7. .NET Core微服务之基于App.Metrics+InfluxDB+Grafana实现统一性能监控

    Tip: 此篇已加入.NET Core微服务基础系列文章索引 一.关于App.Metrics+InfluxDB+Grafana 1.1 App.Metrics App.Metrics是一款开源的支持. ...

  8. 全网最详细!Centos7.X 搭建Grafana+Jmeter+Influxdb 性能实时监控平台

    背景 日常工作中,经常会用到Jmeter去压测,毕竟LR还要钱(@¥&*...),而最常用的接口压力测试,我们都是通过聚合报告去查看压测结果的,然鹅聚合报告的真的是丑到家了,作为程序猿这当然不 ...

  9. Centos7.X 搭建Grafana+Jmeter+Influxdb 性能实时监控平台(不使用docker)

    工具介绍 [centos7安装influxDB] Influxdata官网下载路径:https://portal.influxdata.com/downloads/ 1.直接执行以下命令安装 2.安装 ...

随机推荐

  1. 单用户模式&救援模式&克隆虚拟机&Linux机器相互登录

    1.13 单用户模式 1.14 救援模式 1.15 克隆虚拟机 1.16 Linux机器相互登录 1.单用户模式 关机:init 0 .poweroff 重启:init 6 .reboot 关机:in ...

  2. linux mysql远程连接的命令

    mysql -u 用户名 -h 远程IP地址 -p  随后输入密码. 要确认远程数据库3306端口是否开放,mysql服务是否启动. hadoop@Master:~$ mysql -u root -h ...

  3. SQL2000系统表、存储过程、函数的功能介绍及应用

    转自:http://blog.csdn.net/zlp321002/article/details/480925 ----系统表------------------------------------ ...

  4. 查看cp进度,使用watch

    watch -n 1 -d du -sh dir 每隔1s查看当前目录所占空间大小

  5. 安装MySQL后经常弹出taskeng.exe~

    taskeng.exe,是Microsoft任务计划程序引擎调用的安全进程.文件路径为C:\Windows\system32\taskeng.exe.大小165KB. 解决办法:  这个问题是Wind ...

  6. 转载SQL容易产生的错误问题

    概述 因为每天需要审核程序员发布的SQL语句,所以收集了一些程序员的一些常见问题,还有一些平时收集的其它一些问题,这也是很多人容易忽视的问题,在以后收集到的问题会补充在文章末尾,欢迎关注,由于收集的问 ...

  7. varchar和nvarchar的区别 数据来证明

    如果一个数据是"N好"数据类型是varchar时: select len(vartest) from testselect datalength(vartest) from tex ...

  8. memcache和redis的区别

    1.定义 Redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的API Memcache是一个高性能的分布式的内存对象缓存系 ...

  9. 搭建项目Maven+springMVC+hibernate时,JUnit測试出现报ClassNotFoundException错误的解决

    近期在搭建Maven+springMVC+hibernate项目,正常启动项目时一切正常.但JUNIT測试时出现报ClassNotFoundException错误,经过细致排查发现没有生成class文 ...

  10. [Unity官方文档翻译]Primitive and Placeholder Objects Unity原生3D物体教程

    Primitive and Placeholder Objects 原始的基础物体 Unity can work with 3D models of any shape that can be cre ...