Creating a counter

Hi all,

I am trying to implement a counter, so that I need to increment the value of the only field in my schema if the record (tag set + timestamp in seconds) already exists, which is often the case. For example, a given tenant sends 3 messages to the same destination within the same second (we are running a SMS Hub)

sms,geo=ES, tenant=101 counter=1 1724258870
sms,geo=ES, tenant=101 counter=1 1724258870
sms,geo=ES, tenant=101 counter=1 1724258870

My expected result would be

_time                 _measurement  geo   tenant  counter
--------------------  ------------  ---   ----    ----
2024-08-21T18:47:50Z  sms           ES    101     3

But I get counter=1 because the tag set and the timestamp is the same.

I want to avoid having to maintain state in the client side to increment the counter before sending it the influx (it would be complex, as the time value is external - coming from mobile operators - and we may get a point for a given timestamp X at X, or a X+any number of seconds - up to 2-3 days)

Query then insert is not an option either, as it will heavily impact the performance of the system and we will not be able to maintain real-time stats (which is the main goal of this project). We are processing tens of thousands of points per second at peak times.

I have read this article, which is exactly the problem I have, but before implementing any of the methods explained here (they all seem a “hack”), I wanted to make sure there is no other way to do it.

Thanks.

@Luis_Gasca There really isn’t any other way to do it. This would have to be done client-side. Any points with the same timestamp and tag set will overwrite existing field values with new field values included with the point. The counter field has to be updated before writing it to InfluxDB.