Dear all,
i am trying to achieve to get a notification if a new value (new row with a newer timestamp) have been added to a measurement. Is there any way to do this using a Task or a Check?
Thanks and BR,
Tobias
Dear all,
i am trying to achieve to get a notification if a new value (new row with a newer timestamp) have been added to a measurement. Is there any way to do this using a Task or a Check?
Thanks and BR,
Tobias
Could you provide a small example of the rows , and what you’re wanting to test/alert for?
Query:
from(bucket: "TestBucket")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "movements")
|> filter(fn: (r) => r["_field"] == "csv")
Here you see the result
So, every time a new row (a new csv string) have been added I want to send a notification with some infos of that string. I could do this via a Telegraf Output plugin but am looking for a solution to directly use the InfluxDB own Notification/Alert system.
Thanks an BR,
Tobias
You honestly might be better off exploring those other alternatives. The two built in alert types are the threshold check and deadman check. If I understand your goal, you want to record all events and then sent a single summary alert of the latest “batch”.
If using influxdb for this, you would probably need to use a task that stores the last read/process event in its own table/measurement, and then collects all new events from this point in time onwards to now.
The built in alerts currently
Creating a set of tasks to achieve what you want:
So I finally found out how I can get this done.
option task = {name: "csv_detection", every: 10s}
lastDetected = from(bucket: "notifications")
|> range(start: 0)
|> filter(fn: (r) => r["_measurement"] == "movements" and r["sub_area"] == "T1")
|> filter(fn: (r) => r["_field"] == "csv")
|> last()
|> findRecord(
fn: (key) => true,
idx: 0,
)
from(bucket: "SourceBucket")
|> range(start: if exists lastDetected._time then lastDetected._time else time(v: "1970-01-01T00:00:00Z"))
|> filter(fn: (r) => r["_measurement"] == "movements" and r["sub_area"] == "T1")
|> filter(fn: (r) => r["_field"] == "csv")
|> to(bucket: "notifications")
This does the job absolutely perfect!