Today, I’m going to walk you through setting up a local instance of Kibana to connect to a remote Elasticsearch cluster. ObjectRocket for Elasticsearch instances include a free, hosted Kibana install, but there are some cases where running Kibana on your local machine provides additional flexibility. Also, if you happen to be running in an environment or on a service that does not provide hosted Kibana, this walkthrough will help you easily run Kibana local to your machine.
Why run a local instance of Kibana?
Have you ever wanted to create a custom set of visualizations that are not shared with other Kibana users? Or try out a new Kibana plugin without having to install it on a shared instance of Kibana? Running Kibana locally can do all of these things and more.
Kibana doesn’t store anything locally and, by default, uses the same index to store its configuration in the Elasticsearch cluster. That means you can run as many instances of Kibana as you want or only run Kibana when you’re using it. Due to the shared state/configuration, you can create and modify visualizations on one instance, and the new content will be seen on any Kibana instance connecting to the cluster. This has the advantage of allowing good collaboration but also the downside that a mistake by one user can delete or modify visualizations for all users.
If you have a number of users using your Kibana instance, you may want to run your own with a different index, so you can have custom visualizations without the risk of another user trampling on them. Or, you may want to try out visualizations or plugins on your own Kibana install without providing access to everyone else until they’re ready.
The flexibility can come in handy, so let’s jump to setup.
Setting up Kibana
Kibana just connects to Elasticsearch like any other Elasticsearch client, so if you can connect your local system to Elasticsearch, then you can run Kibana locally. We recommend a Dockerized version of Kibana to minimize the number of components to install locally and to keep things well contained, so you will at least need Docker and Docker Compose installed on your local system.
Once you’ve got Docker setup, clone our local-kibana GitHub repo to a directory on your system.
Next, you’ll want to configure the inlcuded kibana.yml file to your needs. Below is a copy of the version included in the repo:
---
## Default Kibana configuration from kibana-docker.
## from https://github.com/elastic/kibana-docker/blob/master/build/kibana/config/kibana.yml
#
# Kibana server name and host. You shouldn't need to change these
server.name: kibana
server.host: "0"
# These are the settings you must set to your target Elasticsearch cluster and user.
elasticsearch.url: "https://your-host.es.objectrocket.com:yourport"
elasticsearch.username: "youruser"
elasticsearch.password: "yourpassword"
# The index Kibana should use. By default, Kibana will use an index named ".kibana".
# If you want to isolate your visualizations/dashboards/index patterns from others, change This
#kibana.index: ".kibana"
In the config file, there are two sections to focus on: the elasticsearch.* settings and the kibana.index setting.
The elasticsearch.* settings determine which target Elasticsearch cluster to connect to. If you’re on the ObjectRocket service, you can find everything you need to fill this out in the “Connect” section of the UI. Otherwise, set these to an Elasticsearch host and the username and password you use to connect to Elasticsearch. Note that Kibana does not accept multiple Elasticsearch hostnames, so if you have multiple hosts, you’ll need to pick just one for this Kibana instance to connect to.
The second section to focus on is the kibana.index setting. If you want to work with the same visualizations and dashboards as everyone else, just leave this as is. If you want to work on your own custom settings, uncomment it and change to something else so you and others can identify it as your Kibana settings.
Running Kibana
Now you’re ready to fire Kibana up. If you’re on a service with network security/ACLs, first make sure you’re able to connect to Elasticsearch from your local machine.
From the local-kibana directory, run:
$ docker-compose build --no-cache
$ docker-compose up
Kibana will take a few minutes to start up and configure itself, but eventually you should see the Kibana state updated to ‘green’ in your terminal. Now, you’re ready to connect.
Connecting
Now that your Kibana container is up and running, you can navigate to localhost:5601 in a browser. Kibana will ask for your username and password (this is the same user/password you put in the config file above) one more time, then everything will load up. If you changed the Kibana index from the default, you will also need to set up your index patterns and default index pattern the first time you log in.
Wrapping Up
That’s all you need to quickly and easily launch a local Kibana instance. You can also find more detailed instructions in our docs.