Open nilscrls opened 6 years ago
It looks like the addUserDefinedTag() method is adding a tag and not a field:
However, it looks like the standard metadata save logic would also add this as a field:
It seems like we should choose one or the other, but I'm not sure if existing users are depending on the field being there.
Well after testing it appears the functionality is broken. Using InfluxDB without tags doesn't seem pretty usefull. May I suggest you to move this check to here : https://github.com/sitewhere/sitewhere/blob/1fa2fe84b93d14da22fe41b71a0a0452a008835f/sitewhere-influx/src/main/java/com/sitewhere/influx/device/InfluxDbDeviceEvent.java#L533-L535
Example working solution :
for (String key : event.getMetadata().keySet()) {
+ if (key.startsWith("INFLUX_TAG_")) {
+ builder.tag(key, event.getMetadata(key));
+ }
+ else {
builder.addField(EVENT_METADATA_PREFIX + key, event.getMetadata(key));
+ }
}
Hi!
Using Sitewhere v1.14.0 and a Mongo/Influx datastore, if I got it correctly when you send a device measurement with "INFLUX_TAG_foo" as metadata, the "foo" tag should be added to Influx but it creates the field "INFLUX_TAG_foo" instead.
In: https://github.com/sitewhere/sitewhere/blob/1fa2fe84b93d14da22fe41b71a0a0452a008835f/sitewhere-influx/src/main/java/com/sitewhere/influx/InfluxDbDeviceEventManagement.java#L236-L240
Is this a bug or have I misunderstood the feature?