VolkovLabs / business-forms

The Business Forms panel is a conceptually new plugin for Grafana. It is the first plugin that allows inserting and updating application data, as well as modifying configuration directly from your Grafana dashboard.
https://docs.volkovlabs.io
Apache License 2.0
86 stars 10 forks source link

Create a row in AWS Postgres using Business forms #515

Closed Filikin closed 1 month ago

Filikin commented 1 month ago

I have Grafana using on AWS with Business forms version 4.6.0 I created a simple form to allow a row to be created in the PostGres database that is the source for Grafana In the update request payload, I have the following code:

const payload = {};

context.panel.elements.forEach((element) => { if (!element.value) { return; }

payload[element.id] = element.value; }) const queryInsert = { rawSql: INSERT INTO battery_locations (client_id, location) VALUES ('${payload.client_id}', '${payload.location}'), format: 'table', }; console.log(queryInsert); return queryInsert;

I can see from the console that queryInsert is {rawSql: "INSERT INTO battery_locations (client_id, location) VALUES ('EPS123', 'My Office')", format: 'table'}

but nothing is getting to the database.

Is there a log either in the plugin or Grafana that I can use to help debug the issue? Nothing appears in the AWS database logs.

I am making the assumption that this should work, based on the tutorial videos

mikhail-vl commented 1 month ago

@Filikin You can check in the Browser's Network tab the payload and response to troubleshoot the issue.

What do you see in the context.panel.response object? Was it successful?

Filikin commented 1 month ago

Thanks, the problem was that I was looking that the tutorials for V3 and had missed the significance of the query editor in the Update Request Payload section

Filikin commented 1 month ago

All good now, the dashboard is updating the PostGres database

mikhail-vl commented 1 month ago

@Filikin Correct, Query Editor was introduced in v4 is a game-changer and provides better user experience than v3.