Mongo DB with grafana False QUERY ,new Date()

I use Grafana for monitoring. But my query isnot working.

İn my query, ı use new Date() function, for find current date. its working mongo shell But new Date() is not working on grafana.

Grafana doesnt accept functions on grafana command line , for example new ISODate(),new Date() etc.

grafana ERROR : "message " : unexpected token e in JSON position 168

{ "$year":  new Date() }       //not working

{ "$year": {"$dateFromString":{"dateString":"2018-09-08T12:10:40.787"}} }    //working

why could it be ?

1 Like

How did you even connect MongoDB with Grafana?

like this

grafana is work but, new Date() is not working on grafana