Working with Kibana in Elasticsearch 5.x

0
2321
8 min read
Below given post is a book excerpt from Mastering Elasticsearch 5.x written by  Bharvi Dixit. This book introduces you to the new features of Elasticsearch 5.

The following article showcases Kibana, a tool belongs to the Elastic Stack, and used for visualization and exploration of data residing in Elasticsearch. One can install Kibana and start to explore Elasticsearch indices in minutes — no code, no additional infrastructure required. If you have been using an older version of Kibana, you will notice that it has transformed altogether in terms of functionality.

Note:

This URL has all the latest changes done in Kibana 5.0: https://www.elastic.co/guide/en/kibana/current/breaking-changes- 5.0.html.

Installing Kibana

Similar to other Elastic Stack tools, you can visit the following URL to download Kibana 5.0.0, as per your operating system distribution:

https://www.elastic.co/downloads/past-releases/kibana-5-0-0
An example of downloading and installing Kibana from the Debian package.

  • First of all, download the package:

https://artifacts.elastic.co/downloads/kibana/kibana-5.0.0-amd64.deb


  • Then install it using the following command:

sudo dpkg -i kibana-5.0.0-amd64.deb

Kibana configuration

Once installed, you can find the Kibana configuration file, kibana.yml, inside the/etc/kibana/ directory. All the settings related to Kibana are done only in this file. There is a big list of configuration options available inside the Kibana settings which you can learn about here:

https://www.elastic.co/guide/en/kibana/current/settings.html.

Starting Kibana

Kibana can be started using the following command and it will be started on port 5601 bounded on localhost by default:

sudo service kibana start

Exploring and visualizing data on Kibana

Now all the components of Elastic Stack are installed and configured, we can start exploring the awesomeness of Kibana visualizations.

Kibana 5.x is supported on almost all of the latest major web browsers, including Internet Explorer 11+.

To load Kibana, you just need to type localhost:5601 in your web browser. You will see different options available in the left panel of the screen, as shown in following figure:

Kibana

These different options are used for the following purposes:

Discover: Used for data exploration where you get the access of each field along with a default time.

Visualize: Used for creating visualizations of the data in your Elasticsearch indices. You can then build dashboards that display related visualizations.

Dashboard: Used to display a collection of saved visualizations.

Timelion: A time series data visualizer that enables you to combine totally independent data sources within a single visualization. It is based on simple expression  language.

Management: A place where you perform your runtime configuration of Kibana, including both the initial setup and ongoing configuration of index patterns, advanced settings that tweak the behaviors of Kibana itself and saved objects.

Dev Tools: Contains the console which is based on the Sense plugin and allows you to write Elasticsearch commands in one tab and see the responses of those commands in the other tab.

Understanding the Kibana Management screen

The Management screen has three tabs available:

Index Patterns: For selecting and configuring index names

Saved Objects: Where all of your saved visualizations, searches, and dashboards are located

Advanced Settings: Contains advanced settings of Kibana:

Configuring index pattern

As you can see on the management screen, the very first tab is for Index Patterns. Kibana is asking you to configure an index pattern so that it can load all the mappings and settings from the defined index. It defaults to logstash-*; you can add as many index patterns or absolute index names as you want and can select them while creating the visualization. Since we do have an index already available with the logstash-* pattern, when you click on the Time-field name drop-down list, you will find that it will show you two fields, @timestamp and received_at, which are of the date type, as shown in following screenshot:

Configuring index pattern

We will select the @timestamp field and hit the Create button. As soon as you do it, the following screen appears:

Kibana

In the above screenshot, you can see that Kibana has loaded all the mappings from our Logstash index. In addition, you can see three labels in blue (for marking this index as the default), yellow (for reloading the mappings; this is needed if you have updated the mapping after selecting the index pattern), and red (for deleting this index pattern altogether from Kibana).

The second tab on the management screen is about saved objects, which contain all of your saved visualizations, searches, and dashboards as you can see in the following screenshot. Please note that you can see the imported dashboards and visualizations from Metricbeat here, which we have done a while ago.

Edit saved objects


