An open API service indexing awesome lists of open source software.

https://github.com/hiwepy/jmxtrans-integration

embedded-jmxtrans 整合 Spring、Servlet、InfluxDB
https://github.com/hiwepy/jmxtrans-integration

influxdb jmxtrans spring

Last synced: 2 months ago
JSON representation

embedded-jmxtrans 整合 Spring、Servlet、InfluxDB

Awesome Lists containing this project

README

          

# jmxtrans-integration

embedded-jmxtrans 整合 Spring、Servlet、InfluxDB

## 1、Servlet Integration

参考EmbeddedJmxTransLoaderListener对象注解
```xml

jmxtrans.config

classpath:jmxtrans.json
classpath:org/jmxtrans/embedded/config/jmxtrans-internals-servlet-container.json
classpath:org/jmxtrans/embedded/config/tomcat-7.json
classpath:org/jmxtrans/embedded/config/jvm-sun-hotspot.json

org.jmxtrans.embedded.servlet.EmbeddedJmxTransLoaderListener

```
## 2、Spring Integration

本人参考 embedded-jmxtrans 的github地址 https://github.com/jmxtrans/embedded-jmxtrans/wiki 配置后,测试完全无效。
阅读代码后采用另种方式:

配置EmbeddedJmxTransFactory
```xml










classpath:jmxtrans.json
classpath:org/jmxtrans/embedded/config/tomcat-7.json
classpath:org/jmxtrans/embedded/config/jmxtrans-internals.json
classpath:org/jmxtrans/embedded/config/jvm-sun-hotspot.json

```
使用EmbeddedJmxTransFactory;此处发现如果不引用上面的对象,则无法调用getObject方法实现对象初始化
```xml

```

## 3、InfluxDB Integration

在第二则中提到配置文件 jmxtrans.json;为了将数据自己输出到InfluxDB,我拷贝了jmxtrans-output-influxdb的代码,做了一些调整,配置如下:

```json
{
"queries": [
{
"objectName": "Catalina:type=Manager,context=/,host=*",
"resultAlias": "application.activeSessions",
"attributes": [
"activeSessions"
]

}
],
"outputWriters": [
{
"@class": "org.jmxtrans.embedded.output.Slf4jWriter",
"settings": {
"enabled": "${jmxtrans.writer.slf4j.enabled:true}"
}
},
{
"@class": "org.jmxtrans.embedded.output.influxdb.InfluxDbOutputWriter",
"settings": {
"enabled": "${jmxtrans.writer.influxdb.enabled:true}",
"url": "${jmxtrans.writer.influxdb.url:http://localhost:8086}",
"database": "${jmxtrans.writer.influxdb.database:APP_Metrics}",
"user": "${jmxtrans.writer.influxdb.user:admin}",
"password": "${jmxtrans.writer.influxdb.password:admin}",
"tags": "${jmxtrans.writer.influxdb.tags:host=#hostname#}"

}
}
]
}
```