Surprising Use Cases for Log Visualization
Tags: logging, programming, software
Published: 2019-11-12 14:53:04

People commonly say that a picture is worth a thousand words.&nbsp; So I wonder if log visualization is worth a thousand log entries.&nbsp; The math equivalency might be a little hard to prove, but the idea is worth exploring.

You're recording all sorts of information in your log files, but are you&nbsp;<em>visualizing</em> that information?

Do you have dashboards and graphs that help you picture production behavior?&nbsp; Or does the information sit buried within digital mountains of arcane strings?&nbsp; The proverbial needle in the haystack?&nbsp; Does anyone who&nbsp;wants to use it need to <a href="https://www.scalyr.com/blog/log-file-too-big-what-should-i-do/">engage in laborious searches</a>?

If you're not visualizing your logs, you're missing out.&nbsp; But I don't necessarily want to make the case for visualization today.&nbsp; Instead, I'd like to offer some ideas for visualization that you perhaps hadn't considered.&nbsp; Let's take a look at some use cases for log visualization that you might not have considered.<img class=" wp-image-1360 aligncenter" src="https://library.scalyr.com/2018/07/19175256/Eye_for_Visualizing_Data-2.png" alt="" width="311" height="311">
<h3>Prerequisites for Log Visualization</h3>
First things first, though.&nbsp; Before I can take you through the use cases, you need to have a setup that&nbsp;<em>allows</em> log visualization.&nbsp; Specifically, you need <a href="https://www.scalyr.com/blog/log-management-what-is-it-and-why-you-need-it/">modern log file management,</a>&nbsp;which includes the following things that concern us:
<ul>
 	<li><a href="https://www.scalyr.com/product/log-aggregation">Log aggregation</a> (gathering and storing log files).</li>
 	<li>Meaningful parsing of the data contained in the log files.</li>
 	<li>Powerful search capabilities.</li>
 	<li>Log visualization tools.</li>
</ul>
Don't get me wrong.&nbsp; You&nbsp;<em>could</em> implement all of this stuff yourself.&nbsp; But then again, you&nbsp;<em>could&nbsp;</em>also implement your own source control and text editor.&nbsp; Just because you can doesn't mean you should.

If you want to get serious about visualizing log files without burning tons of time, you need tooling and infrastructure in place to help you.&nbsp; Once you have that, though, let's take a look at some of the things you might do.

<!--more-->
<h3>Chart a Breakdown of Your Log Messages by Tag</h3>
If you'll recall, I talked some time back about <a href="https://www.scalyr.com/blog/be-kind-to-your-log-file-and-those-reading-it/">good application logging practices</a>.&nbsp; This includes categorizing and tagging entries/events in your log files.&nbsp; In short, you want to make it easy to group similar messages for different kinds of audits.<img class=" wp-image-1356 alignright" src="https://library.scalyr.com/2018/07/19175256/Pull_quote-You_ll_be_able_to_tell_at_a_glance.png" alt="" width="280" height="233">

So let's assume you're doing that.&nbsp; One interesting way to visualize this breakdown would be to enlist the following tactics:
<ul>
 	<li>View mutually exclusive categories of messages in a pie chart.</li>
 	<li>View inclusive tags in a bar graph.</li>
</ul>
For both cases, you could pick an arbitrary length of time (or sample multiple) to gather.&nbsp; What you'll have then is a breakdown of what&nbsp;sorts of information you're recording in the log file.&nbsp; This gives you some meta-insight into your information gathering.

Are you focusing a little too much on a mostly pass-through service layer?&nbsp; Not paying enough attention to your underlying physical systems?

You'll be able to tell at a glance.
<h3>See a Similar Breakdown by Log Level</h3>
You also have the option to do a similar kind of meta-information gathering.&nbsp; In this case, you can check out how your application logging looks by <a href="https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels">log level</a>.

