How to link Kibana URL for log in Alert?

I have an alert where I am sending certain data from log in alert which is working as expected. What I want to do is, I also want to include URL in alert but not sure about one particular id.

i.e. http://MY-URL.com/_plugin/kibana/app/kibana#/doc/SOME-GUID/app-metrics-2020.02.06/_doc?id=DOC-ID&_g=()

Here is my way to create URL,
http://MY-URL.com/_plugin/kibana/app/kibana#/doc/NOT-SURE-WHERE-TO-GET-THIS/{{ ctx.results.0.hits.hits.0._index }}/_doc?id={{ ctx.results.0.hits.hits.0._id }}

Is there a way I can get NOT-SURE-WHERE-TO-GET-THIS from ctx?

Unfortunately it won't be available in ctx. It's the index pattern id saved in the .kibana index. It is fixed to the kibana index pattern that's being searched over, so if the alert is fixed to a known index pattern you could grab that id. You can see it in the URL in the discover page.

A hacky workaround that may or may not have performance impacts is to create an index pattern in kibana that matches all indices (*) and use that id.

image

I can't say I'd recommend it, it may produce some unnecessarily large queries when setting up but could be considered as an alternative

In that case, what is the best practice you would recommend to pull the log for unique id and create URL?

Can I create search where I can update this unique id based on alert?

i.e. https://SOME-URL/ID/{{ctx.results.0.hits.hits.0._id}}

When you say index pattern id is saved, do you mean it will be always same? i.e. same for day, month Vs always same.

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