Search code examples
elasticsearchkibanaelk

can you create visuals programmatically in Kibana?


I'm new to the world of Elastic Search and Kibana and I was asked to create a script that will generate some Kibana visuals (pie charts and bar charts) according to a given argument- a csv dataset. I wanted to ask if that's even possible (with the tools that are supplied by the Kibana software; I searched for an answer but all the explanations that I found were not clear and outdated). If it is, a short explanation, guide or tutorial would be greatly appreciated.

Thanks in advance


Solution

  • Yes this is possible since visualizations and dashboards are basically written in JSON format. There is no detailed tutorial about the syntax of these saved objects. But you should get a good starting point by exporting an already existing dashboard or visualization. This will give you a NDJSON file (new line delimited JSON).

    Here's a quick guide to do that:

    https://support.logz.io/hc/en-us/articles/210207225-How-can-I-export-import-Dashboards-Searches-and-Visualizations-from-my-own-Kibana-

    With that you should be able to figure out which parts have to be variable and which static.

    A script could then use a template that fills the variable parts with the data from your csv. After the ndjson file was generated you can import them via the Kibana API described here:

    https://www.elastic.co/guide/en/kibana/master/saved-objects-api.html

    Please note that there is no function in Kibana itself to generate Visualizations programmatically. You could edit them but not generate them from scratch. So you'd need to write a script/application by yourself and call the Kibana API.

    I hope I could help you.