Kibana Guide: Upload a File and Create a Data View

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

Checked on 2026-11-11 against Kibana 9.5.x.

What you build

You do three things that every later guide relies on. You upload the small CSV file of the lab into a new index, to see what the file upload does and where it can trip you up. You create the data view Bookshelf logs (guides) on the log data stream of the Bookshelf service, which the Discover, Lens and rule guides use. And you add two things to that data view without changing a single stored document: a runtime field status_class that turns the HTTP status into 2xx, 4xx or 5xx, and a URL formatter for the field attributes.uri.

Result: the data view Bookshelf logs (guides) in Kibana 9.5 with the index pattern logs-generic.otel-default, the runtime field status_class in the fields table and the format Url on attributes.uri

Before you start

  • Start the Kibana profile of the hands-on lab and wait about a minute:

    cd lab
    docker compose --profile kibana up -d
  • Open http://localhost:5601 and sign in as elastic with the password lab-elastic-password. When Kibana opens its full-screen welcome page, click Explore on my own.

  • Do the previous guide, First steps in Kibana, to know the menu and the time picker. It also installs the sample data sets, but this guide does not need them.

  • The load generator must have been running for a minute or two, so that the data stream logs-generic.otel-default exists. It does after the lab start in its default mode, and curl localhost:8090/ prints the mode.

  • The file to upload is kibana/bookshelf-books.csv of the lab folder: a header line title,author,genre,pages,published_year and 30 books. Copy its path from your lab folder, you choose it in a file dialog.

  • The lab runs with a trial licence, and this guide needs only the basic licence and the privileges of the elastic user.

  • The figures are drawings of the Kibana 9.5 user interface, not screenshots, so small details can differ from your screen. A highlighted box with a number marks the control of the step with the same number. Where a screen is drawn without a label (the buttons that confirm the override and start the import), the text of the step names the button by its role.

Steps

Two screens are used. The first part works on the Add data page, which has a tab for files. The other parts work in Stack Management, in the Data Views section. There is no map to learn: the figures show each screen at the step that uses it.

Upload the books file

  1. On Home, in the row Get started by adding integrations, click Upload a file. The page Add data opens on its tab Upload file.

  2. Under Select index creation method, check that New index is selected. (Existing index adds the rows to an index that exists already.)

  3. In Index name, type guide-books. Kibana accepts lowercase names with hyphens and numbers.

  4. Click the drop zone Select or drag and drop files and choose bookshelf-books.csv in the file dialog, or drag the file onto the zone. Kibana accepts PDF, TXT, CSV, log files and NDJSON.

    Add data page of Kibana 9.5 on the tab Upload file: New index is selected (callout 2), the Index name field holds guide-books (callout 3) and the drop zone Select or drag and drop files accepts CSV (callout 4)
  5. Kibana analyses the file and shows what it found: a delimited file with the delimiter comma and the quote character. For this file it does not recognise the header line, so it names the columns column1 to column5 and treats the line title,author,genre,pages,published_year as the first book. Click Override settings.

    Analysis of bookshelf-books.csv in Kibana 9.5: the first row title, author, genre, pages, published_year is read as data under the column names column1 to column5; the button Override settings is marked by callout 5
  6. In the window of the override settings, tick Has header row.

  7. Confirm the window with its primary button, the one that applies the settings.

    Override settings window of the file analysis with the checkbox Has header row ticked and marked by callout 6 and the primary button that confirms the window marked by callout 7
  8. Check the preview. The columns are now named title, author, genre, pages and published_year, and the first row is Dune. Kibana types title, author and genre as keywords and pages and published_year as numbers.

  9. Click the primary button that starts the import.

    Analysis of bookshelf-books.csv after the override: the columns are title, author, genre, pages and published_year, marked by callout 8; the primary button that starts the import is marked by callout 9
  10. Wait until Kibana reports that the import is complete. The import may offer to create a data view for the new index; the guides of this series do not use one for guide-books, so either choice is fine.

Create the data view for the Bookshelf logs

  1. Click the menu button, Toggle primary navigation, at the left of the second bar.

  2. Scroll the navigation to the section Management and click Stack Management.

    Kibana 9.5 with the primary navigation open and scrolled to the Management section: callout 11 marks the menu button of the second bar and callout 12 marks Stack Management
  3. In the menu at the left, under Kibana, click Data Views.

    Stack Management of Kibana 9.5 with its left menu groups Ingest, Data, Alerts and Insights and Kibana; Data Views under Kibana is marked by callout 13
  4. Click Create data view. The page lists the data views of Kibana: the managed ones (APM, Case Analytics) and, if you installed them in the previous guide, the sample ones. The first sample set you installed carries the badge Default.

    Data Views page of Kibana 9.5 listing the sample data views Kibana Sample Data eCommerce, Kibana Sample Data Logs, APM and Case Analytics; the primary button Create data view is marked by callout 14
  5. In the flyout, type Bookshelf logs (guides) in Name.

  6. Type logs-generic.otel-default in Index pattern. The right side of the flyout lists the data stream that matches.

  7. Leave Timestamp field on @timestamp, or choose it if the list shows another field.

  8. Click Save data view to Kibana.

    Create data view flyout of Kibana 9.5 with the Name Bookshelf logs (guides) (callout 15), the Index pattern logs-generic.otel-default (callout 16), the Timestamp field @timestamp (callout 17) and the primary button Save data view to Kibana (callout 18)
  9. Kibana opens the page of the new data view with a table of its fields. The fields of the Bookshelf logs are @timestamp, body.text, severity_text, attributes.uri, attributes.status (a number) and trace_id, among about a hundred more that come from the OpenTelemetry mapping.

