Would you like to learn how to import a CSV file to ElasticSearch? In this tutorial, we are going to show you how to import a CSV file to an ElasticSearch server using Logstash or Kibana.
• Ubuntu 20
• Ubuntu 19
• Ubuntu 18
• ElasticSearch 7.6.2
• Logstash 7.6.2
In our example, The ElastiSearch server IP address is 192.168.100.9.
In our example, we are going to install Logstash and import a CSV file.
ElasticSearch Related Tutorial:
On this page, we offer quick access to a list of tutorials related to ElasticSearch installation.
Tutorial Logstash – Installation
Use apt-get to install the required packages.
Find the Java installation directory.
In our example, Java is installed on the following directory: /usr/lib/jvm/java-11-openjdk-amd64
Create a file to configure the required Java variables.
Here is the file content.
Reboot the computer.
Verify if the system created automatically the environment variable named: JAVA_HOME.
Here is the command output.
Download and install the ElasticSearch repository key.
Add the official ElasticSearch repository to your APT database
Update the APT-GET database and install the Logstash package.
Configure the Logstash service to start automatically.
Congratulations! You have finished the Logstash installation on Ubuntu Linux.
Tutorial ElasticSearch – Importing a CSV file
Create a CSV file.
Here is our file content.
In our example, we have a CSV file showing the Bitcoin daily price.
Create a Logstash configuration file.
Here is our file content.
Stop the Logstash service.
Star the Logstash service using the new configuration file.
Here is the command output.
In our example, we imported a CSV file containing 2 fields to ElasticSearch using Logstash.
In our example, we converted the field containing the Bitcoin price to the type numeric float.
In our example, we set the field named DATETIME as the default timestamp.
Verify if the Index was created on the ElasticSearch server.
Here is the command output.
Verify if the Bitcoin price was mapped as a numeric value.
Here is the command output.
In our example, the field named MARKET-PRICE was set as a float number.
List the content of the index named Bitcoin.
Here is the command output.
Congratulations! You imported a CSV file to ElasticSearch.