Date field in json query

New to Grafana. I’m using Infinity plugin to call a Cisco API. I need to put the times in the JSON body. I’d like to do from midnight to current time. Currently I put it in manually. How do I automate this?

{
    "aggregationInterval": "1d",
    "timestamp": [
        "2024-08-07T00:00:00Z",
        "2024-08-07T16:38:00Z"
    ],
    "aggregateBy": "verdicts"
}

Assuming that Grafana’s time picker is set to ‘Last something’ (i.e. Last 6 hours) you may try to use built-in to variable. Something like this:

${__to:date:YYYY-MM-DDT00:00:00Z}

${__to:date:YYYY-MM-DDTHH:mm:ssZ}

2 Likes

Thank you, that worked. Had to quote the date fields for the json


{
    "aggregationInterval": "1d",
    "timestamp": [
       "${__to:date:YYYY-MM-DDT00:00:00Z}",
       "${__to:date:YYYY-MM-DDTHH:mm:ssZ}"
    ],
    "aggregateBy": "verdicts"
}