IT technical memo of networking

Patch to Kibana 5 and export CSV from the Discover tab


In this article I built a feature addition version that can be exported from Discover tab of Kibana, but honestly it took quite a lot of trouble.

Over time, there seems to be someone who created the same function as a patch, so I tried using it.

How to use the Kibana Export patch

The usage method introduced by the creator is as follows. After confirming the contents, the patch was the contents of the src directory. Delete optimize after replacing it and recreate it at startup. (Automatically)

tar -zcvf optimize-backup.tar.gz
rm -rf optimize
tar -zxvf csv-export-patch.tar.gz
rm -f csv-export-patch.tar.gz

Deploy with Docker

Kibana already runs and deploys the patched version of Kibana as a Docker container to avoid conflicts.

I made it possible to deploy with Docker-Compose. In addition, parameters related to Elasticseach are not designed to read from environment variables, and the config directory is mounted.

$ tree
├── docker-compose.yml
└── kibana_5.3
    ├── Dockerfile
    └── config
        └── etc
            ├── kibana.log
            └── kibana.yml

The base image is simply created from CentOS. The Elastic Official feels that it is heavy startup with multiple functions such as X-Pack installation. Since the existing Elasticsearch is Ver.5.3.0, Kibana also has versions. Since patches are released for each version, use the corresponding version.

$ sudo vi ./kibana_5.3/Dockerfile
FROM centos

RUN rpm --import
RUN echo $'[kibana-5.x]\n\
name=Kibana repository for 5.x packages\n\
type=rpm-md' > /etc/yum.repos.d/elastic.repo

RUN yum install -y kibana-5.3.0-1 && yum clean all

WORKDIR /usr/share/kibana
RUN curl -OL
RUN tar -xzvf ./csv-export-patch.tar.gz
RUN chown kibana:kibana -R ./src
RUN rm -rf ./optimize/*

CMD /usr/share/kibana/bin/kibana

The docker-compose file is fairly simple like this.

$ sudo vi ./docker-compose.yml
version: '2.1'
    build: kibana_5.3
    container_name: kibana_5.3_export
     - 5605:5601
      - kibana_net
      - ./kibana_5.3/config/etc/:/etc/kibana/

Make the setting file separately and mount it at container startup. The logging setting is output to the same directory to make the mount directory one.

$ sudo vi ./kibana_5.3/config/etc/kibana.yml
server.port: 5601 "" "kibana.designet.local"
elasticsearch.url: ""
logging.dest: /etc/kibana/kibana.log

It takes some time to start up

At startup, it takes several minutes for optimize processing. In my environment Kibana came up in about 90 seconds as below. (State logged STDOUT)

$ sudo docker-compose up
Starting kibana_5.3_export ...
Starting kibana_5.3_export ... done
Attaching to kibana_5.3_export
kibana_5.3_export | {"type":"log","@timestamp":"2017-07-16T17:17:12Z","tags":["info","optimize"],"pid":1,"message":"Optimizing and caching bundles for kibana, timelion and status_page. This may take a few minutes"}
kibana_5.3_export | {"type":"log","@timestamp":"2017-07-16T17:18:43Z","tags":["info","optimize"],"pid":1,"message":"Optimization of bundles for kibana, timelion and status_page complete in 90.28 seconds"}
kibana_5.3_export | {"type":"log","@timestamp":"2017-07-16T17:18:43Z","tags":["status","plugin:kibana@5.3.0","info"],"pid":1,"state":"green","message":"Status changed from uninitialized to green - Ready","prevState":"uninitialized","prevMsg":"uninitialized"}

Outline of the export operation

With the patch-applied version, it is possible to export like this. You can also export by selecting column in the Discover tab, saving it and opening it . Otherwise only _ source will be displayed.


From here you can export on CSV as follows.

"July 17th 2017, 00:40:00.000",Built,outside,management,tcp,outbound,""," - ",443," - ","",,"53,574"
"July 17th 2017, 00:40:00.000",Built,management,outside,tcp," - ",""," - ","53,574",dynamic,"",,"53,574"
"July 17th 2017, 00:40:00.000",Built,management,outside,tcp," - ",""," - ","53,575",dynamic,"",,"53,575"

Summary - Patch Kibana 5 and export CSV from the Discover tab

Kibana 5 applied the patch and the search result can be exported as CSV from the Discover tab. Because I can add export function with simple operation, I evaluate it as a very useful patch.

This Blog is English Version of my JP's.

Sorry if my English sentences are incorrect.