Providing analytics with Kibana

Kibana is an open source web frontend for Elasticsearch that gives you visualizations for analytics and the ability to search for specific data. It's produced by the company behind Elasticsearch and is very widely used because it provides a user-friendly way to navigate huge quantities of data. You can explore the data interactively, and power users can build comprehensive dashboards to share with others.

The latest version of Kibana is a Node.js application, so like Elasticsearch and NATS, it's a cross-platform application. There's an official image on Docker Hub with Linux and variants, and I've packaged my own image based on Windows Server 2019. The Kibana image is built using the same convention-based approach that I've used in the message handlers: it expects to connect to a container called elasticsearch on the default API port 9200.

In the source code directory for this chapter, there is a second PowerShell script that deploys the containers for this feature. The fine named ch05-run-nerd-dinner_part-3.ps1 starts the additional Elasticsearch, Kibana, and index handler containers, and it assumes that the other components are already running from the part-1 and part-2 scripts:

 docker container run -d `
--name elasticsearch `
--env ES_JAVA_OPTS='-Xms512m -Xmx512m' `
sixeyed/elasticsearch:5.6.11-windowsservercore-ltsc2019;

docker container run -d `
--name kibana `
-l "traefik.frontend.rule=Host:kibana.nerddinner.local" `
sixeyed
/kibana:5.6.11-windowsservercore-ltsc2019;

docker container run -d `
--name nerd-dinner-index-handler `
dockeronwindows/ch05-nerd-dinner-index-handler:2e;
The Kibana container is labelled with Traefik's frontend rules. By default, Kibana listens on port 5601, but in my setup, I'll be able to reach it on port 80 using the kibana.nerddinner.local domain, which I've added to my hosts file, and Traefik will proxy the UI.

The full stack is running now. When I add a new dinner, I will see the logs from the message handler containers showing that the data is now being saved to Elasticsearch, as well as to the SQL Server:

> docker container logs nerd-dinner-save-handler
Connecting to message queue url: nats://message-queue:4222
Listening on subject: events.dinner.created, queue: save-dinner-handler
Received message, subject: events.dinner.created
Saving new dinner, created at: 2/11/2019 10:18:32 PM; event ID: 9919cd1e-2b0b-41c7-8019-b2243e81a412
Dinner saved. Dinner ID: 2; event ID: 9919cd1e-2b0b-41c7-8019-b2243e81a412

> docker container logs nerd-dinner-index-handler
Connecting to message queue url: nats://message-queue:4222
Listening on subject: events.dinner.created, queue: index-dinner-handler
Received message, subject: events.dinner.created
Indexing new dinner, created at: 2/11/2019 10:18:32 PM; event ID: 9919cd1e-2b0b-41c7-8019-b2243e81a412

Kibana is being proxied by Traefik, so I just need to browse to kibana.nerddinner.local. The only configuration the launch-screen needs is the name of the document collection, which Elasticsearch calls an index. In this case, the index is called dinners. I've already added a document with the message handler so that Kibana can access the Elasticsearch metadata to determine the fields in the documents:

Every dinner created will now be saved in the original transactional database SQL Server, and also in the new reporting database, Elasticsearch. Users can create visualizations over aggregated data, looking for patterns in popular times or locations, and they can search for particular dinner details and retrieve specific documents:

Elasticsearch and Kibana are hugely capable software systems. Docker has made them accessible to a whole new set of users. I won't cover them in any further detail in this book, but they are popular components with a lot of online resources, that you can search for, if you want to learn more.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.204.5