Convert string to date

Hey,

I am trying to create an alert which checks if there is a problematic worker which doesn’t take tasks from rabbitmq queue.
They way for us to indicate it is: If tasks_ready > X AND queue idle_since > now() - 10m.

The problem is that Telegraf’s rabbitmq plugin returns idle_since as string instead of time, and I just can query over it.
tried so many functions and still it doesn’t work.

the query must also work with Kapacitor.

queries examples:
select last(idle_since) from rabbitmq_queue where last > now() - 1h group by queue limit 1 - 0 value returned
select last(idle_since) from rabbitmq_queue where last < now() - 1h group by queue limit 1 - 0 value returned
select last(idle_since) from rabbitmq_queue group by queue limit 1:
name: rabbitmq_queue
tags: queue=bla3
time last


1535011291000000000 2018-08-23 7:15:58

name: rabbitmq_queue
tags: queue=bla2
time last


1535023021000000000 2018-08-23 11:16:01

name: rabbitmq_queue
tags: queue=bla1
time last


1535023021000000000 2018-08-23 10:59:59

How can I query that when it’s not a date?

InfluxDB only supports four data types for fields: integers, floats, booleans, and strings. There is no support for time fields, or for casting a string to time and performing operations on it, so a query that compares the idle_since string value to a time will not work.

It seems like adding another field to the RabbiqMQ plugin—let’s call it idle_for—might be useful. The plugin could calculate the difference, in seconds, between the current time and the idle_since time and store that value as a float. Then your query could check that the value of the idle_for field is greater than 600.

If that sounds like a useful approach, go ahead and open a feature request issue on GitHub. Or even better, a pull request!