How to compute difference between 2 fields based on 3rd field

Hello,

I have the current use case:

  • We have a system that computes different response time metrics for messages that we want to insert in InfluxDB. This system writes JSON entries to a file.
  • We use telegraf with JSON plugin to extract the fields we want and insert into InfluxDB.

So far so good.

But we have an issue with 1 particular information.
The system will emit messages where mId is the Unique identifier, in the below examples we have 2 uuidXXXX and uuidYYYY:

{“meta1”:“value”, “mId”:“uuidXXXX”, “resTime1”:1232332233, “timeWeEnterBus”:startTimestamp}
{“meta1”:“value2”, “mId”:“uuidYYYY”, “resTime1”:1232331111, “timeWeEnterBus”:startTimestamp}
{“meta1”:“value”, “mId”:“uuidXXXX”, “resTime1”:1232332233, “timeWeExitBus”:endTimestamp}
{“meta1”:“value2”, “mId”:“uuidYYYY”, “resTime1”:1232331111, “timeWeEnterBus”:startTimestamp}

And what we want here is to graph the timeInBus which is equal to “timeWeExitBus-timeWeEnterBus” for each unique mId.

So my questions are:

  • IMU, uuid would be a field not a tag as it is unlimited, same for timeWeExitBus and timeWeEnterBus which would be numeric fields since we want to use functions on them. And timeInBus would be the measurement
  • Is this use case a good one for Influx / Telegraf or are we misusing it for this ? IMU, it doesn’t look like a good use case to try to compute this on telegraf side, but I don’t see how to do it in InfluxDB , I initially though ELAPSED could help but I end up thinking it doesn’t work here
  • If it’s a good use case, could you point me to documentation helping implementing this ?

Thanks a lot for any help
Regards

Hello,
Any insights on this ?

Thanks

I’d say it’s not the right tool. At least I don’t see how to make it work.

You want to group by uuid. You can only group by tag. You can’t make uuid a tag because cardinality will explode. I don’t see how to overcome this.