Kibana dashboard URL with time filter

I want to generate a URL for a kibana dashboard that pre-loads a specific time range, I have the time in time format when event occured and i want to display 2h less and 2h plus that time
Is there some way to generate it?
I can generate:


i see as well that i can use:


But it fails if i use:




can anyone managed to build a URL like this?


Datemath can't be mixed with static dates like this, you will have to do that calculation wherever you are generating those urls.

In Javascript for example it would work like this:

// give me the time four hours ago
const date = new Date("2020-03-13T15:34:19Z");
date.setHours(date.getHours() - 4);
const updatedISOString = date.toISOString();
1 Like

Thanks Joe! i'm using elastalert and was trying to generate a URL in the email alert to take the notified person to see the information, dont think i can use javascript in elastalert

Actually, maybe it is possible.

I just checked the code and it should work when the math part is separated by || from the static time part. Also see here:

Example: 2015-05-05T00:00:00||+1d-1m

Kibana doesn’t support the full datemath Elasticsearch does, but from what I can tell this specific thing should work (haven’t tested though). Sorry for my initial misleading answer, I was pretty certain that specific syntax was Elasticsearch only, but I’m not so sure anymore.

Let me know whether it works for your use case.

1 Like

Great Joe! that worked, i'm putting the code here for reference, in this case i used the date less 4h and plus 1h.

thanks a lot!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.