Relevant starting from version 3.2.0.
The Data Manipulation plugin offers to convert any Grafana dashboard into a fully functional web application. No wonder getting lost in all option parameters and their interconnections is easy.
The schema below is created to illustrate the major parts and their roles.
The initial request is executed after the browser finishes a page-loading step. You can configure your Initial request as Query, Data Source, and REST API.
The query is short for the native Grafana query. Any initial request carries data from a data source into Grafana and is what the core Grafana does already with excellence. The Query method works with the data frames prepared by the Data Source, the one you specified on the left.
This method was created to allow leveraging the existing Grafana data extraction mechanism. To make it work, map every Data Manipulation form element to the appropriate data frame field.
Do not confuse this data source with the one you can select on the left-hand side. This is a different parameter located in the Update Request section and is visible when the Data source type is selected.
The Data source type is more flexible than the Query type. However, it means the developer must also take more responsibility by creating Initial Payload Request.
The Initial Payload Request is a mandatory piece of code that needs to contain the database request at the bare minimum. More complex data parsing functionality could be added if required.
The REST API type works with an external API server. When specifying the API URL, you can use global and dashboard variables. Header parameters are available as separate options.
You can find ready-to-use API servers for Deno, InfluxDB, JSON API, MySQL, Node-Red, and PostgreSQL in servers section.
Find more information, tips and tricks in our documentation.
Initial Request Custom Code
To create post-processing logic, you can access panel options, API responses, form elements, Grafana services, dashboard, and global variables. Find the code snippet here.
Ball is on the user's side
The Data Manipulation form rests at this step, awaiting the user's actions.
You can enable the Highlight Changes feature, which displays all modifications made by the user in a specified color. For the Query and REST API Initial request types, simply enabling the feature in the plugin edit mode is enough.
For the Data Source type, you must use the
SetInitial() function in the Initial Request Custom Code. See the illustration for the Initial Request, Data Source type above (on the picture). Also, find code examples here.
The reset button is not shown by default. To review all available options, switch the visibility parameter to anything, but 'hidden'. Primary, Secondary and Destructive are pre-set visualization templates. In Custom, you can specify foreground color, background color, icon and the text to put instead of 'Reset' if needed.
When this button is not hidden (any other mode is selected), you will also get the Reset Request section. There, you can go with either the Initial Request option or Custom code.
The Initial request is selected by default. In that event, the plugin executes the Initial Request again as if the form is being loaded for the first time.
In the Custom code, you can have any custom logic required. For instance, set all form elements to their defaults.
The Update Request carries data from the Grafana dashboard to your data source. There are two ways of doing so - Data Source and Rest API. This process is independent of the Initial Request, which means you can use any combination of Initial and Update Request types.
See the description for the Initial Request REST API. Both Initial and Update requests have the same parameters. Also similarly, you can use global and dashboard variables in the API server call along with header parameters.
You can enable the Confirmation step if needed. This step looks like a popup window with old and new values. For the Query and REST API Initial request types, simply enabling the feature in the plugin edit mode, Update Request section, is enough.
For the Data Source type, you must use the
SetInitial() function in the Initial Request Custom Code. See the illustration for the Initial Request, Data Source type above (on the picture).
Following Confirmation, the Submit button initiates the Update Request.
Update Request Custom Code
Or in other words, the post-processing step. Similarly to the Initial Request Custom Code, this step exists in all Update Request Custom Code types. You can access the same entities from the code: panel options, API responses, form elements, Grafana services, dashboard, and global variable. Find the code snippet here.
For example, during the post-processing, you can output a status message, transition the user to another dashboard, reload a page, call an initial request, etc.
Save Default Button
In addition to the Submit and Reset button, there is a third one - Save Default. It saves the current form values in the dashboard. You can choose an icon and text instead of the pre-set ones.
Initial Request vs Update Request
Below is the comparative table showing the similarities and differences between the initial and update requests.
The below schema summarises the information about buttons available in the Data Manipulation form.