On the one hand, if you're seeing a lot of fatal and error messages, you probably want to do some investigation.&nbsp; But at the other end of the spectrum, do you have a lot more informational logging than you need?&nbsp; Do you have trace or debug logging unintentionally going in production?&nbsp; Or if you have it going intentionally, is it swamping your files?

Again, you can check out all of this at a glance with log visualization in a much more impactful way than just by, say, counting up messages over a period of time.
<h3>How Many Messages Are Structured?</h3>
So far, I've talked about visualization use cases that examine your application logging practices and settings.&nbsp; But what about the entries themselves?&nbsp; And what about log visualization that you monitor as a trend, hoping to improve?

Earlier, I talked about the importance of structuring your log messages using an approach like key-value pairing them.&nbsp; Well, that probably won't happen all at once, and it's harder to get them into that format when they come from third-party logs.

But at any given point, you could track how many of your events come in structured as key-value pairs and how many don't.&nbsp; Over the course of multiple releases, you can monitor your progress in formatting messages the way you want.
<h3>Check Out a Breakdown of Your Application Exceptions</h3>
If people working on your application code regularly run a profiler, they might have some insight about common exceptions their code may generate.&nbsp; Or they may have no idea.&nbsp; After all, they probably can't recreate production conditions very well in staging, let alone at their desks.

To give them an idea of the prevalence of certain types of exceptions, you can make use of log visualization.&nbsp; Create a breakdown of which types of application exceptions occur in production.&nbsp; You could structure this as a pie-chart-style breakdown or as a bar-graph-style breakdown of quantities.

In either case, it'll tell you a lot about the sorts of things that tend to go wrong in production.&nbsp; You can then use this information back on the development side to see if you can't eliminate sources of frictional operation.
<h3>See A Graph of Server Responses</h3>
Do you have a web server in production these days, serving either actual web pages or web service responses?&nbsp; Most operations do, in some capacity or another.&nbsp; This means that you're routinely sending back <a href="https://en.wikipedia.org/wiki/List_of_HTTP_status_codes">HTTP response codes</a> over the wire.

Wouldn't it be useful to see how these break down?&nbsp; Something like this?

<img class="size-full wp-image-665 aligncenter" src="https://library.scalyr.com/2018/07/19175257/Non200Responses.jpg" alt="" width="377" height="393">

A lot of folks might think to monitor the general case of server errors, but why not see everything that's happening?&nbsp; Of the errors that happen, are they mostly on the users or on your software?&nbsp; Are you seeing significant variance in the percentages?&nbsp; If so, wouldn't you want to look into why?
<h3>Keep an Eye on Log Event/File Volume</h3>
Here's a practical one for you: try monitoring the volume of the data going into your log aggregation service each day.

However you're doing this, there's a decent chance that it directly impacts your wallet.&nbsp; More money for more data processing or more money for more storage.&nbsp; Whatever the case may be, you probably have a sliding scale.

While this probably doesn't break the bank, keeping an eye on it would be nice.&nbsp; You could then see in real time whether you were approaching a certain threshold as well as predict your cost on an ongoing basis.&nbsp; Including this as part of a dashboard would let you keep immediate and extremely clear tabs on it.<img class="wp-image-1357 alignright" src="https://library.scalyr.com/2018/07/19175257/Pull_quote-Logs_can_be_so_much_more_powerful_when_you_treat_them_as_data.png" alt="" width="289" height="243">
<h3>What Are Your Use Cases for Log Visualization?</h3>
The purpose of this post was not to call out every use case of log visualization.&nbsp; I couldn't do that even if I spent tens of thousands of words and many posts trying.&nbsp; So I clearly won't do it in one.

Instead, I was just hoping to give you some ideas for seeing a common practice in a new light.&nbsp; It's easy to think of logs as the equivalent of your house's attic.&nbsp; Just stuff everything in there and sort it out later, if you ever really need to find something.

But they can be so much more powerful than that when you treat them as data.&nbsp; And data gets even more powerful when you visualize it.

So what are you doing with the visualization of your log files?&nbsp; What's in your dashboard and what do you keep an eye on?&nbsp; Weigh in below in the comments.