I’ve recently had the pleasure (and pain) of installing and configuring Elasticsearch + Kibana on Windows Server, so I thought about documenting my steps in an extremely straightforward way in case it helps someone else.
If you are not familiar with Elasticsearch, it is an extremely powerful open-source search tool. You can use it to add a Google-like search to your project. The whole ELK stack is very interesting and I recommend checking it out.
We start with Elasticsearch itself.
The MSI release is an easy way to install it on Windows. In case of doubt during the installation, I recommend just leaving the defaults. Take note of the node name, as it may be useful later on.
In order to set up your passwords, in your installation folder run:
Follow the prompts, setting a password for each account.
Open <elasticsearch folder>\config\elasticsearch.yml and add the following lines:
Try to open http://localhost:9200 — It should prompt you for basic authentication. Use your elastic credentials set in the previous step. If it returns a JSON with some information, you’re done!
You can think of Kibana as a UI for Elasticsearch.
Unlike Elasticsearch, Kibana does not have an MSI file, you will need to extract this zip file to a permanent folder, e.g. next to Elasticsearch.
Open <kibana folder>\config\kibana.yml and add the following lines:
- Uncomment the server.port property;
- Uncomment and set the server.host property with “0.0.0.0” to listen on all addresses;
- Uncomment the elasticsearch.hosts property;
- Uncomment the elasticsearch.username property;
- Uncomment and set the elasticsearch.password property with the password set on the Setup Passwords step;
NSSM will help us create a service based on Kibana’s .bat file.
Extract this zip file and run:
start-process ".\nssm.exe" "install Kibana"
On the Application tab:
- Path: <kibana folder>\bin\Kibana.bat
- Startup Directory: <kibana folder>\bin
On the Dependencies tab enter Elasticsearch so that the service waits for Elasticsearch to start first.
Check services.msc to see whether the service has started correctly.
You can check if Kibana is installed correctly by accessing http://localhost:5601 on the server. Use the same credentials you’ve set before.
Remember to open the correspondent firewall ports if you wish to provide access from the internet:
netsh advfirewall firewall add rule name=Kibana-Inbound-5601 dir=in action=allow protocol=TCP localport=5601netsh advfirewall firewall add rule name=Elasticsearch-Inbound-9200 dir=in action=allow protocol=TCP localport=9200
Here is the relevant information:
Encrypting communications in Elasticsearch | Elasticsearch Reference [master] | Elastic
Elastic Stack security features enable you to encrypt traffic to, from, and within your Elasticsearch cluster…
Encrypt communications in Kibana | Kibana Guide [master] | Elastic
Secure Sockets Layer (SSL) and Transport Layer Security (TLS) provide encryption for data-in-transit. While these terms…
After following these steps, don’t forget to set https on the elasticsearch.hosts property on <kibana folder>\config\kibana.yml.
When using a self-signed certificate, remember to set elasticsearch.ssl.verificationMode on <kibana folder>\config\kibana.yml to either “certificate” or “none”.
In my case, I needed to specify the full path on the elasticsearch.ssl.certificateAuthorities property on <kibana folder>\config\kibama.yml.
Let’s say you wanted to create an API key that has access to indexes starting with myclient* (myclient-documents, myclient-attachments, etc). You can open your ElasticSearch dev console, e.g. http://my-elastic:5601/app/dev_tools#/console, and run something like this:
See more information here:
Create API key API | Elasticsearch Reference [7.10] | Elastic
The API keys are created by the Elasticsearch API key service, which is automatically enabled when you configure TLS on…
Consider the option of running the Docker image instead, if it meets your needs. In my case, it made more sense doing things this way.
You may need to restart the services in order to apply some of the configurations.
You can always run <kibana folder>\bin\Kibana.bat directly to get more information about the process and possible errors.
This article helped me a lot: https://robwillis.info/2019/05/installing-elk-7-elasticsearch-logstash-and-kibana-windows-server-2016/
Apparently, there has been a licensing change recently, starting with the next version: https://anonymoushash.vmbrasseur.com/2021/01/14/elasticsearch-and-kibana-are-now-business-risks — Please do your own research as this may be deal-breaking for some projects.
If you’d like to see some code examples of the integration and end-user searches on .NET let me know, I may consider it for a future article.