How to test against current day/month/year?

Hello,
I am using Influx & Kapacitor to process data coming from various applications. Each application sends an event (a ‘subscription’) as soon as a business user performs an action with this application. Each hour for a given month, I need to generate a measurement (subscriber, value is total number of subscribers") containing the total number of subscriptions received so far.
I was planning to:

  • use a batch node
  • perform a query for counting all subscriptions for a current day
  • store this count to a new measurement (total_subscriptions)

It should look something like this:
batch
| query(‘select “dummy_value” from “mydb”.“autogen”.subscription where day(time) == day(now())’
.count()
.as('total_count)
| log()
| influxDBOut()
.database(“mydb”)
.measurement(“subscriber”)
.tag(“computed”,‘true’)

My question is how can I write my query as I haven’t found any way of extracting the day from the ‘now()’ function as well as getting the current day/month/year?

Thank you very much for your help!

Thanks for your help!

I would look at the time functions in the docs. I think you can do this with a lambda like so:

|where(lambda: day(“time”) == day(now())

Let me know if that helps!

@Katy thanks a lot, yes it does help though I am really struggling with the error messages from the TICK script editor embedded in Chronograf.

It would help us if you filed an issue so we can improve the experience. We love to hear feedback!