Elasticsearch + Kibana 7.10 Setup on Windows

Nuno Góis
4 min readJan 18, 2021

--

Elasticsearch

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.

Elasticsearch

We start with Elasticsearch itself.

https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.0.msi

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.

Passwords

In order to set up your passwords, in your installation folder run:

bin\elasticsearch-setup-passwords interactive

Follow the prompts, setting a password for each account.

Elasticsearch configuration

Open <elasticsearch folder>\config\elasticsearch.yml and add the following lines:

transport.host: localhost
network.host: 0.0.0.0

Elasticsearch done!

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!

Kibana

You can think of Kibana as a UI for Elasticsearch.

https://artifacts.elastic.co/downloads/kibana/kibana-7.10.0-windows-x86_64.zip

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.

Kibana configuration

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

NSSM will help us create a service based on Kibana’s .bat file.

https://nssm.cc/ci/nssm-2.24-101-g897c7ad.zip

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.

Kibana done!

You can check if Kibana is installed correctly by accessing http://localhost:5601 on the server. Use the same credentials you’ve set before.

Firewall Rules

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

SSL

Here is the relevant information:

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.

API Keys

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:

POST /_security/api_key
{
"name": "myclient",
"role_descriptors": {
"mynodename": {
"cluster": ["all"],
"index": [
{
"names": ["myclient*"],
"privileges": ["all"]
}
]
}
}
}

See more information here:

Final Thoughts

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.

--

--

Nuno Góis
Nuno Góis

Written by Nuno Góis

https://www.nunogois.com — Full-Stack Developer with too many hobbies - including video games, writing, reading, traveling, music, movies and series.