Learn Grafana 7.0
上QQ阅读APP看书,第一时间看更新

Editing the graph in the Panel tab

On the right-hand side of the graph display, you'll find the Panel tab, where you'll find a boatload of features for tailoring the look of your panel. The panel's myriad of options are available from one easily accessed column, with each one featuring a disclosure control so that you only need to see the options relevant to the task at hand.

The Settings section

Starting from the top of the Panel tab, the Settings section is used for general panel settings such as the title or description. As shown in the following screenshot, the Settingssection contains three settings:

  • Panel title: Sets the panel's title on the dashboard
  • Description: Sets the content of the panel's information popup
  • Transparent: Increases the panel's transparency:

Setting the panel's Title is obviously a good practice if you want to make it clear what the panel represents. Titles support variable substitution, and in Chapter 8, Working with Advanced Dashboard Features, we will look at how to use variables to automatically set parts of the title. Description sets additional information about the panel. This can be displayed by hovering over the information icon (i) in the top-left corner of the panel. The Description setting supports markdown formatting for attractive text styling without the need for HTML editing.

Setting the panel title and description

Let's return to our panel and fill in these fields to give our panel a Title and Description.It's a good practice to set the title of your panels, as well as to provide a description, since it provides viewers with some context for the display:

  1. Fill theTitletext field withMy Awesome Panel or some other text of your choice.
  2. In theDescriptiontextbox, add the following text(or something similar with some markdown tags):
### My Awesome Panel 
This is where I'd like to make a description of my *awesome* panel.

Hover over the tinyisymbol in the top-left corner of the panel display to see your Description text in all its markdown-rendered HTML glory:

The Visualisation section

The Visualisationsection serves as a quick mechanism for switching out the current panel for a different one. It has a filter field to help reduce the number of panels in the listing. Changing the panel will also alter the Panel tab and increase or decrease the number of options corresponding to the particular panel. The Options settings are cached so that they are not lost when switching between panels.

The Display section

The Displaysection is where you can make the most substantial changes to the appearance of the graph. Here, you can decide which combination of bars, points, or lines to activate when drawing the graph. It is here that you should take care when choosing the drawing objects that best represent your data. For instance, if your data represents a set of sampled quantities, you may not want to use lines that imply the data is continuous. Likewise, if the data doesn't represent a measurable quantity, a bar may not be appropriate.

Here's a look at the Displaysection:

Once you have determined what objects you want to represent your data, and depending on which objects you have enabled, additional options will reveal themselves. Most of the options in this group are fairly self-explanatory: Area fill determines the opacity of the fill color, along with a Fill gradient option, which gradually decreases the opacity. Line width sets the width of the lines. Point Radius sets the size of the points. Finally, the Staircase option forces the lines to be drawn in a perpendicular fashion, either horizontally or vertically.

The Hover tooltip

The Hover tooltip is designed to serve as a miniature legend that appears near any point that you hover over. The tooltip works in two modes: all series will draw the values of all dataset series on a single tooltip, while Single will only draw the value for the hover point. If you choose All series mode, Sort order will sort the series' point values in Increasing or Decreasing order; if None is selected, it will order them by how each data series is specified in the Query pane. If you choose to stack your series, you will also have a Stack value choice to display each point either as a cumulative value of the stacked points or each value as an individual one.

Stacking and Null value

Stacking displays multiple series, one on top of the other. Be mindful when stacking series where each series a) should use the same measurement units and b) be a portion of a larger whole. If you deviate from one of those rules, you may save some space by packing multiple series onto the same graph, but you may also create a misleading association between the series or otherwise confuse someone looking at your graphs. If you do choose to stack your series, you can make the part-to-whole relationship even more explicit by toggling the Percent setting on.

