mark
This commit is contained in:
@@ -49,23 +49,23 @@ public class Main {
|
||||
// InfluxClient.Client.insert(event,"ASProcessCompleteEvent");
|
||||
|
||||
|
||||
Point point = Point.measurement("ASProcessCompleteEvent")
|
||||
.addTag("transationId", "112311")
|
||||
.addTag("argName", "argName11")
|
||||
.addField("argValue", 3D)
|
||||
.time(Instant.now().toEpochMilli(), WritePrecision.MS);
|
||||
|
||||
|
||||
Point point2 = Point.measurement("ASProcessCompleteEvent")
|
||||
.addTag("transationId", "222312")
|
||||
.addTag("argName", "argName11")
|
||||
.addField("argValue", 4D)
|
||||
.time(Instant.now().toEpochMilli(), WritePrecision.MS);
|
||||
List<Point> list = new ArrayList<>();
|
||||
list.add(point);
|
||||
list.add(point2);
|
||||
|
||||
writeApi.writePoints(list);
|
||||
// Point point = Point.measurement("ASProcessCompleteEvent")
|
||||
// .addTag("transationId", "112311")
|
||||
// .addTag("argName", "argName11")
|
||||
// .addField("argValue", 3D)
|
||||
// .time(Instant.now().toEpochMilli(), WritePrecision.MS);
|
||||
//
|
||||
//
|
||||
// Point point2 = Point.measurement("ASProcessCompleteEvent")
|
||||
// .addTag("transationId", "222312")
|
||||
// .addTag("argName", "argName11")
|
||||
// .addField("argValue", 4D)
|
||||
// .time(Instant.now().toEpochMilli(), WritePrecision.MS);
|
||||
// List<Point> list = new ArrayList<>();
|
||||
// list.add(point);
|
||||
// list.add(point2);
|
||||
//
|
||||
// writeApi.writePoints(list);
|
||||
|
||||
//todo api.writeMeasurements(WritePrecision.NS, Arrays.asList(new H2OFeetMeasurement("coyote_creek", 15.0D, null, Instant.ofEpochSecond(0, 15)), new H2OFeetMeasurement("coyote_creek", 16.0D, null, Instant.ofEpochSecond(0, 16))));
|
||||
// List<Event> events = new ArrayList<>();
|
||||
@@ -105,23 +105,24 @@ public class Main {
|
||||
// }
|
||||
|
||||
|
||||
// String flux = "from(bucket:\"mytest\") |> range(start: -60m)";
|
||||
// flux += "|> filter(fn: (r) =>\n" +
|
||||
// " r._measurement == \"ASProcessCompleteEvent\" and \n" +
|
||||
//// " r._field == \"type\" and \n" + //对应 Field key
|
||||
// " r.argName == \"arg3\"\n" + //对应 Tags key (Tag 信息无法在FluxRecord 里面获取。)
|
||||
// " )";
|
||||
// QueryApi queryApi = influxDBClient.getQueryApi();
|
||||
//
|
||||
// List<FluxTable> tables = queryApi.query(flux);
|
||||
// for (FluxTable fluxTable : tables) {
|
||||
// List<FluxRecord> records = fluxTable.getRecords();
|
||||
// for (FluxRecord fluxRecord : records) {
|
||||
// System.out.println("time: "+fluxRecord.getTime() +" key:"+fluxRecord.getField()+" value: " + fluxRecord.getValueByKey("_value")+" measurement: " + fluxRecord.getMeasurement());
|
||||
//// System.out.println("time: "+fluxRecord.getTime() +" key:"++" value: " + fluxRecord.getValueByKey("_value")+" measurement: " + fluxRecord.getMeasurement());
|
||||
//
|
||||
// }
|
||||
// }
|
||||
String flux = "from(bucket:\"mytest\") |> range(start: -6000000000000000m)";
|
||||
flux += "|> filter(fn: (r) =>\n" +
|
||||
" r._measurement == \"ASProcessCompleteEvent\" and \n" +
|
||||
// " r._field == \"type\" and \n" + //对应 Field key
|
||||
" r.argName == \"arg3\"\n" + //对应 Tags key (Tag 信息无法在FluxRecord 里面获取。)
|
||||
" )";
|
||||
QueryApi queryApi = influxDBClient.getQueryApi();
|
||||
|
||||
List<FluxTable> tables = queryApi.query(flux);
|
||||
for (FluxTable fluxTable : tables) {
|
||||
List<FluxRecord> records = fluxTable.getRecords();
|
||||
for (FluxRecord fluxRecord : records) {
|
||||
Double o = (Double)fluxRecord.getValueByKey("_value");
|
||||
System.out.println("time: "+fluxRecord.getTime() +" key:"+fluxRecord.getField()+" value: " + fluxRecord.getValueByKey("_value")+" measurement: " + fluxRecord.getMeasurement());
|
||||
// System.out.println("time: "+fluxRecord.getTime() +" key:"++" value: " + fluxRecord.getValueByKey("_value")+" measurement: " + fluxRecord.getMeasurement());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// from(bucket: "mytest")
|
||||
|
||||
Reference in New Issue
Block a user