Lower influx time precision.

This commit is contained in:
Mark Nellemann 2022-12-17 09:48:28 +01:00
parent 9b35a6f3dc
commit 6a6fdf6d25
5 changed files with 20 additions and 41 deletions

View file

@ -2,6 +2,12 @@
All notable changes to this project will be documented in this file.
## [1.1.0] - 2022-12-17
- Lower influx time precision from milliseconds to seconds
- requires you to update server and clients to this version.
- Update *oshi* dependency (for AIX improvements).
## [1.0.24] - 2022-11-16
- Fix incorrect use of OSHI getDiskStores()
- Update dashboards
@ -40,6 +46,7 @@ All notable changes to this project will be documented in this file.
### Changed
- Updated 3rd party dependencies.
[1.1.0]: https://bitbucket.org/mnellemann/sysmon/branches/compare/v1.1.0%0Dv0.1.24
[1.0.24]: https://bitbucket.org/mnellemann/sysmon/branches/compare/v1.0.24%0Dv0.1.23
[1.0.23]: https://bitbucket.org/mnellemann/sysmon/branches/compare/v1.0.23%0Dv0.1.21
[1.0.21]: https://bitbucket.org/mnellemann/sysmon/branches/compare/v1.0.21%0Dv0.1.18

View file

@ -1,9 +1,9 @@
version = 1.0.25
version = 1.1.0
pf4jVersion = 3.7.0
slf4jVersion = 2.0.4
slf4jVersion = 2.0.5
camelVersion = 3.14.5
groovyVersion = 3.0.13
picocliVersion = 4.7.0
oshiVersion = 6.3.2
oshiVersion = 6.4.0
spockVersion = 2.3-groovy-3.0
tomljVersion = 1.1.0

View file

@ -26,14 +26,14 @@ public class ComboResultToPointProcessor implements Processor {
BatchPoints.Builder batchPoints = BatchPoints
.database(ComboResultToPointProcessor.influxDbName)
.precision(TimeUnit.MILLISECONDS);
.precision(TimeUnit.SECONDS);
for(MetricResult metricResult : comboResult.getMetricResults()) {
for(Measurement measurement : metricResult.getMeasurements()) {
Point.Builder point = Point.measurement(metricResult.getName())
.time(metricResult.getTimestamp(), TimeUnit.MILLISECONDS)
.time(metricResult.getTimestamp(), TimeUnit.SECONDS)
.tag("hostname", metricResult.getHostname())
.tag(measurement.getTags())
.fields(measurement.getFields());

View file

@ -29,46 +29,18 @@ public class MetricResultToPointProcessor implements Processor {
BatchPoints.Builder batchPoints = BatchPoints
.database(MetricResultToPointProcessor.influxDbName)
.precision(TimeUnit.MILLISECONDS)
.precision(TimeUnit.SECONDS)
.tag("hostname", metricResult.getHostname());
for(Measurement measurement : measurementList) {
Point.Builder point = Point.measurement(metricResult.getName())
.time(metricResult.getTimestamp(), TimeUnit.MILLISECONDS)
.time(metricResult.getTimestamp(), TimeUnit.SECONDS)
.fields(measurement.getFields())
.tag(measurement.getTags());
/*
for (Map.Entry<String,String> entry : measurement.getTags().entrySet()) {
//log.info("process() - tag: " + entry.getKey() + "=" + entry.getValue());
point.tag(entry.getKey(), entry.getValue());
}*/
/*
for (Map.Entry<String,Object> entry : measurement.getFields().entrySet()) {
//log.info("process() - field: " + entry.getKey() + "=" + entry.getValue());
if(entry.getValue() instanceof Float) {
float num = (float) entry.getValue();
point.addField(entry.getKey(), num);
} else if(entry.getValue() instanceof Long) {
long num = (long) entry.getValue();
point.addField(entry.getKey(), num);
} else if(entry.getValue() instanceof Integer) {
int num = (int) entry.getValue();
point.addField(entry.getKey(), num);
} else if(entry.getValue() instanceof Boolean) {
boolean bol = (Boolean) entry.getValue();
point.addField(entry.getKey(), bol);
} else if(entry.getValue() instanceof Number) {
Number num = (Number) entry.getValue();
point.addField(entry.getKey(), num);
} else {
String str = (String) entry.getValue();
point.addField(entry.getKey(), str);
}
}*/
batchPoints.point(point.build());
}
exchange.getIn().setBody(batchPoints.build());

View file

@ -10,7 +10,7 @@ public class MetricResult implements Serializable {
private String name;
private String hostname;
private Long timestamp; // epoch milli
private Long timestamp; // epoch seconds
private ArrayList<Measurement> measurements;
public MetricResult() {
@ -18,12 +18,12 @@ public class MetricResult implements Serializable {
public MetricResult(String name) {
this.name = name;
this.timestamp = Instant.now().toEpochMilli();
this.timestamp = Instant.now().getEpochSecond();
}
public MetricResult(String name, Measurement measurement) {
this.name = name;
this.timestamp = Instant.now().toEpochMilli();
this.timestamp = Instant.now().getEpochSecond();
this.measurements = new ArrayList<Measurement>() {{
add(measurement);
}};
@ -31,7 +31,7 @@ public class MetricResult implements Serializable {
public MetricResult(String name, ArrayList<Measurement> measurements) {
this.name = name;
this.timestamp = Instant.now().toEpochMilli();
this.timestamp = Instant.now().getEpochSecond();
this.measurements = measurements;
}