Setting Null value really depends on the specific nature of your data and how you want to display empty data points, called nulls. Setting it to connected effectively ignores nulls, so Grafana will interpolate the line graph between the points with values. Setting it to null will display the break in the graph where there is a null point, which may not be aesthetically pleasing, but may be necessary for making it clear if you have missing data. Finally, the null as zero setting treats null points as having a zero value, which will allow a cleaner graph but will still highlight the discontinuities. The proper choice is often a judgment call based on a balance between aesthetics and data visualization integrity.

The Series overrides section

Series overrides is a powerful tool for fine-grained control over some of the many settings Grafana typically provides by default, such as color, line or point size, stacking order, and so on, and is based on matching the name of the data series to a collection of settings overrides. We will cover Series overrides in Chapter 5, Visualizing Data in the Graph Panel.

The Axes section

Moving onto the Axessection, the graph panel will display up to two Y-Axes (the left- and right-hand sides of the graph), and the X-axis; you can turn each of the three axes on or off. Each axis is given its own settings grouping, as shown in the following screenshot:

Let's take a look at these now.

Left Y/Right Y

Since Grafana is data-agnostic, you can choose to display the Y-axis in almost any way you want. You can specify by Unit, set Scale as either linear or logarithmic, set the minimum (Y-Min) and maximum (Y-Max) values for Y, and set the number of Decimals in the axis values. You can also Label the axis.

X-axis

The X-axis can be set to display in three different modes: Time, which is a standard time-series axis; Series, which displays each data series as a bar graph based on the Value aggregation setting; and Histogram, which displays a histogram of all the Y values. The number of histogram buckets can be set manually with the Buckets option, and the X-min and X-max settings will truncate the left- or right-hand sides, respectively.

The Legend section

You've probably already seen the legend in action when you first set up the graph panel. The legend options are mostly designed to control the placement of the legend, or its contents. As shown in the following screenshot, it's covered by three groups:

Let's take a look at these now.

Options

Options are used to control the overall placement and visibility of the legend. You can turn it on or off with Show. As Table arranges the entries in a tabular order, rather than linearly. It also has a nifty spreadsheet-like column sort feature when displaying Values (see the next subsection). To the right places the legend off to the right, rather than at the bottom of the graph. If you enable the right-hand side placement, a minimum width can also be guaranteed by setting Width.

Values

Normally, the legend is just used to map a color to a data series, but the Values group is great for displaying some simple series aggregation data. You can turn on Min, Max, Avg (Average), Current, and Total. Bear in mind that turning all of them on when the legend is on the right will dramatically reduce the display size for the graph itself. Set the maximum number of digits after the decimal with Decimals. If you don't see the values update, try toggling the visibility for one of them.

Hide series

If you need to conserve some space in the legend, especially if you have a lot of data series in your graph, you might be able to remove any series that contains no usable data. With only nulls will hide any series containing only nulls, while With only zeros does the same thing for series with only zeros. Note that this doesn't hide the series; it only hides the series entry in the legend.

The Thresholds section

While Grafana has an extensive alerting system, which we will look at shortly, perhaps you only want to see when your data crosses specific boundaries, but not necessarily get alerts. Perhaps you are preparing to establish alerts, but first need to determine what the typical boundary thresholds are. Thresholds graphically depict these boundaries as horizontal indicators set at specific values.

Bear in mind that Thresholds and Alerts are mutually exclusive, that is, defining an Alert will disable Thresholds.

Specifying a threshold is easy: simply click the+ Add Thresholdbutton. You will get an indicator on the graph that you can drag to set a threshold. Setting value in the field updates the indicator and vice versa. From there, you can set whether the threshold is crossed when the value is less than (lt) or greater than (gt) the threshold, the Color of the threshold area, whether to style the threshold area with a Fill and/or the indicator Line, and to which Y-axis the threshold applies.

Setting a threshold

