askvity

How to Customize Your Legend in Grafana

Published in Grafana Legend Customization 4 mins read

To change your legend in Grafana, you primarily interact with the Legend section within the panel edit pane for the specific visualization you wish to modify.

Modifying your Grafana panel's legend allows you to control its appearance, what information it displays, and its position, enhancing the clarity and readability of your dashboards.

Step-by-Step Guide to Access Legend Settings

Follow these straightforward steps to access the legend customization options for any panel:

  1. Navigate to the Panel: Go to the Grafana dashboard containing the panel you want to update.
  2. Open Panel Edit Mode:
    • Hover over any part of the panel you wish to work on.
    • A menu will appear on the top right corner of the panel.
    • Click this menu.
    • Select Edit from the dropdown options.
  3. Locate the Legend Section:
    • Once in the panel edit pane (typically on the right side of the screen), scroll down through the various visualization settings.
    • You will find a dedicated section labeled Legend.

Understanding Legend Customization Options

Within the Legend section, Grafana offers various settings to tailor your legend's behavior and appearance. While the exact options can vary slightly based on the visualization type (e.g., Graph, Stat, Table), common settings include:

  • Display Mode:
    • List: Displays legend items as a vertical list.
    • Table: Arranges legend items in a table format, often allowing additional value columns.
    • Hidden: Hides the legend entirely, useful when space is critical or labels are embedded directly on the visualization.
  • Position:
    • Bottom: Places the legend below the panel.
    • Right: Places the legend to the right of the panel.
  • Values: You can choose to show various statistical values for each series in the legend. Common options include:
    • Min: Minimum value.
    • Max: Maximum value.
    • Avg: Average value.
    • Current: Latest value.
    • Total: Sum of all values.
    • Count: Number of data points.
  • Placement of Values: Define whether these values appear in the legend, on the tooltip, or both.
  • Show as Table/List: Switch between a compact list view and a more detailed table view for legend items, especially useful when displaying multiple values per series.
  • Alias (Series Naming): While not directly in the "Legend" section, the Alias field (often found in the "Query" tab or "Series overrides") is crucial for controlling the names that appear in your legend. Using template variables or regular expressions here can dynamically name your series, making the legend more descriptive.
  • Series Overrides: For fine-grained control, Series Overrides allow you to apply specific legend settings (and other display options) to individual series based on their name or a regex pattern, overriding the global legend settings.

Example: Enhancing Readability

Consider a panel displaying CPU usage for multiple servers. By customizing the legend:

  • You can set the Position to "Right" for better horizontal space utilization.
  • Enable Values like "Current" and "Max" to quickly see the latest and peak CPU usage directly in the legend.
  • If using aliases, you could name your series CPU Usage - $hostname to clearly identify each server in the legend.

By leveraging these settings, you can transform your Grafana legends from simple labels into powerful data summary tools, making your dashboards more intuitive and informative.

Related Articles