|
|
package com.monitor.influxdb;
|
|
|
|
|
|
import org.influxdb.dto.Query;
|
|
|
import org.influxdb.dto.QueryResult;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
public class InfluxDBQuery {
|
|
|
|
|
|
@Autowired
|
|
|
protected InluxDBSingle inluxDBSingle;
|
|
|
|
|
|
protected final Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
protected QueryResult query(String influxDBName, String command, String database){
|
|
|
Query query = new Query(command, database);
|
|
|
try {
|
|
|
QueryResult queryResult = inluxDBSingle.getInfluxDBByName(influxDBName)
|
|
|
.getInfluxDB().query(query);
|
|
|
|
|
|
return queryResult;
|
|
|
} catch (Exception e) {
|
|
|
logger.error("influxdb query failed! influxDBName:{},commond:{},database:{},exception{}",influxDBName,command,database,e);
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|