Export Elasticsearch data to CSV with Kibana
How exporting Elasticsearch data to CSV through Kibana works, what the conversion changes, where it loses information, and when another format or method fits better.
Exporting Elasticsearch data to CSV turns JSON documents into a flat, delimited table that spreadsheets and many other tools can open. Kibana is the most common way to do this without writing code. This review explains what the conversion actually changes, how usable the result is once it leaves Kibana, and when a different route or format is the better choice.
A note on evidence: no confirmed specifications, size limits, version details or test results were supplied for this article. The descriptions below follow the general documented behavior of Kibana and Elasticsearch. Option names, menus, defaults and licensing differ between versions and deployments, so check the documentation for your release before relying on any specific detail.
Short verdict: is a Kibana CSV export suitable?
For tabular, mostly flat data that someone needs to read, filter or share in a spreadsheet, a Kibana CSV export is a reasonable choice. Its main benefit is convenience: you build the view in Discover with the time range, query, filters and columns you want, then generate a report from that same view, with no scripting.
The key tradeoff is structure. CSV has rows, columns and text, and nothing else. Nested objects, arrays, data types and relationships between fields do not carry over cleanly. If the data has to go back into Elasticsearch, into another system that expects typed or nested records, or into an audit trail where exact values matter, a JSON-based export (such as newline-delimited JSON) is usually the better fit.
Large exports are another constraint. Kibana's CSV reporting is subject to size and time limits that administrators can configure, so a very large export may be truncated or fail. For bulk extraction, scripted or pipeline-based methods are often more dependable.
How the export works in Kibana
In Kibana, a CSV export usually starts from a Discover session. The general workflow:
- Open Discover and select the data view that covers the indices you need.
- Set the time range and enter your query and filters.
- Add the fields you want as columns. If you select no columns, the export may include whole documents, which is rarely what you want in a spreadsheet.
- Save the session if your version requires a saved search before reporting.
- Use the share or export menu to generate a CSV report.
- Download the finished file from the notification or from the Reporting page in Stack Management.
Reporting runs in the background, so large exports may take some time. Whether reporting is available, and who can use it, depends on your license tier and on the roles and privileges in your deployment. If the export option is missing, ask an administrator about reporting privileges.
What the conversion actually changes
This is a change to the stored data, not to how it is displayed. Elasticsearch holds documents as JSON. The export writes a new text file in which each matching document becomes one row and each selected field becomes one column, separated by a delimiter (a comma by default). The original documents are not modified. The file is a separate, flattened copy.
Specifically, the conversion affects the following:
- Nested objects are flattened. A field inside an object appears as a column with a dotted name, such as host.name. The parent-child grouping is lost.
- Arrays and multi-value fields do not map to a single cell. They may be joined into one cell or represented in a way that varies by field type and version. Check how your version handles them before you parse the file automatically.
- Types become text. Numbers, booleans, dates and IP addresses are all written as characters. The spreadsheet or downstream tool then guesses types again, which can strip leading zeros, reformat long numeric IDs or reinterpret dates.
- Formatting may follow Kibana rather than the raw source. Values such as dates can appear in the format set by Kibana's field formatters or advanced settings, not exactly as stored in the source document.
- Only the selected columns are exported. Any field you did not add to the view is not in the file.
Kibana's advanced settings include options for the CSV separator and for whether values are quoted. Changing them affects every report generated afterward, so coordinate with whoever maintains the deployment.
Will the file stay readable and usable after it is shared?
CSV is plain text, so it travels well. It can be copied, emailed, versioned and opened by many tools. Most problems show up when the file is opened, not when it is moved.
Encoding and special characters
Exported text containing non-ASCII characters, such as accented names, non-Latin scripts or emoji, depends on the receiving program reading the file with the right encoding. Some spreadsheet applications decode a UTF-8 file incorrectly unless it starts with a byte order mark. Kibana's reporting configuration includes an option for this. If recipients see garbled characters, check that setting or import the file with the encoding specified explicitly, rather than opening it with a double-click.
Delimiters, quotes and line breaks inside values
Log messages and free-text fields often contain commas, quotation marks or line breaks. Correct CSV quoting handles these. Tools that split lines naively, such as simple scripts or some command-line utilities, can still break rows apart. If the file feeds a parser, use a real CSV library instead of splitting on commas.
Spreadsheet formula risk
A cell that begins with characters like an equals sign can be treated as a formula when the file is opened in a spreadsheet. With data from logs or user input, this is a known security concern. Kibana's reporting settings include an option to escape such values. Confirm that it is enabled in your deployment before you share exports widely, and keep in mind that escaping changes the literal text of the affected cells.
Accessibility and practical reading
In principle, a CSV opened in a spreadsheet works with screen readers and keyboard navigation as well as any other table does, because the content is ordinary text in ordinary cells. In practice, wide exports with dozens of dotted column names are hard for anyone to navigate, especially without visual scanning. No assistive-technology testing was available for this review. The practical advice is to limit the export to the columns that matter, give them clear names where your tooling allows, and include a short note on what each column means when you share the file.
Search and editing
Once exported, the data is a static snapshot. It does not update when the index changes. You can no longer query it with Elasticsearch's search features, and edits to the file have no effect on the source. Record the time range and query used for the export so readers know what the snapshot covers.
Alternatives when Kibana's export is not the right fit
If the export is too large, needs to run on a schedule, or must be reproducible from code, consider one of these documented approaches:
- Elasticsearch SQL API with CSV output. A query sent to the SQL endpoint can return results directly as CSV, and a cursor lets you page through larger result sets.
- Logstash. An Elasticsearch input combined with a CSV output plugin can extract data in a repeatable pipeline.
- Custom scripts. A client library that pages through results (for example, with point-in-time and search-after) gives full control over flattening, arrays and encoding.
- JSON or newline-delimited JSON. When structure and types must be preserved, export JSON instead of CSV and convert later only if needed.
An illustrative SQL API request returning CSV is shown below. The index pattern and field names are placeholders. Check the syntax for your version, including how field names with dots or special characters must be quoted.
POST _sql?format=csv
{
"query": "SELECT \"@timestamp\", host.name, message FROM \"logs-*\" ORDER BY \"@timestamp\" DESC"
}
When to choose CSV and when to avoid it
- Choose a Kibana CSV export when the data is mostly flat, the audience will use a spreadsheet, and the volume is within your deployment's reporting limits.
- Use the SQL API, Logstash or a script when exports are large, recurring or need to be reproducible.
- Avoid CSV when nested structure, arrays or exact data types matter, or when the data will be reimported. Use JSON or NDJSON instead.
- Before sharing any CSV export, check the encoding, confirm that formula escaping is enabled, and remove columns the recipients do not need.
Open questions this review could not resolve
Without supplied evidence, this review cannot state the default export size or time limits, the exact license tiers that include CSV reporting, the precise handling of multi-value fields in each Kibana version, or how particular spreadsheet applications and screen readers behave with a given export. Verify these against your version's documentation, and test with a small sample from your own data, before you depend on the export for reporting or compliance.