Adding variables for current dashboard time frame in infinity request body

Hey all!

I’m currently trying to implement the REST API of our external Mail Security Relay Server using the Infinity Data Source.

All words great - Except for one small issue.

The API requests to the Mail Relay Service require two key arguments date_from and date_to in the request body in order to define a time frame.

Now I’m wondering - Is there a way of using variables in there so that the timeframe I’m requesting from the API is the same as defined in the dashboard?

I’m aware that this is more of an Infinity plugin than something directly related to grafana, but as far as I can see, there’s no forum, Discord or whatever for Infinity …

I’d be very grateful for any help regarding this!

Thanks in advance and enjoy your day :slight_smile:

Tried like this. Doesn’t work unfortunately :frowning:

Okay - Getting closer.
Found out that the Relay Server can only work with one Datetime format.

Now there’s just one last problem, and that’s the “Z” character at the end.
In order to check if the variable does what I expect, I’ve added a “Text” visualization.

When I just append a “Z”, Grafana recognizes and replaces it with my actual timezone +01:00.
So I tried escaping the “Z” - And that works.

Hoooowever, this appears to be invalid JSON.

So, I feel like I’m getting closer, but I’m not quite there.

Aaaand here I go again.

So I’ve found out that just ${__to:date} already returns a ISO-8601 string, which is exactly what I need! Nice!

However … Still receiving HTTP 400 from the Relay API.

So now I’m wondering: Does Infinity even parse Grafana variables?

This is getting out of hand … Anyways.

Hello again :waving_hand:

So, ${__to:date} and ${__from:date} return ISO-8601 BUT the resulting string is also including milliseconds.

Example:
2025-03-27T12:10:23 .327 Z (without spaces)

And the API does not like that.

I’ll now close this issue and open another one asking how to remove the milliseconds from the timestamp.

C ya

1 Like