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
- Host: GitHub
- URL: https://github.com/hiwepy/jmxtrans-integration
- Owner: hiwepy
- License: apache-2.0
- Created: 2017-03-29T04:09:57.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-11-03T14:09:16.000Z (over 6 years ago)
- Last Synced: 2025-10-24T06:27:47.420Z (8 months ago)
- Topics: influxdb, jmxtrans, spring
- Language: Java
- Homepage:
- Size: 81.1 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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#}"
}
}
]
}
```