Plugin for custom visualization based on hits

Hi, I'm trying to create some custom visualizations by developing kibana plugins, for example, one of them is for displaying a cumulative sum of uptime and downtime over the time, the sum should restart whenever I see a change from up to down or vice versa. To calculate that I need to use all of the records, so I need to get somehow the hits part of ES response instead of the aggs part inside my plugin, is that possible?

An alternative that I'm using is Terms aggregation on @timestamp and Terms aggregation on the other fields that I'm insterested in, but that way I'm limiting the number of records to bucket size parameter, is there a way to set the bucket size parameter to null or to remove the size parameter from my plugin so I can get all of the buckets with no limit?

Thanks,

Marlen

Since, I don't want to give a half baked answer, am redirecting this question to our Visualization team cc / @thomasneirynck

He will get to your q when he finds some time .

Cheers
Rashmi

You can also directly fetch the records your looking for. There are helpers, like callWithRequest to aide in making the ES calls through elasticsearch-js.

@Marlen,

thanks @tylersmalley, agreed that that is the best way to get custom queries to Elasticsearch.

For more information on how to write a custom visualization plugin, you might want to start with https://www.elastic.co/guide/en/kibana/master/development-visualize-index.html.

Hi @thomasneirynck and @tylersmalley, thanks for your answers, I'm a little confused, I'm using VisFactory.createAngularVisualization to create my visualization, can I use these custom queries you are talking about within this type of visualization?, do I have to use a custom requestHandler or something like that? I was able to query ES using a custom requestHandler but now I don't know how to use the response from my controller, any suggestion?

Thanks

You can probably ignore the response-handler for now, since you are working with raw data.

fwiw I would advise against using the angular-visualization, Kibana is moving away from Angular in the long term. I would just use the BasesVisualization type for a first pass.

You would get the custom response of your request in your Visualization#render(data) method. cf. https://www.elastic.co/guide/en/kibana/master/development-visualization-factory.html#development-base-visualization-type.

Alternatively, you could use the ReactVisualization type as well.

@thomasneirynck Im trying now with BaseVisualization but I still can't get the raw data, with Angular I was trying something like this within the requestHandler:

es.search({
index: 'my_index*',
body: {
query: {
match_all: {
}
}
}
}, function (response, error) {
hits = response;
console.log(response);
console.trace(error.message);
});

but I just couldn't return the data to the controller because I think it is an async function, would you share with me an example of querying raw data (hits part of ES response) with this BaseVis?

Hi @Marlen,

I think a good working example would be to look into how the Vega-plugin is structured (core_plugins/vega). It is a base-visualization, with its own custom requesthandler, and does a custom to query ES.

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