[collector]采集器支持mysql协议指标采集
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
<dependency>
|
||||
<groupId>com.usthe.tancloud</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<!-- etcd -->
|
||||
<dependency>
|
||||
@@ -84,6 +84,13 @@
|
||||
<artifactId>aviator</artifactId>
|
||||
<version>5.2.7</version>
|
||||
</dependency>
|
||||
<!--collect-->
|
||||
<!-- mysql -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.27</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -3,6 +3,7 @@ package com.usthe.collector.dispatch;
|
||||
import com.googlecode.aviator.AviatorEvaluator;
|
||||
import com.googlecode.aviator.Expression;
|
||||
import com.usthe.collector.collect.AbstractCollect;
|
||||
import com.usthe.collector.collect.database.JdbcCommonCollect;
|
||||
import com.usthe.collector.collect.http.HttpCollectImpl;
|
||||
import com.usthe.collector.collect.icmp.IcmpCollectImpl;
|
||||
import com.usthe.collector.collect.telnet.TelnetCollectImpl;
|
||||
@@ -107,6 +108,9 @@ public class MetricsCollect implements Runnable, Comparable<MetricsCollect> {
|
||||
case DispatchConstants.PROTOCOL_TELNET:
|
||||
abstractCollect = TelnetCollectImpl.getInstance();
|
||||
break;
|
||||
case DispatchConstants.PROTOCOL_JDBC:
|
||||
abstractCollect = JdbcCommonCollect.getInstance();
|
||||
break;
|
||||
// todo
|
||||
default: break;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class JsonPathParser {
|
||||
* 使用jsonPath来解析json内容
|
||||
* @param content json内容
|
||||
* @param jsonPath jsonPath脚本
|
||||
* @return 解析后的内容
|
||||
* @return 解析后的内容 [{'name': 'tom', 'speed': '433'},{'name': 'lili', 'speed': '543'}]
|
||||
*/
|
||||
public static List<Map<String, Object>> parseContentWithJsonPath(String content, String jsonPath) {
|
||||
if (content == null || jsonPath == null || "".equals(content) || "".equals(jsonPath)) {
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.usthe.collector.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* prometheus-format-text parser
|
||||
* @author tom
|
||||
* @date 2022/1/9 14:12
|
||||
*/
|
||||
public class PrometheusTextParser {
|
||||
|
||||
/**
|
||||
* 解析prometheusText
|
||||
* @param content 待解析文本内容
|
||||
* @return eg:[{'name': 'tom', 'speed': '433'},{'name': 'lili', 'speed': '543'},{'name': 'sam', 'speed': '643'}]
|
||||
*/
|
||||
public static Map<String, List<Map<String, Object>>> parsePrometheusText(String content) {
|
||||
String[] lines = content.split("\n");
|
||||
Map<String, List<Map<String, Object>>> parseResult = new HashMap<>(8);
|
||||
for (String lineTmp : lines) {
|
||||
String line = lineTmp.trim();
|
||||
if (line.length() == 0 || line.startsWith("#")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user