Java apis to create visualization in kibana

Is there any way I can create visualization in kibana from java api?

To be more specific my requirement is -

  1. I have a portal page where user can define different parameters
  2. When user submit requests, in background (java code) I want to create visualization using the provided parameters
  3. Then get the iframe and embed it on to the page for user.

Any pointers to this will be very helpful.

Thanks,
Abhishek

Hi Abhishek,

Yes, you can write a Java application that uses Elasticsearch APIs to create documents for the .kibana index. That's the index that stores the settings for Kibana's Index Patterns, Visualizations, Dashboards, Saved Searches, etc.

To get started, I would suggest manually create and save some visualizations and then use the Sense plugin to explore the structure of the .kibana index.

What do you mean by create document for the .kibana index. Do you mean visualization right? not creating ELASTICSEARCH document?

Also I am not able to find .kibana index. Is it available in Version 4.0.3 ?

Sorry, I didn't realize you are using Kibana 4.0.3.

In newer versions of Kibana, 4.1+, there is an index for Kibana that stores all of the saved objects. So if you had Kibana 4.5 and the Sense plugin, you could do something like:

GET .kibana/visualization/_search

And you'd see result documents that look like (this is one generated by Beats Dashboard creator):

{
  "_index": ".kibana",
  "_type": "visualization",
  "_id": "Servers",
  "_score": 1,
  "_source": {
    "visState": "{\"type\":\"table\",\"params\":{\"perPage\":10,\"showPartialRows\":false,\"showMeticsAtAllLevels\":false},\"aggs\":[{\"id\":\"1\",\"type\":\"avg\",\"schema\":\"metric\",\"params\":{\"field\":\"cpu.user_p\"}},{\"id\":\"3\",\"type\":\"avg\",\"schema\":\"metric\",\"params\":{\"field\":\"cpu.system_p\"}},{\"id\":\"4\",\"type\":\"max\",\"schema\":\"metric\",\"params\":{\"field\":\"mem.total\"}},{\"id\":\"5\",\"type\":\"max\",\"schema\":\"metric\",\"params\":{\"field\":\"mem.used\"}},{\"id\":\"8\",\"type\":\"max\",\"schema\":\"metric\",\"params\":{\"field\":\"mem.used_p\"}},{\"id\":\"6\",\"type\":\"max\",\"schema\":\"metric\",\"params\":{\"field\":\"mem.free\"}},{\"id\":\"9\",\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"beat.name\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}],\"listeners\":{}}",
    "description": "",
    "title": "Servers",
    "version": 1,
    "savedSearchId": "System-stats",
    "kibanaSavedObjectMeta": {
      "searchSourceJSON": "{\"filter\":[]}"
    }
  }
}

So if you could programatically create those kind of documents yourself, and index them into the .kibana index.

But I am not sure exactly how this could be done in Kibana 4.0.x. It must have some method of storing saved objects in an Elasticsearch index.

1 Like

Thanks Tim. I looked at the documentation. For 4.1 onwards they do have mentioned for .kibana index but not before that. So I am not sure whether it is possible or not

I found it with index name .kibana-4.
Thanks for the help.

1 Like