1.在maven项目的pom.xml引入metrics-spring和metrics-influxdb两个jar包

    <dependency>
<groupId>com.ryantenney.metrics</groupId>
<artifactId>metrics-spring</artifactId>
<version>3.1.3</version>
</dependency>
<dependency>
<groupId>com.github.davidb</groupId>
<artifactId>metrics-influxdb</artifactId>
<version>0.9.3</version>
</dependency>

2.配置InfluxdbReporter

import java.util.concurrent.TimeUnit;

import org.springframework.context.annotation.Configuration;

import com.codahale.metrics.ConsoleReporter;
import com.codahale.metrics.MetricFilter;
import com.codahale.metrics.MetricRegistry;
import com.ryantenney.metrics.spring.config.annotation.EnableMetrics;
import com.ryantenney.metrics.spring.config.annotation.MetricsConfigurerAdapter; import metrics_influxdb.HttpInfluxdbProtocol;
import metrics_influxdb.InfluxdbReporter; @Configuration
@EnableMetrics
public class SpringConfiguringClass extends MetricsConfigurerAdapter { @Override
public void configureReporters(MetricRegistry metricRegistry) {
// registerReporter allows the MetricsConfigurerAdapter to
// shut down the reporter when the Spring context is closed
//输出度量数据至控制台
registerReporter(ConsoleReporter.forRegistry(metricRegistry).build()).start(5, TimeUnit.SECONDS);
//输出度数数据到influxdb
InfluxdbReporter.forRegistry(metricRegistry)
.protocol(new HttpInfluxdbProtocol("your influxdb server IP address", 8086, "test", "test"))
.convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).filter(MetricFilter.ALL)
.skipIdleMetrics(false).tag("server", "127.0.0.1").build().start(1, TimeUnit.SECONDS);
} }

3.在需要监控的代码方法体上引入相关注解

 note:方法必须为public方法

4.参考文档

  Metrics官网 https://metrics.dropwizard.io/4.0.0/getting-started.html

  metrics-spring官网 https://github.com/ryantenney/metrics-spring

  metrics-influxdb官网 https://github.com/davidB/metrics-influxdb

  grafana官网文档 http://docs.grafana.org/features/panels/graph/

5.整合influxdb+grafana+metrics,可参考

  https://blog.csdn.net/qq_35981283/article/details/76887173

metrics+spring+influxdb整合的更多相关文章

  1. metrics+spring+influxdb

    https://www.cnblogs.com/lixyu/p/9337055.html

  2. struts2 spring mybatis 整合(test)

    这几天搭了个spring+struts2+mybatis的架子,练练手,顺便熟悉熟悉struts2. 环境:myEclipse10+tomcat7+jdk1.6(1.8的jre报错,所以换成了1.6) ...

  3. 【Java EE 学习 79 下】【动态SQL】【mybatis和spring的整合】

    一.动态SQL 什么是动态SQL,就是在不同的条件下,sql语句不相同的意思,曾经在“酒店会员管理系统”中写过大量的多条件查询,那是在SSH的环境中,所以只能在代码中进行判断,以下是其中一个多条件查询 ...

  4. 3.springMVC+spring+Mybatis整合Demo(单表的增删该查,这里主要是贴代码,不多解释了)

    前面给大家讲了整合的思路和整合的过程,在这里就不在提了,直接把springMVC+spring+Mybatis整合的实例代码(单表的增删改查)贴给大家: 首先是目录结构: 仔细看看这个目录结构:我不详 ...

  5. 由“单独搭建Mybatis”到“Mybatis与Spring的整合/集成”

    在J2EE领域,Hibernate与Mybatis是大家常用的持久层框架,它们各有特点,在持久层框架中处于领导地位. 本文主要介绍Mybatis(对于较小型的系统,特别是报表较多的系统,个人偏向Myb ...

  6. spring+websocket整合

    java-websocket的搭建非常之容易,没用框架的童鞋可以在这里下载撸主亲自调教好的java-websocket程序: Apach Tomcat 8.0.3+MyEclipse+maven+JD ...

  7. Hibernate 与 Spring 的整合

    刚刚学习了hibernate和Spring的整合,现在来总结一下. 以实现一个功能为例,与大家分享一下整个过程. 需要实现的功能:建立一个Person类,该类包括name,sex,age,birtha ...

  8. Spring与Struts2整合VS Spring与Spring MVC整合

    Spring与Struts2整合,struts.xml在src目录下 1.在web.xml配置监听器 web.xml <!-- 配置Spring的用于初始化ApplicationContext的 ...

  9. struts2+hibernate-jpa+Spring+maven 整合(1)

    1.0.0 struts2 与 spring 的整合. 1.1.0 新建maven工程 , 编写pom.xml ,这里只需要简单的添加 一个组件就够了: 在myeclipse 生成的pom.xml 添 ...

随机推荐

  1. 项目三(2)——person与学生

    编程实现Person类,学生类的设计及其继承关系 (同第六章课后第三题) class Person{ private String name; private String addr; private ...

  2. 安装jdk1.8

    这是很普通的shell的脚本,只需要注意:echo 语句内出现的变量,需要转义! #!/bin/bash function get_current_time_stamp(){ echo `date & ...

  3. SQL 优化经历

    一次非常有趣的 SQL 优化经历   阅读本文大概需要 6 分钟. 前言 在网上刷到一篇数据库优化的文章,自己也来研究一波. 场景 数据库版本:5.7.25 ,运行在虚拟机中. 课程表 #课程表 cr ...

  4. python魔法方法

    1.__call__ 实现__call__后,该类的对象可以被调用 举例如: class test_call_: def __init__(self, n): self.n = n def __cal ...

  5. vue学习笔记——组件的优化

    Vue 应用性能优化指南 1 给组件定义name,然后在同级目录新建index文件: import Count from './count.vue' export Count; 2 优化大数据的列表 ...

  6. windows openssh server 安装试用

    使用Windows的可能会知道win10 的已经包好了openssh 服务,但是对于其他机器win 7 windows 2008 ,就需要其他的方法了 还好powershell 团队开发了支持wind ...

  7. 代码本色 用编程模拟自然系统 (Daniel Shiffman 著)

    https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.7/p5.js http://www.box2d.org http://www.jbox2d.org ...

  8. 使用新标签兼容低版本IE

    HTML语义化 意义:根据内容的结构化(语义化),选择合适的标签,便于开发者阅读和写出更优雅的代码,同时让流浪器的爬虫和机器更好的解析. 尽可能少的使用无语义的标签 div 和 span 在语义不明显 ...

  9. 二十、springcloud(六)配置中心服务化和高可用

    1.问题描述 前一篇,spring-cloud-houge-provider(称之为客户端)直接从spring-cloud-houge-config(称之为服务端)读取配置,客户端和服务端的耦合性太高 ...

  10. LiveBindings如何绑定一个对象(转)

    原文 http://www.malcolmgroves.com/blog/?p=1084 一.新建VCL工程加入TAdapterBingSource控件 二.定一个TPerson类 MyPerson ...