You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/create-plugin/templates/datasource/.config/AGENTS/instructions.md
+13-3Lines changed: 13 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,11 +24,11 @@ A typical datasource with backend plugin includes:
24
24
**Main module (`src/module.ts`)**
25
25
26
26
- Exports: `new DataSourcePlugin(DataSource)`
27
-
- Registers query editor, config editor.
27
+
- Registers query editor, config editor
28
28
29
29
**Data source (`src/datasource.ts`)**
30
30
31
-
-Defines the class that extends DataSourceWithBackend.
31
+
-Frontend datasource that extends DataSourceWithBackend.
32
32
- Connects the UI to the backend, provides the default query, applies template variables, filters queries, and sends them to the Go backend for execution
33
33
34
34
**Query editor (`src/QueryEditor.tsx`)**
@@ -42,10 +42,15 @@ A typical datasource with backend plugin includes:
42
42
43
43
**Main module (`pkg/main.go`)**
44
44
45
-
- Register a factory function with `grafana-plugin-sdk-go` to create datasource backend instances.
45
+
- Register a factory function with `grafana-plugin-sdk-go` to create datasource backend instances
46
46
47
47
**Data source (`pkg/plugin/datasource.go`)**
48
48
49
+
- Backend datasource that Implements QueryData (receives queries from frontend, unmarshals into queryModel, returns data frames)
50
+
- CheckHealth (validates API key from settings)
51
+
- Dispose (cleanup hook).
52
+
- NewDatasource factory called when Grafana starts instance of plugin
53
+
49
54
### Repository layout
50
55
51
56
-`src/` - Frontend (TypeScript/React)
@@ -84,12 +89,17 @@ You must **NOT**:
84
89
- Modify anything inside `.config/*`
85
90
- Remove/change existing query model without a migration handler
86
91
- Break public APIs (query model)
92
+
- Use the local file system
93
+
- Use environment variables
94
+
- Execute arbitrary code in the backend
87
95
88
96
You **SHOULD**:
89
97
90
98
- Maintain backward compatibility
91
99
- Preserve query model schema unless migration handler is added
92
100
- Follow official Grafana datasource plugin patterns
93
101
- Use idiomatic React + TypeScript
102
+
- Use secureJsonData instead of jsonData for credentials and sensitive data
103
+
- Error happening should be logged with level `error`
0 commit comments