How to add a custom value in Grafana Legend?

by emerald.wunsch , in category: General Help , a year ago

How to add a custom value in Grafana Legend?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by cecelia , a year ago

@emerald.wunsch 

To add a custom value in Grafana Legend, you can use the Templating feature. Here's a step-by-step guide:

  1. In Grafana, open the Dashboard you want to customize the Legend for.
  2. Click on the Settings (gear) icon in the top-right corner of the screen.
  3. From the dropdown menu, select "Templating."
  4. Click on the "+ New" button to create a new template variable.
  5. Set the Name for the variable, which will be displayed in the Legend.
  6. In the Query field, enter a query that will generate the custom value you want to add to the Legend. For example, you may use a Prometheus query or any other data source query to compute a desired value.
  7. Configure any other options you require, such as a custom Label or Default value for the variable.
  8. Click on the "Add" button to save the template variable.
  9. Go back to your Dashboard view.
  10. Edit the Panel for which you want to show the custom value in the Legend.
  11. In the Metrics tab, select the Legend format using the "Legend" dropdown option.
  12. When setting up the Legend format, you can use the newly created template variable as a metric label. Simply add the template variable within curly braces. For example, if your template variable is named "my_variable", you can use the "{my_variable}" placeholder in the Legend format.
  13. Save the Panel settings.
  14. Refresh the Dashboard, and you should see your custom value in the Legend.


By using the Templating feature, you can create dynamic custom values in the Legend that will update based on the selected template variable.

Member

by albert , 8 months ago

@emerald.wunsch 

Here are the step-by-step instructions to add a custom value in the Grafana Legend:

  1. Open the Grafana Dashboard where you want to add the custom value in the Legend.
  2. Click on the settings (gear) icon located in the top-right corner of the screen.
  3. In the dropdown menu, select "Templating."
  4. Click on the "+ New" button to create a new template variable.
  5. Set the Name for the variable that will be displayed in the Legend.
  6. In the Query field, enter the query that will generate the custom value you want to add to the Legend. You may use queries from your data source to compute the desired value.
  7. Configure any additional options like Label or Default value for the variable.
  8. Click on the "Add" button to save the template variable.
  9. Go back to the Dashboard view.
  10. Edit the Panel for which you want to display the custom value in the Legend.
  11. In the Metrics tab, select the Legend format using the "Legend" dropdown option.
  12. When configuring the Legend format, you can use the template variable you created by enclosing it in curly braces. For instance, if your template variable is named "custom_value", use "{custom_value}" as a placeholder in the Legend format.
  13. Save the Panel settings.
  14. Refresh the Dashboard, and you should see the custom value displayed in the Legend.


Using the Templating feature in Grafana allows you to create dynamic custom values in the Legend that update based on the selected template variable.