From visState to raw aggregations request

Hi all,

I'm trying to create an aggregation request from a visstate of a visualize (mainly from a data table).
I'm searching in the kibana code but didn't find anything...

What I want to do is to get the same result of an inspect data request from vis builder in Kibana...

Someone can help me ?

Thanks in advance.

Hi @Nicolap, I'll try to point you to that code, but what version of Kibana are you using?

Hi @dosant,

I found the code I need some days ago.

I paste the code I used to achive what I wanted to do:

      const startServices = await SavedObjectsServices.startServices;
      const savedObjectsClient = startServices[0].savedObjects.client;

      const vis = await savedObjectsClient.get(

      let factory;
      if (!factory) {
        factory = getEmbeddable().getEmbeddableFactory("visualization");

      const visParams = {
        filters: [],
        query: {},

      const visHandler = await factory.createFromSavedObject(, visParams);

      const aggConfig =;
      const aggsDsl = aggConfig.toDsl(); //this is the magic snippet of code :D

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