Kibana visualization request body

I want to fetch a request body associated with kibana visualization programatically, so is there API present for it?

Have you thought about Saved objects API. You can get the data from the REST API by using saved objects API.
Saved objects have a use: Kibana uses them for searches and visualizations. Be warned, Saved Objects can change over time :slight_smile: When you query the .kibana index for a search object, you'll get back a document that looks like:

If you look at the kibanaSavedObjectMeta.searchSourceJSON from a search object in the .kibana index:

$ http --auth kibana_user:11111111 localhost:9200/.kibana/search/d76780b0-c15e-11e6-b8ec-f58a80978e3d?filter_path=_source.kibanaSavedObjectMeta.searchSourceJSON
HTTP/1.1 200 OK
content-encoding: gzip
content-type: application/json; charset=UTF-8
transfer-encoding: chunked

    "_source": {
        "kibanaSavedObjectMeta": {
            "searchSourceJSON": "{\"index\":\"tweets-*\",\"query\":{\"query_string\":{\"analyze_wildcard\":true,\"query\":\"_type:avocado\"}},\"filter\":[],\"highlight\":{\"pre_tags\":[\"@kibana-highlighted-field@\"],\"post_tags\":[\"@/kibana-highlighted-field@\"],\"fields\":{\"*\":{}},\"require_field_match\":false,\"fragment_size\":2147483647}}"

If you want to see what the actual query from a saved search looks like, you can also use the Spy panel in Kibana.
Getting the data directly out of the .kibana index isn't really using a "REST API". You're using the Elasticsearch search API to get data that's managed by Kibana, and you're trying to go around Kibana to get it.

Additionally for more info: to get saved objects from Ki via API, these tests could help you:


Thanks for your inputs Rashmi.
The query which we get in searchSOurceJson by using saved objects API is different from the query in request body of the spy panel. If we use the request body in spy panel , we can fetch the the data from elasticsearch by using below URL format:
http://localhost:9200/index/type/_search?source={ request body attached with visualization of kibana in spy panel} & source_content_type=application/json.

So I want to know, Is there any way to fetch the request body in spy panel via program or any REST API.

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