The third option is for Advanced Settings and you should not play with the settings shown on this page if you are not aware of the tweaking effects.

Discovering data on Kibana

When you move to the Discover page of Kibana, you will see a screen similar to the following:

Discovering data in Kibana

Setting the time range and auto-refresh interval

Please note that Kibana by default loads the data of the last 15 minutes, which you change by clicking on the clock sign which you can find in the top-right corner of the screen and selecting the desired time range. We have shown it in the following screenshot:

Kibana

One more thing to take look out for is that, after clicking on this clock sign, apart from time- based settings, you will see one more option in the top corner with the name Auto-refresh. This setting tells Kibana how often it needs to query Elasticsearch. When you click on this setting, you will get the option to choose either to completely turn off the auto-refresh or select the desired time interval.

Adding fields for exploration and using the search panel

As you can see in the following screenshot, you have all your fields available inside your index. On the Visualization screen, by default Kibana shows the timestamp and _source field but you can add your selected fields from the left panel by just moving the cursor on them and then clicking Add. Similarly, if you want to remove the field from the column, just move the cursor to the field’s name on the column heading and click on the cross icon.

In addition, Kibana also provides you with a search panel in which you can write queries. For example, in the following screenshot, I have searched for the logstash keyword inside the syslog_message field. When you hit the search button, the search text gets highlighted inside the rendered responses:

Kibana

Exploring more options on the Visualization page

On Kibana, you will see lots of small arrow signs to open or collapse the sections/settings. You will see one of these arrows in the following image, in the bottom-left corner (I have also added a custom text on the image just beside the arrow):

Kibana

When you click on this arrow, the time series histogram gets hidden and you get to see the following screen, which contains multiple properties such as Table, which contains the histogram data in tabular format; Request, which contains the actual JSON query sent to Elasticsearch; Response, which contains the JSON response returned from Elasticsearch; and Statistics, which shows the query execution time and number of hits matching the query:

Kibana

Using the Dashboard screen to create/load dashboards

When you click on the Dashboard panel, you first get a blank screen with some options, such as New for creating a dashboard and Open to open an existing dashboard, along with some more options. If you are creating a dashboard from scratch, you will have to add the built visualizations onto it and then save it using some name. But since we already have a dashboard available which we imported using Metricbeat, we will click Open and you will see something similar to the following screenshot on your Kibana page:

Kibana

Please note that if you do not have Apache installed on your system, selecting the first option, Metricbeat – Apache HTTPD server status, will load a blank dashboard. You can select any other title; for example, if you select the second option, you will see a dashboard similar to the following:

Kibana

Editing an existing visualization

When you move the cursor on the visualizations presented on the dashboard, you will notice that a pencil sign appears, as shown in the following screenshot:

Kibana

When you click on that pencil sign, it will open that particular visualization inside the visualization editor panel, as shown in the following screenshot. Here you can edit the properties and either override the same visualization or save it using some other name:

Kibana

Please note that if you want to create a visualization from scratch, just click on the Visualize option on the left-hand side and it will guide you through the steps of creating the visualization. Kibana provides almost 10 types of visualizations. To get the details about working with each type of visualization, please follow the official documentation of Kibana on this link: https://www.elastic.co/guide/en/kibana/master/createvis.html.

Using Sense

Inside the Dev-Tools option, you can find the console for Kibana, which was previously known as Sense Editor. This is one of the most wonderful tools to help you speed up the learning curve of Elasticsearch since it provides auto-suggestions for all the endpoints and queries, as shown in the following screenshot:

Kibana

You will see that the Kibana Console is divided into two parts; the left part is where you write your queries/requests, and after clicking the green arrow, the response from Elasticsearch is rendered inside the right-hand panel:

Kibana

 

To summarize we explained how to work with the Kibana tool in Elasticsearch 5.x. We explored installation of  Kibana, Kibana configuration, and moving ahead with exploring and visualizing data using Kibana.

If you enjoyed this excerpt, and want to get an understanding of how you can scale your ElasticSearch cluster to contextualize it and improve its performance, check out the book Mastering Elasticsearch 5.x.

Mastering Elasticsearch 5.x

 

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here