A panel plugin for Grafana for dynamic, data-driven text.
While the built-in Text panel in Grafana does support variables, that's about as dynamic it gets. This panel lets you define a text template using the data from your data source query.
- Grafana 7.0+ is required for version 1.X.
The Dynamic Text panel can be installed from the Grafana Catalog or use the grafana-cli
tool to install from the command line:
grafana-cli plugins install marcusolsson-dynamictext-panel
- Supports Markdown and Handlebars.
- Uses markdown-it for rendering Markdown to HTML.
- HTML inside templates is sanitized using XSS through textUtil.
A Handlebars template with support for Markdown.
To use display data from your query result, enter the name of the field surrounded by double braces. For example, to display the value from the Time
field, enter {{Time}}
.
Grafana renders the template for every row in the query result. If a query returns multiple query results, you can select the query result you wish to display from a drop-down menu.
You can even do basic text processing using one or more helpers inside your template.
Whenever the data source query returns an empty result, Grafana displays the template in Default content instead of Content.
This can be useful to provide users with instructions on what to do, or who to contact, when the query returns an empty result.
Even though there's no data from the data source, you can still use the available helpers.
By default, the template configured in the Content field is rendered for each record in the result.
You can render this template only once by turning this switch off. In this case, the query results are passed in as the data
field to the template.
Handlebars provides a builtin-helper to iterate over these records.
Let's say that your data source returns the following data:
| app | description | cluster | tier |
| ---- | ---------------------------- | ------- | -------- |
| auth | Handles user authentication. | prod | frontend |
You can then write Markdown with placeholders for the data you want to use. The value inside each double brace expression refers to a field in the query result.
# {{app}}
{{description}}
{{#if (eq tier "frontend")}}
https://{{cluster}}.example.com/{{app}}
{{/if}}
The panel renders Handlebars → Markdown → HTML and displays the final result.
For more examples, take a look at
- Helpers - functions that let you perform basic text transformation within your template.
- Recipes - useful snippets that you can use in your templates.
We love to hear from users, developers, and the whole community interested in this plugin. These are various ways to get in touch with us:
- Ask a question, request a new feature, and file a bug with GitHub issues.
- Star the repository to show your support.
- Apache License Version 2.0, see LICENSE.