Export to Csv/excel From Kibana

Better Stack Team
Updated on October 26, 2024

Exporting data from Kibana to CSV or Excel can be done in a few different ways, depending on what data you want to export, such as raw search results, aggregation results, or table data. Below are the common methods to achieve this:

1. Exporting Data from Discover Tab to CSV

The Discover tab in Kibana is where you can search and filter your Elasticsearch documents. You can export the search results to a CSV file.

Steps:

  1. Navigate to Discover:
    • In Kibana, go to the Discover tab.
  2. Create a Search Query:
    • Apply filters or a search query to find the data you want to export.
    • Adjust the time range using the time picker at the top right.
  3. Select Columns:
    • On the left panel, under Available Fields, click on the fields you want to include in the export. These will appear as columns in the CSV file.
  4. Export to CSV:

    • Click on the Share button (usually in the top right corner).
    • Select CSV Reports.
    • Click Generate CSV.
    • The export process will start, and a notification will appear when it’s ready for download.

    You can then download the generated CSV file.

Note:

  • If you are using Kibana Basic or Free Tier, you may have to install a Reporting plugin to generate CSV exports.
  • You can configure maximum CSV export size in the kibana.yml configuration file, which is especially useful when working with large datasets:

     
    xpack.reporting.csv.maxSizeBytes: 104857600  # For 100 MB CSV export limit
    

2. Exporting Data from Visualizations to CSV

You can also export data that is displayed in a Kibana Visualization, such as a Data Table or other charts, to CSV.

Steps:

  1. Navigate to Visualize:
    • Go to the Visualize tab in Kibana and open the visualization that contains the data you want to export (for example, a Data Table).
  2. Inspect the Visualization:
    • Click the Inspect button (usually available under the ... menu in the top right of the visualization).
    • In the Inspect panel, switch to the Data tab to see the underlying data that was used to create the visualization.
  3. Download as CSV:
    • Once in the Data tab, click on the Download CSV button to export the displayed data to a CSV file.

Note:

  • This method works best for table-based visualizations (like Data Table) where rows and columns are already structured. Other types of visualizations (like charts) may not export in a straightforward format, and only the underlying raw data is exported.

3. Exporting Data via Saved Searches

If you've created a Saved Search in the Discover tab, you can use this saved search in a Dashboard or Visualization and export the data.

Steps:

  1. Create and Save a Search:
    • In the Discover tab, build a search query.
    • Select the fields you want to export.
    • Click on Save to save the search.
  2. Export the Saved Search:
    • Follow the same steps as described under Exporting Data from Discover Tab to CSV.

4. Automating CSV Export Using Watcher (Advanced)

If you need to regularly export data, you can use Elasticsearch Watcher to automate the export and send the results via email or HTTP.

Steps:

  1. Create a Watch:
    • Define a Watch that triggers on a schedule and includes a search query to retrieve the required data.
  2. Attach a Reporting Action:
    • Use the Reporting action in the Watch to generate a CSV file.
  3. Send CSV via Email or Store in a Directory:
    • Configure the Watch to send the CSV via email or to a specified directory.

Example Watch Action:

 
"actions": {
  "email_admin": {
    "email": {
      "to": "admin@example.com",
      "subject": "Daily CSV Report",
      "attachments": {
        "report.csv": {
          "reporting": {
            "csv": {
              "index": "your_index",
              "query": {
                "match_all": {}
              }
            }
          }
        }
      }
    }
  }
}

5. Using Dev Tools (Advanced Elasticsearch Query)

If you prefer querying Elasticsearch directly and exporting the results:

Steps:

  1. Navigate to Dev Tools:
    • Go to the Dev Tools tab in Kibana.
  2. Run a Query:

    • Write an Elasticsearch query to retrieve the data.

    Example:

     
    GET /your_index/_search
    {
      "query": {
        "match_all": {}
      }
    }
    
  3. Copy Data:

    • Once the query is executed, copy the results and format them as needed for CSV or Excel. This method usually requires some manual work (e.g., using a script to convert JSON to CSV).

Conclusion:

  • CSV Export via Discover and Visualizations are the most common and user-friendly methods for exporting data from Kibana.
  • Dev Tools and Watcher provide more advanced, customizable methods to export or automate exports.
  • For Excel, you can convert the CSV file (generated using the above methods) to Excel format easily using tools like Excel or any spreadsheet software.
Got an article suggestion? Let us know
Explore more
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

community@betterstack.com

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github