Quick start using ElasticSearch, Kibana with ASP.Net Core 2.0
ElasticSearch and Kibana are two great products to use in your solution. They provide various values to a solution. If you don’t know ElasticSearch and Kibana then I recommend you read more about these technologies or follow me to get more insight on them.
Create new project folder
Open a command prompt and run the following commands:
Create new ASP.Net Core project
In the command line create a new ASP.Net Core web application.
dotnet new mvc
The following additional packages are needed to log information to ElasticSearch using Serilog.
dotnet add package Serilog -v 2.5.0
dotnet add package Serilog.Extensions.Logging -v 2.0.2
dotnet add package Serilog.Sinks.ElasticSearch -v 5.4.0
Update Startup.cs file to enable logging to ElasticSearch
By enabling the logging from your web application to ElasticSearch you need to make the following changes in the Startup.cs file.
Use Docker to startup and use ElasticSearch and Kibana
In the command line run the following Docker commands to download an ElasticSearch with Kibana docker image.
docker pull nshou/elasticsearch-kibana
docker run -d -p 9200:9200 -p 5601:5601 nshou/elasticsearch-kibana
It can take a while to download the docker image from the docker registry. Once the download is finished, you can confirm if an instance is running of the image by executing the following command.
Run your ASP.Net Core project
Now you must run your ASP.Net Core web application for example from the command line.
Open the web application in your favorite browser: http://localhost:5000
Click around in the web application to generate web traffic. You have to generate first some web traffic before opening the Kibana web application.
Setup and use Kibana
Open in your favorite browser the following URL: http://localhost:5601
This will open the Kibana application. The first thing to do is to configure the index pattern before you can start using the goodies in the Kibana web application.
After the index pattern is configured then you can click on the Discover menu option to see each of the logging information generated by the web requests you have created.
Feel free now to explore and create vizualizations, dashboards and timelines in Kibana based on the logging information.
ElasticSearch and Kibana provides many benefits to you which you can utilize in your web application solution. ElasticSearch specifically is a great search engine that you can use as a view cache to search quickly through information. There is a lot more capabilities ElasticSearch and Kibana have for you to explore and use in your next great ASP.Net Core 2.0 solution.
With the help of containers you can get setup quickly and deploy your solution quickly to any environment. Let me know how you use ElasticSeach and Kibana in your solutions!