7

I created a Kibana dashboard, containing some visualization. I can successfully embed the dashboard using the provided url:

{url}/app/kibana#/dashboard/{dashboard_uuid}?embed=true&_g=(refreshInterval:(display:Off,pause:!f,value:0),time:(from:now-1y,mode:quick,to:now))

Now, I would like to have any user of my app to see this dashboard, filtered in order to only see their data. The filter query that I need is very simple, because all the data contains a field user_id.

An example: For the user with identifier $id, I want to load the dashboard with the filter user_id:$id

In there a way to set the filter through the url? I see there are some parameters already (refreshInterval, time..) but I couldn't find the proper documentation. Any ideas?

Using Kibana 6.2.2 and ElasticSearch 6.6.0

I tried setting the filters through the _a parameter, as explained here: https://discuss.elastic.co/t/dashboard-search-parameter-via-url/84385 without success.

{url}/app/kibana#/dashboard/{dashboard_uuid}?
      embed=true&
      _g=(refreshInterval:(display:Off,pause:!f,value:0),time:(from:now-1y,mode:quick,to:now))&
      _a=(filters:!(),query:(querystring:(query: "user_id:1")))
gbalduzzi
  • 9,356
  • 28
  • 58
  • I would recommend going to the dashboard, setting the filters in the GUI itself and copying the url. Then replace the value of the filter in the url by the variable. It is possible that other applications can't parse the huge kibana url. To solve this i found two options [encode special characters](https://www.urlencoder.org/) or use the [kibana url shortener](https://www.elastic.co/guide/en/kibana/6.7/url-shortening-api-api-shorten-url.html) service. – kobey Nov 19 '19 at 09:05

2 Answers2

11

I stumbled upon this while looking for a solution to a slightly similar question. I figured I would share two options that I have gotten to [mostly] work, but either should do what you are looking for.


URL With Variable Set to Application State:

../app/dashboards#/view/{dashboard_uuid}?_a=(filters:!((query:(match_phrase:(user_id:$id)))))

Using this method, the filter is not "pinned", so if you have another link on your landing dashboard, the filter will not remain if you click that link. However, your other global state settings (timeframe, etc.) do remain.


URL With Variable Set to Global State:

../app/dashboards#/view/{dashboard_uuid}?_g=(filters:!((query:(match_phrase:(user_id:$id)))))

Using this method, the filter is "pinned" and remains throughout additional clicks. However, this URL will overwrite all your other global state settings (timeframe, etc.).

This is where I am. I would like the filter to remain pinned, but if I have a time filter set as well, clicking this link will unfortunately default to the timepicker:timeDefaults setting in Kibana.


I still have not found a solution to my issue, but I hope this answers the original question; or perhaps help someone else that stumbles here (seeing as how this thread is very old now).

Mako-Wish
  • 303
  • 2
  • 12
-1

As of Kibana 7.16.3, if you just want to share a Kibana dashboard link with the filters you've set, you can create a short sharing link by clicking on the "Share" button in the upper right corner.

The short link will look like this:

https://kibana.localhost/s/example/goto/75013722-2c8c-11ee-be56-0242ac120002

When you follow the link, you will see all the filters included in the UI.

enter image description here

enter image description here

Prisacari Dmitrii
  • 1,985
  • 1
  • 23
  • 33