Creating Health Dashboard - filter data using transformation with Time field and regex (help request)

Hi,

I’m using the [[input.exec]] input to run pgrep commands in order to verify whether a process is up and running or down.

The setup is very easy actually. I use Telegraf with an input like this (this one is for Nginx):

[[inputs.exec]]
  commands = ["pgrep -c nginx"]
  name_override = "nr_processes"
  data_format = "value"
  data_type = "integer"
  interval = "5m"
  [inputs.exec.tags]
    instance = "Nginx"

In Grafana I also do a very straightforward query look-up in the InfluxDB and I want all records back in the result, so this almost as default as it gets:

SELECT "value" FROM "nr_processes" WHERE $timeFilter GROUP BY "instance", "host"::tag ORDER BY time DESC

Same query from above, but in editor mode:

So far so good, right?

Since I still want all results/instance tags (eg. Nginx, Redis and other services) in the results as long as it is within the selected time range, I don’t filter them yet… Or do any other strange checks in the query I used showed.

I do use the “Stat” visualization and selected “Last *” calculation in the Value options, together with basic value mapping to either give a ‘OK’ checkbox or ‘NOK’ cross:

Now my question is, even if some service is down for a period of time (like Redis in my example), the result should still pop-up, otherwise Redis will not be displayed.

However with the current setup there is always a result of ‘Redis’ using Last or Last * with the Stats widget. The underlying data has a Redis result from maybe 2 months ago (if the selected time range is big enough). Even if Redis is actually down for weeks already. So you will get (this is incorrect):

Now, I try to use transformation, “Filter data by values” to be precise. And then use the Time file (which is a timestamp), with a bit of Regex, I manually get it working using a static value of Unix timestamp:

Now my question: Can I use now() or $__now maybe in the Filter data by value transformation Regex value field, instead of hard-coded timestamp I now have?

And of course it can’t be the full now timestamp, but stripped a little at the end, to get the last day or so.
Like shown above. Full timestamp of today would be: 1729670740, the example above uses: 17296. Can somebody help me here?

I’m also open for other ideas or implementations. Just be sure you don’t filter out null-values or empty value records, since otherwise Redis will not even be listed in the overview. After all I wanted all services listed, also services that aren’t inserting records anymore.

Thanks!

Regards,
Melroy van den Berg