Need to apply filter to KIBANA dashboard automatically through html

My idea is that I have 2 cards - Virat Kohli and Leo Messi. And in the dashboard, I have 1 dashboard named "main" and in that, I have a filter called "event". In the "event" I have given 2 topics - viratkohli and lionelmessi. So, if I click one of the cards on the HTML page it should apply that filter in the dashboard and the results should be shown. Suppose I click on a Leo Messi card, in the dashboard named "main" the "event" should automatically change to "lionelmessi" and the changes should be applied. Is it possible? And if yes, how?

You can search this forum for similar questions, like this one

Briefly, there is no public API for dashboard URL parameters so you need to inspect your URLs manually. or just copy the whole string for each case and update your iframe with it. In any case this is going to be weak and will need update with any upgrade of the stack.

Worth also mentioning that maybe you can do the full experience inside kibana using drilldowns to offer a generic dashboard with the main options that navigates to a detailed dashboard filtered by the selected option.

So, this is the link to my dashboard without applying the filter :
Elastic)

And this is the link to my dashboard after applying the filter:
Elastic)

There is no change between the links whatsoever. So, how do I make it dynamic so as to access the dashboard only for the certain card?

You need a snapshot URL, available on the share menu on the top right corner

So for example, for that dashboard from the screenshot above about New York city 311 calls I can filter:

Hope it helps!

I've got this code. If it's possible can you please check and tell me that it is correct? I've also put in the id of my dashboard.

const axios = require('axios');

async function updateFilters() {
  try {
    const response = await axios.post(
      '/api/kibana/dashboards/e1af0b80-8285-11ed-8b1c-73fa260fa999/_update_filter',
      {
        // replace e1af0b80-8285-11ed-8b1c-73fa260fa999 with the ID of the dashboard
        filters: [
          {
            query: {
              match_phrase: {
                event: 'lionelmessi'
              }
            }
          }
        ]
      },
      {
        headers: {
          // replace YOUR_API_KEY with your API key
          'kbn-xsrf': 'API_KEY'
        }
      }
    );
    console.log(response.data);
  } catch (error) {
    console.error(error);
  }
}

updateFilters();

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