Dec 14th, 2018: [EN][Kibana] Canvas: From 0 to dashboard before the morning is out


(Aaron Aldrich) #1

Canvas is probably my favorite new feature of Kibana. Since its first technology previews I was thrilled with the idea of live-data backed slide decks built inside of Kibana and beautiful free-form dashboards. It's only recently, though, that I had the time and inspiration to dig in myself. The Central Pennsylvania Open Source Conference gave me just the excuse (and dataset) I needed to get started. It's a bit sparse and simple but here we are, My First Canvas:

It's not the prettiest thing worthy of marketing emails, but it's my thing that I made in a couple of hours with real data instead of sample sets and random numbers, and that means something.

From that, I have some takeaways that might help you get started faster.

1. Messy data

The data that I have for this is a bit muddled. The "quiz results" and "raffle entries" are mixed in a single index that matches filbeat-*. This meant I couldn't just count documents, everything had to be filtered. I encourage better separation of data that you don't plan to query together for individual elements.

The workaround here, using the Elasticsearch Raw Docs (esdocs) data source, I could specify the queries I needed. This was especially true of the Leaderboard and "Entries/Responses" sections that had to separate from each other.

2. ESSQL and WHERE clauses

Tied to the above problem, I wanted to pull out data using Elasticsearch SQL (essql) where I knew I could do SELECT * AS... type statements to rename fields on the fly, but filtering became an issue. As soon as I added a WHERE clause, I got errors. This might be a failing in my understanding, but the statements worked fine as a regular SQL query in Kibana's Discover page, so I'll assume this is a limitation of Canvas's essql at the moment.

The workaround here: I used esdocs which lets me specify the index, fields I want to pull data out of, a query to filter that data down, and a sorting statement. This helped especially for the data table "leaderboard" present in my example.

3. Canvas expressions

Canvas's great power and excitement comes from how flexible it is. It's difficult to expose all of that flexibility in the standard GUI elements for everything on Canvas. If you want some custom functionality, you're going to be dealing with the expression editor. This isn't a bad thing.

Actually, it's this access (easily gained through a button click on your workpad) that allowed me to fix my problems of using esdocs instead of essql above. For instance, when I wanted to rename some columns in my leaderboard, I could still do it, even though I didn't have the SELECT * AS functionality! By piping my query into a couple of new alterColumn statements, I was able to get the results I wanted:

| esdocs index="filebeat-6.5.2-2018.12.01" fields="display_name, score" query="message: \"Leaderboard Submission\"" sort="score, DESC"
| alterColumn "display_name" name="Name" 
| alterColumn "score" name="Score"

It'd have been more satisfying to get it all as part of a single-line query, but this worked and got me what I needed.

4. CSS exposure

Depending on past experiences, you probably have some reaction to being told you might have to write some CSS for design. While not a major pain for me, it still meant I had to dust off some old knowledge (and if I'm completely honest: google a bit).

Using the "Markdown" element, you can put any text on your Canvas pad that you want, but oddly enough, this doesn't have some of the useful text editing buttons from other elements like the counters.

When I wanted to, say, make my "Elastic Quiz Leaderboard" text yellow, I had to do so by hand:

But don't fret! You don't have to remember all the hex codes for your favorite compatible color scheme! You can leverage the color picker from some other elements to get the proper hex for the color you want:


4.5. Some CSS just doesn't actually do anything

As a note, adding font-weight and font-size arguments to my markdown element didn't appear to actually do anything. You can still adjust your font style with markdown as you would normally, but I was a bit surprised by a perceived limitation.

5. Everything is surprisingly easy

This was perhaps the most impressive part of it. Most elements I could add through a clickable interface. With a few clicks you can change colors, display and font sizes. You can easily copy elements you like and alter the query for different data (which is how the "Quiz Responses" and "Raffle Entries" were created in about 2 minutes). My favorite surprise was adding a hyper-link in the markdown element. I don't know why I didn't expect it to work, but it did!

All in all, it isn't the prettiest dashboard anyone's ever created, but I made this thing in a couple of hours during the opening talks at a conference while sitting at the Elastic booth. Then I refreshed our demo on a Raspberry Pi and it was there! Using live data! So if you've seen some of the cool Canvas things and think, "I wish I could do that," you totally can! And if you're like me, after a couple of hours you'll be hooked and digging into all the documentation to find out what else you can do.

(P.S. Canvas is a regular part of Kibana now since 6.5, so you can check it as part of Elastic Cloud or on your own without any complicated plugin installs, so even getting started is easy!)