Let's go ahead and set a threshold. This is also a good way to get familiar with the process of setting an alert:

  1. Select and add a threshold:You'll now see a threshold entry. You can set multiple thresholds. The threshold can be set either by entering a value in the numerical value field or by dragging the threshold manipulator handle to the right of the graph display. Note:The handle is only visible if there is no series when using the right-hand Y-axis.
  2. Drag the indicator to a value somewhere around the halfway point on the graph: Half the graph area will now be shaded. The region to be shaded indicates where the threshold lies. To set the threshold area above the line, set the threshold dropdown togt(for greater than). To set the area so that it falls below the line, set the threshold dropdown tolt(for less than). For this exercise, leave the threshold set at gt.
  3. Set the color (or severity) of the threshold towarning: TheColorfield is used to set the color of the threshold area. The color can be used as a visual cue to convey the severity of the threshold. We'll set the color towarning, which is an amber color (for caution).

Toggling the Fill setting to turn the region on and off while toggling the Line setting turns the threshold line on and off. The Y-Axis setting determines whether the threshold applies to the left or right Y-axis when the left and right Y-axes have independent ranges. You can delete the threshold by selecting the trash icon.

Your graph should look something like this:

The Time Region section

Time regions are time periods during the day for one or more days of the week for which a corresponding threshold applies.

While similar to a threshold, specifying a time region is a little trickier in that you have to work in UTC time. Clicking on + Add Time Region creates a new region. To specify the time, enter it in the text field, keeping in mind that all times need to be in UTC. You can also specify which day of the week begins the region and which ends it. Color, Fill, and Line work in the same fashion as they do in a threshold.

Setting a time region

Now, let's create a time region to go with our previously specified threshold (called T1). The time region narrows the time period for which a threshold is in effect:

  1. Set the time range toLast 24 Hours.
  2. Select + AddTime Region.

The 24-hour time range is to give you quick feedback as to whether you've correctly set the region. Unfortunately, there is no manipulator for setting time regions – you can only type in the start (From) and end (To) times.

  1. Set the From time to 0900 local time, adjusted to UTC.

Don't worry if you don't see the region yet. It takes both a From and To time to get a region. You'll need to convert 9:00 a.m. to UTC (hh:mm format)in order to determine the correct time for the field. We'll leave the From day dropdown set to Any. Normally, Any means the threshold is active every day at the From and To times, so the day setting can be used to extend the time region across multiple days (for example, a workweek of Monday to Friday).

  1. Set theTotime to1700local time, again adjusted to UTC.

You'll need to convert 5:00 p.m. into UTC in order to determine the correct time for the field. We'll leave the To day set to Any.

  1. Set Color to Green and enable Line.

This is roughly how the graph should look:

As we'll see later, the techniques for creating Alerts are very similar.

The Data links section

Data links connect graph data points to external resources. Data links can be as simple as a single static URL for a dynamic system that leverages template variables and links each data point in the graph with, for example, an external logging monitor. Metadata about each selected data point is available for constructing a specific URL corresponding to a log listing at the same time. To create a link from a point in this data series in another panel, use the Data linkssection.

Clicking+ Add link launches a dialog box with three settings:

  • Title: Contains descriptive link text
  • URL: Link to an external resource
  • Open in new tab

Clicking on a graph data point will bring up a popup, which will display the data links below Add annotation. We will explore techniques for linking and annotating data and panels in Chapter 8,Working with Advanced Dashboard Features.

The Links section

If you would like to add links from the panel to other resources (other panels, dashboards, other websites, and so on), use the Linkssection.

Clicking +Add link brings up a dialog box with three settings:

  • Title: Contains the link text
  • URL: Link to another resource
  • Open in new tab

The link will appear at the bottom of the information (i icon) popup if the panel's Description contains text; otherwise, the corner will display a link icon and the link will appear when it's hovered over. This feature will be discussed in more detail in Chapter 8,Working with Advanced Dashboard Features.

The Repeat options section

The Repeat optionssection is used in combination with template variables to automatically generate additional panels. Select a template variable from the Repeatingdropdown to select a parameter for creating the additional repeating panels.

We will look at template variables and how to use them to create panels in Chapter 8, Working with Advanced Dashboard Features.