# How export logs from Kibana 4?

**URL:** https://discuss.elastic.co/t/how-export-logs-from-kibana-4/186
**Category:** Kibana
**Created:** [May 5, 2015, 7:47am UTC](https://discuss.elastic.co/t/how-export-logs-from-kibana-4/186 "2015-05-05T07:47:45Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Dnyaneshwar](https://avatars.discourse-cdn.com/v4/letter/d/a4c791/32.png) [@Dnyaneshwar](https://discuss.elastic.co/u/Dnyaneshwar)
#### Post date: [May 5, 2015, 7:47am UTC](https://discuss.elastic.co/t/how-export-logs-from-kibana-4/186/1 "2015-05-05T07:47:45Z")

</div>

I have tried the export button in kibana 4, but it export the table with timestamp and count column.. there is not logs.

How export logs from Kibana 4 ?

Thanks

---

<div class="post-metadata">

### Author: ![tylerjl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tylerjl/32/44965_2.png) [@tylerjl](https://discuss.elastic.co/u/tylerjl)
#### Post date: [May 5, 2015, 6:46pm UTC](https://discuss.elastic.co/t/how-export-logs-from-kibana-4/186/2 "2015-05-05T18:46:27Z")

</div>

When you look at the export for a table in Kibana, you're seeing what Elasticsearch returned to Kibana in answer to a specific query - Kibana can ask to get back a histogram, for example, so the export is just a dump of that summarized data that Kibana got back from a query like that.

If you're looking to actually export logs from Elasticsearch, you probably want to save them somewhere, so viewing them in the browser probably isn't the best way to view hundreds or thousands of logs. There are a couple of options here:

- In the "Discover" tab, you can click on the arrow tab near the bottom to see the raw request and response. You could click "Request" and use that as a query to ES with `curl` (or something similar) to query ES for the logs you want.
- You could use logstash or [stream2es](https://github.com/elastic/stream2es) to dump out the contents of a index (with possible query parameters to get the specific documents you want.)

---

<div class="post-metadata">

### Author: ![bizmate](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bizmate/32/24977_2.png) [@bizmate](https://discuss.elastic.co/u/bizmate)
#### Post date: [July 4, 2017, 11:58am UTC](https://discuss.elastic.co/t/how-export-logs-from-kibana-4/186/3 "2017-07-04T11:58:47Z")

</div>

Does this button still exists on the latest Kibana? I cannot see it. Anyway to enable it rather than using logstash plugins?

---

<div class="post-metadata">

### Author: ![tylerjl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tylerjl/32/44965_2.png) [@tylerjl](https://discuss.elastic.co/u/tylerjl)
#### Post date: [July 5, 2017, 3:03pm UTC](https://discuss.elastic.co/t/how-export-logs-from-kibana-4/186/4 "2017-07-05T15:03:28Z")

</div>

It's still there. To view the underlying REST request and response that Kibana uses to fetch the raw data use this popup arrow:

 ![](https://us1.discourse-cdn.com/elastic/original/3X/0/7/07db01877ace839e0036ac1f432d3a7ed3fd6289.png)

Which will expose the following panel:

 ![](https://us1.discourse-cdn.com/elastic/original/3X/8/7/870b84ec970fa14bdbdafc1075b10187dbf6926f.png)

Clicking on "`Request`" will show you the REST API request used to retrieve the search results, and clicking on "`Response`" will show the raw response from Elasticsearch itself.

---

<div class="post-metadata">

### Author: ![\_kyllr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/_kyllr/32/27610_2.png) [@\_kyllr](https://discuss.elastic.co/u/_kyllr)
#### Post date: [February 8, 2018, 3:39am UTC](https://discuss.elastic.co/t/how-export-logs-from-kibana-4/186/5 "2018-02-08T03:39:42Z")

</div>

> [@tylerjl](#):
>
> raw response from Elasticsearch

How can I export raw response from Elasticsearch?

---

<div class="post-metadata">

### Author: ![tylerjl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tylerjl/32/44965_2.png) [@tylerjl](https://discuss.elastic.co/u/tylerjl)
#### Post date: [February 8, 2018, 8:15pm UTC](https://discuss.elastic.co/t/how-export-logs-from-kibana-4/186/6 "2018-02-08T20:15:35Z")

</div>

The simplest way would be to find the query you need from Kibana (or just query for all documents in the index you're interested in) and run it in a small script to export documents.

---

<div class="post-metadata">

### Author: ![LoriD](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@LoriD](https://discuss.elastic.co/u/LoriD)
#### Post date: [July 17, 2018, 7:52pm UTC](https://discuss.elastic.co/t/how-export-logs-from-kibana-4/186/7 "2018-07-17T19:52:35Z")

</div>

Hi Tyler,

Could you add some detail about how to run a small script to export documents? Currently the only way I can download search results that appear in the sample data section in Discover is to manually highlight them all, copy and then paste everything into Excel.

Thank you!

---

<div class="post-metadata">

### Author: ![tylerjl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tylerjl/32/44965_2.png) [@tylerjl](https://discuss.elastic.co/u/tylerjl)
#### Post date: [July 17, 2018, 10:47pm UTC](https://discuss.elastic.co/t/how-export-logs-from-kibana-4/186/8 "2018-07-17T22:47:34Z")

</div>

@LoriD everybody's needs are different, and to export logs generally out of Elasticsearch, you would need to retrieve all documents from an index which you could then put into whatever system you ultimately need the documents in. Tools like Logstash can transform data into forms you need in a powerful way, but to simply dump all documents from an index, you would need to [open a scroll](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html) and retrieve all documents from the index. At the end of the day, you would end up with many json documents.

The best detail I can give is an example script that would do what I'm describing. The following bash script would dump all documents in an index for the last 15 minutes, effectively creating a `dump.json` file that contains all the documents that you'd normally find in a default kibana dashboard (I use the [httpie](https://httpie.org/) and [jq](https://stedolan.github.io/jq/) utilities in this script):

```auto
#!/usr/bin/env bash

usage="Usage: ${0} <elasticsearch url> <index>"
: ${1?:$usage}
: ${2?:$usage}

es=${1}
initial=$(http -b $es/${2}/_search scroll==1m size==500 q=="@timestamp:>=now-15m")
scroll_id=$(echo $initial | jq -r '."_scroll_id"')
echo "Scroll id: ${scroll_id}"
hits=$(echo $initial | jq -r '.hits.hits | length')
echo $initial | jq '.hits.hits[]' > dump.json

until [[$hits -eq 0]]
do
    results=$(http -b $es/_search/scroll scroll=1m scroll_id="${scroll_id}")
    echo $results | jq '.hits.hits[]' >> dump.json
    hits=$(echo $results | jq -r '.hits.hits | length')
done

http -b DELETE $es/_search/scroll scroll_id=$scroll_id

```

That's a very simple example of how to use the scroll API to retrieve _all_ documents for a given index.

---

<div class="post-metadata">

### Author: ![Tiny\_Jacob](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tiny_jacob/32/46431_2.png) [@Tiny\_Jacob](https://discuss.elastic.co/u/Tiny_Jacob)
#### Post date: [August 4, 2020, 7:51am UTC](https://discuss.elastic.co/t/how-export-logs-from-kibana-4/186/9 "2020-08-04T07:51:06Z")

</div>

Hi Tyler,  
Is it possible to pull out error logs only from Kibana?

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [August 4, 2020, 8:53am UTC](https://discuss.elastic.co/t/how-export-logs-from-kibana-4/186/10 "2020-08-04T08:53:32Z")

</div>

Please open a new thread with your question.

---

<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: [November 4, 2022, 3:58am UTC](https://discuss.elastic.co/t/how-export-logs-from-kibana-4/186/11 "2022-11-04T03:58:56Z")

</div>