Add a runtime field

  1. On the data view page, click Add field.

    Page of the data view Bookshelf logs (guides) in Kibana 9.5 with its fields table, including attributes.status and attributes.uri; the button Add field is marked by callout 20
  2. In the field editor that opens at the right, type status_class in Name.

  3. Set the type to Keyword.

  4. Type the script that sets the value of the field. It reads the number attributes.status and emits one of three texts. A document without a status emits nothing:

    if (doc['attributes.status'].size() == 0) { return; }
    long s = doc['attributes.status'].value;
    if (s >= 500) { emit("5xx"); }
    else if (s >= 400) { emit("4xx"); }
    else { emit("2xx"); }
    Flyout for a new runtime field with the Name status_class (callout 21), the Type Keyword (callout 22) and the script that emits 5xx, 4xx or 2xx from attributes.status (callout 23)
  5. Look at the preview of the editor. It runs the script on sample documents of the index and shows the value of status_class for each, mostly 2xx while the load generator runs in its default mode. An error in the script is shown there instead of values.

  6. Click Save.

    Flyout of the runtime field status_class with the Preview pane listing the values 2xx, 4xx and 5xx of sample documents, marked by callout 24, and the primary button Save marked by callout 25

Format a field

  1. Back on the fields table, type attributes.uri in the search box above the table. The table narrows to that field.

  2. Click the edit button at the right of the row attributes.uri.

    Data view page with the search box holding attributes.uri (callout 26) and the fields table narrowed to the row attributes.uri, whose edit button is marked by callout 27
  3. In the field editor, turn on Set format and choose the format Url.

  4. Enter the template http://localhost:8080{{rawValue}} in Url template. The text {{rawValue}} is replaced by the stored value, so /api/search becomes a link to http://localhost:8080/api/search on the Bookshelf service.

  5. Click Save.

    Field editor of attributes.uri with Set format turned on, the format Url (callout 28), the Url template http://localhost:8080 followed by the raw value placeholder (callout 29) and the primary button Save (callout 30)
  6. The fields table now shows Url in the format column of attributes.uri and lists status_class with the type string. The editor of a field has a preview of its own, which shows a sample value as it will look.

Check the result

Check the three things in turn.

  • The upload: the index guide-books holds the 30 books.

    curl -s -u elastic:lab-elastic-password "localhost:9200/guide-books/_count"

    The answer contains "count":30.

  • The data view: open Stack Management → Data Views. The list holds Bookshelf logs (guides), and its page lists status_class and the format of attributes.uri.

  • The runtime field: it is computed when a query reads it, so nothing is reindexed. To see it with values, open Discover from the menu, choose the data view Bookshelf logs (guides) in the data view picker and find status_class in the field list. The next guide does this in full.

To see the value 5xx appear, force errors for a minute and then restore normal traffic:

curl -X POST localhost:8090/mode/failing
curl -X POST localhost:8090/mode/normal

Variations

  • To format a number of bytes, edit a numeric field of a data view that has one, for example bytes of Kibana Sample Data Logs, and choose the format Bytes; its numbers are then shown with a unit such as KB or MB. The Bookshelf logs have no such field.

  • To format a duration, edit a numeric field that holds a time, such as attributes.transaction.duration.us of the trace data, choose the format Duration and set the input unit of the field (microseconds there). The Bookshelf logs carry no duration either, and the lab was not used to exercise this format.

  • Use Existing index in the upload to add the rows of another file to guide-books, for example after you fix a file.

What can go wrong

Symptom Cause Fix

The columns are named column1 to column5 and the first book is title

The header line was not detected.

Click Override settings and tick Has header row, as in the steps.

The upload is refused for a file name or a size

The file is not one of the accepted formats, or it is larger than the upload limit of the file importer.

Use a CSV, TXT, log or NDJSON file. The lab file has 31 lines and is far below the limit.

Index name is rejected

Index names must be lowercase and contain only hyphens and numbers besides the letters.

Use guide-books or another lowercase name.

The index pattern says that it matches no sources

The data stream does not exist yet, because the load generator was just started, or the pattern has a typo.

Check the mode with curl localhost:8090/, wait a minute, and retype logs-generic.otel-default.

The preview of the runtime field shows no values or an error

The script has a typo, or the type is not Keyword while the script emits text.

Retype the script exactly as shown and set the type to Keyword.

Url template is not shown

The format is not Url.

Choose Url in the format list.

Clean up

Keep the data view Bookshelf logs (guides), its runtime field and its format: the following guides use them. The upload is only an exercise, so you can delete its index:

curl -s -u elastic:lab-elastic-password -X DELETE "localhost:9200/guide-books"

If the import created a data view for it, delete that one under Stack Management → Data Views. To remove everything the lab stores, stop the profile with docker compose --profile kibana down -v.

Where to go next