# Get Kibana queries to execute them later directly into ElasticSearch

**URL:** <https://discuss.elastic.co/t/get-kibana-queries-to-execute-them-later-directly-into-elasticsearch/169595>\
**Category:** Kibana\
**Created:** [February 22, 2019, 2:37pm UTC](https://discuss.elastic.co/t/get-kibana-queries-to-execute-them-later-directly-into-elasticsearch/169595 "2019-02-22T14:37:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carlos\_Lopez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlos_lopez/32/69105_2.png) [@Carlos\_Lopez](https://discuss.elastic.co/u/Carlos_Lopez)\
**Post date:** [February 22, 2019, 2:37pm UTC](https://discuss.elastic.co/t/get-kibana-queries-to-execute-them-later-directly-into-elasticsearch/169595/1 "2019-02-22T14:37:15Z")

</div>

We've been using Kibana (v6.4) for a while and found a way of integrating the application as an Iframe in our web application.

We got a new requirement where the user saves a "Search" and then we reuse the results of that search for internal tasks.

I saw the Kibana Object API, and I can retrieve the searches an User has stored, but it returns a result like:

```
{
        "id": "2e3fd100-3618-11e9-a719-419d60b7873d",
        "type": "search",
        "updated_at": "2019-02-21T20:35:09.456Z",
        "version": 1,
        "attributes": {
            "title": "Carlos Search",
            "description": "",
            "hits": 0,
            "columns": [
                "billingProduct"
            ],
            "sort": [
                "createdOn",
                "desc"
            ],
            "version": 1,
            "kibanaSavedObjectMeta": {
                "searchSourceJSON": "{\"index\":\"e8ec21c0-f996-11e8-950b-03302d77bc99\",\"highlightAll\":true,\"version\":true,\"query\":{\"language\":\"lucene\",\"query\":\"\"},\"filter\":[{\"meta\":{\"negate\":false,\"index\":\"e8ec21c0-f996-11e8-950b-03302d77bc99\",\"type\":\"phrase\",\"key\":\"eventStatus\",\"value\":\"DELIVRD\",\"params\":{\"query\":\"DELIVRD\",\"type\":\"phrase\"},\"disabled\":false,\"alias\":null},\"query\":{\"match\":{\"eventStatus\":{\"query\":\"DELIVRD\",\"type\":\"phrase\"}}},\"$state\":{\"store\":\"appState\"}}]}"
            }
        }
    }

```

If I want to use the searchSourceJSON directly into ElasticSearch it needs to be modified and still it doesn't have all the filters / Columns the user used when saving the "Search".

Is there a way to get the queries that Kibana executes when searching to be reused later on directly onto ElasticSearch?

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [February 22, 2019, 2:58pm UTC](https://discuss.elastic.co/t/get-kibana-queries-to-execute-them-later-directly-into-elasticsearch/169595/2 "2019-02-22T14:58:03Z")

</div>

There isn't nay way unless you do a MITM and intercept the request done to the Elasticsearch server. You can see the actual requests manually in the Dev Tools of your browser when loading a saved search.

---

<div class="post-metadata">

**Author:** ![stiltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stiltz/32/39714_2.png) [@stiltz](https://discuss.elastic.co/u/stiltz)\
**Post date:** [February 22, 2019, 3:18pm UTC](https://discuss.elastic.co/t/get-kibana-queries-to-execute-them-later-directly-into-elasticsearch/169595/3 "2019-02-22T15:18:58Z")

</div>

I think there is a way to do this. It is how I take my Kibana queries and convert them to watcher searchers.  
In version 6.5 and lower you can run your kibana query and then under the histogram there is a little arrow on the left. Click that and you'll have options for **Table** , **Request** , **Response** , and **Statistics**. If you click on Request you'll see the json behind your query.  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/b/3b93329ca2edd05bd6393f8752d4f9fac30e0b80.png)

In version 6.6 (and newer?) you can run your kibana query and then click **Inspect** in the top bar of kibana.  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/6/d6032ad4ee3de02a21ba8d8cd69ab60bb8b71946.png)  
This will open a new box within kibana. Click the **Request** tab and then the json for your query will be in there.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/3/a34f0ee02299ec12ead7cc9c7dc65e2065fedcd4.png)  
In v6.6 (and newer?) there is a lot of extra formatting in the json so you'll have to sort through some of the json to cut out the parts you won't need.

Hope that helps!

---

<div class="post-metadata">

**Author:** ![Carlos\_Lopez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlos_lopez/32/69105_2.png) [@Carlos\_Lopez](https://discuss.elastic.co/u/Carlos_Lopez)\
**Post date:** [February 22, 2019, 3:56pm UTC](https://discuss.elastic.co/t/get-kibana-queries-to-execute-them-later-directly-into-elasticsearch/169595/4 "2019-02-22T15:56:09Z")

</div>

Thanks, That's pretty much what I need, but in a programmatically way. Is there a way to do it? Like taking it from the back end and send the query to Elastic?

---

<div class="post-metadata">

**Author:** ![stiltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stiltz/32/39714_2.png) [@stiltz](https://discuss.elastic.co/u/stiltz)\
**Post date:** [February 22, 2019, 5:43pm UTC](https://discuss.elastic.co/t/get-kibana-queries-to-execute-them-later-directly-into-elasticsearch/169595/5 "2019-02-22T17:43:04Z")

</div>

I've never tried but perhaps this thread will give you some ideas?

> [@Log queries performed in kibana to the output log using a plugin](https://discuss.elastic.co/t/log-queries-performed-in-kibana-to-the-output-log-using-a-plugin/86979/6):
>
> @tsmalley I had already tried setting on kibana.cfg: logging.verbose: true elasticsearch.logQueries: true But I can not see the query string, I do see JSON for internal operations... but no user query JSON. ops [15:11:53.389] memory: 136.9MB uptime: 0:01:08 load: [3.44 3.01 2.83] delay: 0.215 log [15:11:53.390] [debug][monitoring-ui] Received Monitoring event data respons [15:11:53.964] GET /ui/favicons/favicon.ico 304 2ms - 9.0B respons [15:11:53.976] POST /elasticsearch/\_msearch 200 …

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 22, 2019, 5:43pm UTC](https://discuss.elastic.co/t/get-kibana-queries-to-execute-them-later-directly-into-elasticsearch/169595/6 "2019-03-22T17:43:10Z")

</div>

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