@grafana/create-plugin 7.13.0 → 7.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/codemods/additions/additions.js +12 -0
- package/dist/codemods/additions/prompts/docs-content.md +131 -0
- package/dist/codemods/additions/scripts/docs-content.js +30 -0
- package/dist/codemods/additions/scripts/docs.js +468 -0
- package/dist/codemods/additions/scripts/experimental-app-sdk.js +15 -14
- package/dist/codemods/utils.agents.js +64 -0
- package/dist/codemods/utils.js +40 -7
- package/dist/codemods/utils.workflows.js +94 -0
- package/dist/utils/utils.cli.js +3 -2
- package/dist/utils/utils.handlebars.js +9 -2
- package/package.json +1 -1
- package/src/codemods/additions/additions.ts +12 -0
- package/src/codemods/additions/prompts/docs-content.md +131 -0
- package/src/codemods/additions/scripts/docs-content.test.ts +103 -0
- package/src/codemods/additions/scripts/docs-content.ts +32 -0
- package/src/codemods/additions/scripts/docs.test.ts +1766 -0
- package/src/codemods/additions/scripts/docs.ts +697 -0
- package/src/codemods/additions/scripts/experimental-app-sdk.test.ts +4 -3
- package/src/codemods/additions/scripts/experimental-app-sdk.ts +15 -15
- package/src/codemods/migrations/scripts/004-eslint9-flat-config.ts +1 -3
- package/src/codemods/utils.agents.test.ts +140 -0
- package/src/codemods/utils.agents.ts +81 -0
- package/src/codemods/utils.test.ts +23 -0
- package/src/codemods/utils.ts +29 -7
- package/src/codemods/utils.workflows.test.ts +153 -0
- package/src/codemods/utils.workflows.ts +140 -0
- package/src/utils/utils.cli.ts +2 -1
- package/src/utils/utils.handlebars.ts +9 -0
- package/templates/app-sdk/.config/app-sdk/generate-kinds.mjs +1 -1
- package/templates/docs/app/docs/AGENTS.md +127 -0
- package/templates/docs/app/docs/CLAUDE.md +1 -0
- package/templates/docs/app/docs/README.md +20 -0
- package/templates/docs/app/docs/configure.md +65 -0
- package/templates/docs/app/docs/dashboards.md +29 -0
- package/templates/docs/app/docs/index.md +70 -0
- package/templates/docs/app/docs/permissions.md +45 -0
- package/templates/docs/app/docs/troubleshooting.md +65 -0
- package/templates/docs/app/feature-page.md +26 -0
- package/templates/docs/app/features-index.md +12 -0
- package/templates/docs/common/workflows/validate-docs.yml +52 -0
- package/templates/docs/datasource/docs/AGENTS.md +123 -0
- package/templates/docs/datasource/docs/CLAUDE.md +1 -0
- package/templates/docs/datasource/docs/README.md +20 -0
- package/templates/docs/datasource/docs/alerting.md +56 -0
- package/templates/docs/datasource/docs/annotations.md +68 -0
- package/templates/docs/datasource/docs/configure.md +114 -0
- package/templates/docs/datasource/docs/dashboards.md +28 -0
- package/templates/docs/datasource/docs/index.md +40 -0
- package/templates/docs/datasource/docs/query-editor.md +72 -0
- package/templates/docs/datasource/docs/template-variables.md +69 -0
- package/templates/docs/datasource/docs/troubleshooting.md +73 -0
- package/templates/docs/panel/docs/AGENTS.md +113 -0
- package/templates/docs/panel/docs/CLAUDE.md +1 -0
- package/templates/docs/panel/docs/README.md +20 -0
- package/templates/docs/panel/docs/data-formats.md +27 -0
- package/templates/docs/panel/docs/examples.md +35 -0
- package/templates/docs/panel/docs/index.md +26 -0
- package/templates/docs/panel/docs/options.md +53 -0
- package/templates/docs/panel/docs/troubleshooting.md +35 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
name: Validate documentation
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
- master
|
|
8
|
+
paths:
|
|
9
|
+
- '{{docsPath}}/**'
|
|
10
|
+
- 'src/plugin.json'
|
|
11
|
+
- 'package.json'
|
|
12
|
+
{{#if lockFile}}
|
|
13
|
+
- '{{lockFile}}'
|
|
14
|
+
{{/if}}
|
|
15
|
+
pull_request:
|
|
16
|
+
branches:
|
|
17
|
+
- main
|
|
18
|
+
- master
|
|
19
|
+
paths:
|
|
20
|
+
- '{{docsPath}}/**'
|
|
21
|
+
- 'src/plugin.json'
|
|
22
|
+
- 'package.json'
|
|
23
|
+
{{#if lockFile}}
|
|
24
|
+
- '{{lockFile}}'
|
|
25
|
+
{{/if}}
|
|
26
|
+
|
|
27
|
+
jobs:
|
|
28
|
+
validate:
|
|
29
|
+
name: Validate plugin docs
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
permissions:
|
|
32
|
+
contents: read
|
|
33
|
+
steps:
|
|
34
|
+
- uses: actions/checkout@v7
|
|
35
|
+
with:
|
|
36
|
+
persist-credentials: false
|
|
37
|
+
{{#if_eq packageManagerName "pnpm"}}
|
|
38
|
+
# pnpm action uses the packageManager field in package.json to
|
|
39
|
+
# understand which version to install.
|
|
40
|
+
- uses: pnpm/action-setup@v6
|
|
41
|
+
{{/if_eq}}
|
|
42
|
+
- name: Setup Node.js environment
|
|
43
|
+
uses: actions/setup-node@v7
|
|
44
|
+
with:
|
|
45
|
+
node-version: '22'
|
|
46
|
+
cache: '{{packageManagerName}}'
|
|
47
|
+
|
|
48
|
+
- name: Install dependencies
|
|
49
|
+
run: {{packageManagerInstallCmd}}
|
|
50
|
+
|
|
51
|
+
- name: Validate plugin documentation
|
|
52
|
+
run: {{packageManagerName}} run docs:validate
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Plugin docs
|
|
2
|
+
|
|
3
|
+
This folder is the documentation for **{{{pluginName}}}**, published at
|
|
4
|
+
`grafana.com/grafana/plugins/{{pluginId}}/docs/`.
|
|
5
|
+
|
|
6
|
+
## Guides
|
|
7
|
+
|
|
8
|
+
Read these before you write or change any page. This docs format is new and your training
|
|
9
|
+
data does not cover it, so do not rely on what you know about other docs tools.
|
|
10
|
+
|
|
11
|
+
Run `{{packageManagerName}} run docs:validate` and open the guide on its last line, `Docs guides:`. It's
|
|
12
|
+
the guides' `index.md`, which says which guide to read for what, and the other guides sit next to it.
|
|
13
|
+
The guides match the version of the validator this plugin uses. The line is a local path, usually
|
|
14
|
+
`node_modules/@grafana/plugin-docs-cli/docs/index.md`, or a URL when the package isn't on disk, such as
|
|
15
|
+
with Yarn Plug'n'Play.
|
|
16
|
+
|
|
17
|
+
The guides name scripts such as `docs:validate`. This plugin uses **{{packageManagerName}}**, so run them
|
|
18
|
+
with `{{packageManagerName}} run`, as in the commands below.
|
|
19
|
+
|
|
20
|
+
## Pages and their source
|
|
21
|
+
|
|
22
|
+
`annotations.md`, `alerting.md` and `dashboards.md` exist only when the plugin has that feature, as
|
|
23
|
+
described under [Optional pages](#optional-pages).
|
|
24
|
+
|
|
25
|
+
Files may have moved since the plugin was scaffolded, so trace them from `src/module.ts`.
|
|
26
|
+
`new DataSourcePlugin<DataSource, Query, Options>(DataSource)` names the data source class, the query type
|
|
27
|
+
and the options type, and `setConfigEditor` and `setQueryEditor` name the editor components.
|
|
28
|
+
|
|
29
|
+
| Page | Source of truth |
|
|
30
|
+
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
31
|
+
| `index.md` | Nothing - it is a curated router. Update it when pages are added or removed. |
|
|
32
|
+
| `configure.md` | The `setConfigEditor` component and the options type. With a backend, also how it reads these settings and its `CheckHealth` handler |
|
|
33
|
+
| `query-editor.md` | The `setQueryEditor` component, the query type and the code that runs queries in the data source class or backend |
|
|
34
|
+
| `template-variables.md` | Variable support in the data source class: `variables` or `metricFindQuery`, `applyTemplateVariables`, and `getTagKeys` and `getTagValues` |
|
|
35
|
+
| `annotations.md` | `annotations` support in the data source class |
|
|
36
|
+
| `alerting.md` | The backend's query handling, and what the data source class does to queries first, since alert rules skip it |
|
|
37
|
+
| `dashboards.md` | `includes` entries of type `dashboard` in `src/plugin.json` and their JSON files |
|
|
38
|
+
| `troubleshooting.md` | Error messages in source, known issues in the README or other docs and reported issues. Never guess failures |
|
|
39
|
+
|
|
40
|
+
## Optional pages
|
|
41
|
+
|
|
42
|
+
Add one of these pages when the plugin has the matching feature. Use the filename given here, give the page
|
|
43
|
+
a `sidebar_position` that puts it where it belongs and link it from `index.md`.
|
|
44
|
+
|
|
45
|
+
| Trigger | Page | Scope |
|
|
46
|
+
| -------------------------------------------------- | ---------------- | ---------------------------------------------------------------- |
|
|
47
|
+
| `"annotations": true` in `src/plugin.json` | `annotations.md` | Annotation queries, the fields they return and examples. |
|
|
48
|
+
| `"alerting": true` in `src/plugin.json` | `alerting.md` | Which queries work in alert rules, creating a rule and examples. |
|
|
49
|
+
| An `includes` entry of type `dashboard` | `dashboards.md` | What each bundled dashboard shows and how to import it. |
|
|
50
|
+
| Macros that outgrow a section of `query-editor.md` | `macros.md` | Every macro with its syntax, what it expands to and an example. |
|
|
51
|
+
| RBAC role declarations in `src/plugin.json` | `permissions.md` | What each role grants, default assignments. |
|
|
52
|
+
|
|
53
|
+
## What not to write
|
|
54
|
+
|
|
55
|
+
Never write installation instructions, such as installing the plugin with `grafana-cli`, from a zip file or
|
|
56
|
+
in Docker. The Installation tab on the plugin page covers them, and these docs start from a plugin that is
|
|
57
|
+
already installed. When the README has an installation section, leave it out of the pages.
|
|
58
|
+
|
|
59
|
+
## Section briefs
|
|
60
|
+
|
|
61
|
+
Each section of a scaffolded page has a brief telling you what belongs there. A brief is an HTML comment
|
|
62
|
+
that starts with `section-brief`. Search the docs folder for `section-brief` to find what is left to write:
|
|
63
|
+
|
|
64
|
+
```markdown
|
|
65
|
+
## Macros
|
|
66
|
+
|
|
67
|
+
<!-- section-brief
|
|
68
|
+
Fill this in: A table of every macro the plugin expands in queries.
|
|
69
|
+
|
|
70
|
+
If the plugin has no macros, remove this section entirely.
|
|
71
|
+
-->
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Some sections also have fixed text, with a brief that builds on it:
|
|
75
|
+
|
|
76
|
+
```markdown
|
|
77
|
+
## Create an alert rule
|
|
78
|
+
|
|
79
|
+
To create an alert rule from a {{{pluginName}}} query:
|
|
80
|
+
|
|
81
|
+
1. Navigate to **Alerting** > **Alert rules**.
|
|
82
|
+
1. Click **New alert rule**.
|
|
83
|
+
|
|
84
|
+
<!-- section-brief
|
|
85
|
+
Fill this in: Continue the list above with the steps for the query and the alert condition.
|
|
86
|
+
-->
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Text outside a brief is written for every data source and is part of the scaffold. Keep it, and change it
|
|
90
|
+
only where it's wrong for this plugin, such as a menu path or a step that differs.
|
|
91
|
+
|
|
92
|
+
Everything inside a brief is the instruction. A brief covers the section it sits under, unless it says
|
|
93
|
+
otherwise: it may tell you to extend the fixed text above it, to replace it with several sections or to
|
|
94
|
+
remove the page. When a brief says to remove a section, remove its heading and fixed text too.
|
|
95
|
+
|
|
96
|
+
To fill a section:
|
|
97
|
+
|
|
98
|
+
1. Read the brief.
|
|
99
|
+
2. Read the source the page documents, from the table above, then write the section.
|
|
100
|
+
3. Delete the whole comment, from `<!-- section-brief` to `-->`.
|
|
101
|
+
|
|
102
|
+
Briefs are not shown in the preview or the catalog, so a section you haven't written looks like a bare
|
|
103
|
+
heading. `docs:validate` lists every section that still has only its brief.
|
|
104
|
+
|
|
105
|
+
## Validate
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
{{packageManagerName}} run docs:validate
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Run `docs:validate` after every page you write or change and fix what it reports. A docs task is done when
|
|
112
|
+
it reports no warnings and no suggestions about section briefs. In particular, an `empty-section` or
|
|
113
|
+
`unfilled-section-brief` suggestion means a section is still unwritten or a brief is still in place. Neither
|
|
114
|
+
fails validation, so a passing exit code alone does not mean the docs are done.
|
|
115
|
+
|
|
116
|
+
## Preview
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
{{packageManagerName}} run docs:serve # local preview at http://localhost:3001, reloads on save
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`docs:serve` keeps running until you stop it. Start it in the background if you need to look at the
|
|
123
|
+
rendered pages, and stop it when you are done.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@AGENTS.md
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# {{{pluginName}}} documentation
|
|
2
|
+
|
|
3
|
+
This folder is the documentation for **{{{pluginName}}}**. It's published on the Documentation tab of
|
|
4
|
+
`grafana.com/grafana/plugins/{{pluginId}}/` with each plugin release. This README isn't published.
|
|
5
|
+
|
|
6
|
+
To learn how plugin docs work and how to write them, read the
|
|
7
|
+
[Add documentation to your plugin](https://grafana.com/developers/plugin-tools/how-to-guides/plugin-docs) guide.
|
|
8
|
+
|
|
9
|
+
## Next steps
|
|
10
|
+
|
|
11
|
+
1. Fill in or review the pages. Each section has a note that says what belongs there.
|
|
12
|
+
2. Add screenshots, videos and figures where they help readers. Save them inside this folder, for example in `img/`, and link to them with a relative path. `docs:validate` checks their formats and sizes.
|
|
13
|
+
3. Run `{{packageManagerName}} run docs:serve` to preview the docs. It also lists every section left to fill.
|
|
14
|
+
|
|
15
|
+
## Commands
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
{{packageManagerName}} run docs:serve # local preview at http://localhost:3001
|
|
19
|
+
{{packageManagerName}} run docs:validate # check your docs, including sections left to fill
|
|
20
|
+
```
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Alerting
|
|
3
|
+
description: "Create Grafana alert rules from {{{yamlEscape pluginName}}} queries."
|
|
4
|
+
keywords:
|
|
5
|
+
- "{{{yamlEscape pluginName}}}"
|
|
6
|
+
- data source
|
|
7
|
+
- alerting
|
|
8
|
+
sidebar_position: 6
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
You can create alert rules that run {{{pluginName}}} queries on a schedule and fire when the result meets a condition, such as a value above a threshold. For general information about alerting, refer to [Grafana Alerting](https://grafana.com/docs/grafana/latest/alerting/).
|
|
12
|
+
|
|
13
|
+
## Before you begin
|
|
14
|
+
|
|
15
|
+
- [Configure the {{{pluginName}}} data source](./configure.md).
|
|
16
|
+
|
|
17
|
+
<!-- section-brief
|
|
18
|
+
Fill this in: Add bullets for what the reader needs in {{{pluginName}}} for alert queries to return data, such as read access, linking to `./configure.md`. If there is nothing to add, delete only this brief.
|
|
19
|
+
-->
|
|
20
|
+
|
|
21
|
+
## Query requirements
|
|
22
|
+
|
|
23
|
+
<!-- section-brief
|
|
24
|
+
Fill this in: Explain that a query must return numeric data: a time series reduced with **Reduce**, or a single numeric row. Say how to get a number otherwise, such as an aggregate or a **Count** over rows, and that each series becomes its own alert instance.
|
|
25
|
+
|
|
26
|
+
If there are several query types, add a table of which work in alert rules. Alert rules run on the backend, so frontend-only query types don't. Mention the time filter macro, such as `$__timeFilter`.
|
|
27
|
+
-->
|
|
28
|
+
|
|
29
|
+
## Create an alert rule
|
|
30
|
+
|
|
31
|
+
To create an alert rule from a {{{pluginName}}} query:
|
|
32
|
+
|
|
33
|
+
1. Navigate to **Alerting** > **Alert rules**.
|
|
34
|
+
1. Click **New alert rule**.
|
|
35
|
+
1. Enter a **Name** for the rule.
|
|
36
|
+
1. Select the **{{{pluginName}}}** data source.
|
|
37
|
+
|
|
38
|
+
<!-- section-brief
|
|
39
|
+
Fill this in: Continue the list with the query step, field labels in bold, then **Reduce** and **Threshold** expressions, evaluation behavior, labels and notifications, and saving. Link to `./query-editor.md` for the fields and to [Create a Grafana-managed alert rule](https://grafana.com/docs/grafana/latest/alerting/configure-alert-rules/create-grafana-managed-rule/) for the rest.
|
|
40
|
+
-->
|
|
41
|
+
|
|
42
|
+
## Limitations
|
|
43
|
+
|
|
44
|
+
<!-- section-brief
|
|
45
|
+
Fill this in: Add an H3 for each thing that works on a dashboard but not in an alert rule, and what to do instead. Alert rules skip the frontend data source class, so check `applyTemplateVariables`, `query()` overrides and ad hoc filters. Also check for auth that needs a signed-in user, such as forwarded OAuth, settings such as a row limit and API rate limits.
|
|
46
|
+
|
|
47
|
+
If nothing applies, remove this section entirely.
|
|
48
|
+
-->
|
|
49
|
+
|
|
50
|
+
## Alert query examples
|
|
51
|
+
|
|
52
|
+
<!-- section-brief
|
|
53
|
+
Fill this in: Add an H3 for each realistic alert, such as on error counts or latency. Say what it watches for, show the query as a code block or as builder steps with field labels in bold, and end with the **Reduce** function and **Threshold** to use.
|
|
54
|
+
|
|
55
|
+
Where it fits, add a no-data alert and one that combines two queries with a **Math** expression.
|
|
56
|
+
-->
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Annotations
|
|
3
|
+
description: "Mark events on your graphs with annotation queries from {{{yamlEscape pluginName}}}."
|
|
4
|
+
keywords:
|
|
5
|
+
- "{{{yamlEscape pluginName}}}"
|
|
6
|
+
- data source
|
|
7
|
+
- annotations
|
|
8
|
+
sidebar_position: 5
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
Annotations overlay event markers on time series panels, so you can correlate events from {{{pluginName}}}, such as deployments or incidents, with the metrics on your dashboards. For general information about annotations, refer to [Annotate visualizations](https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/annotate-visualizations/).
|
|
12
|
+
|
|
13
|
+
## Before you begin
|
|
14
|
+
|
|
15
|
+
- [Configure the {{{pluginName}}} data source](./configure.md).
|
|
16
|
+
|
|
17
|
+
<!-- section-brief
|
|
18
|
+
Fill this in: Add bullets for what the reader needs in {{{pluginName}}} before annotation queries return anything, such as read access to the data, or events stored with a timestamp. Link to the matching section of `./configure.md` for access. If there is nothing beyond the configured data source, delete only this brief.
|
|
19
|
+
-->
|
|
20
|
+
|
|
21
|
+
## Create an annotation query
|
|
22
|
+
|
|
23
|
+
To add an annotation query to a dashboard:
|
|
24
|
+
|
|
25
|
+
1. Navigate to **Dashboard settings** > **Annotations**.
|
|
26
|
+
1. Click **Add annotation query**.
|
|
27
|
+
1. Enter a **Name** for the annotation.
|
|
28
|
+
1. Select the **{{{pluginName}}}** data source.
|
|
29
|
+
|
|
30
|
+
<!-- section-brief
|
|
31
|
+
Fill this in: Continue the list above with the steps in the annotation editor, using its field labels in bold, and end with saving the dashboard.
|
|
32
|
+
|
|
33
|
+
First find out which annotation editor the plugin has. If the data source class sets `annotations` to an `AnnotationSupport` object with its own `QueryEditor`, such as `this.annotations = createAnnotationSupport(this)`, the plugin has a custom annotation editor, so describe its fields here and its options under Annotation editor. If it sets `annotations = {}` or doesn't set it at all, Grafana uses the panel query editor followed by its standard field mapping, so link to `./query-editor.md` instead of repeating its fields.
|
|
34
|
+
-->
|
|
35
|
+
|
|
36
|
+
## Annotation editor
|
|
37
|
+
|
|
38
|
+
<!-- section-brief
|
|
39
|
+
Fill this in: Describe the custom annotation editor, from the `QueryEditor` set on `annotations` in the data source class. Add an H3 for each annotation type or preset it offers, saying when to use it, its fields and the query it generates. Say whether the generated query can be edited, and how the editor differs from the panel query editor. Also check `prepareAnnotation` and `processEvents` for behaviour the reader sees, such as defaults or how results become annotations.
|
|
40
|
+
|
|
41
|
+
If the plugin has no custom annotation editor, remove this section entirely.
|
|
42
|
+
-->
|
|
43
|
+
|
|
44
|
+
## Query requirements
|
|
45
|
+
|
|
46
|
+
<!-- section-brief
|
|
47
|
+
Fill this in: Explain what an annotation query must return. With the standard field mapping, give this table and keep only the fields the plugin can return:
|
|
48
|
+
|
|
49
|
+
| Field | Required | Description |
|
|
50
|
+
| --------- | -------- | ----------- |
|
|
51
|
+
| `time` | Yes | |
|
|
52
|
+
| `timeEnd` | No | |
|
|
53
|
+
| `title` | No | |
|
|
54
|
+
| `text` | Yes | |
|
|
55
|
+
| `tags` | No | |
|
|
56
|
+
|
|
57
|
+
Fields match by name. If there is no `time` field, Grafana uses the first time field, and if there is no `text` field, the first string field. A `timeEnd` field draws a region instead of a single marker. If a custom editor or `processEvents` maps fields differently, describe that mapping instead.
|
|
58
|
+
|
|
59
|
+
If the editor has several query types, add a table of which ones suit annotations and why. Then say how to keep results to the dashboard time range, such as with the `$__timeFilter` macro, and note limits such as a result cap or API rate limits, and whether ad hoc filters also apply to annotation queries.
|
|
60
|
+
-->
|
|
61
|
+
|
|
62
|
+
## Annotation query examples
|
|
63
|
+
|
|
64
|
+
<!-- section-brief
|
|
65
|
+
Fill this in: Give realistic annotation queries for the events people mark with {{{pluginName}}}, such as deployments, incidents or errors, with an H3 for each. Say what each one marks and show the query the way a reader enters it, as a code block for a query language, or as steps with field labels in bold for a builder. Use the field names and syntax the editor really accepts.
|
|
66
|
+
|
|
67
|
+
Include a region example with `timeEnd` if the plugin can return one, and an example that filters events with a dashboard variable if annotation queries interpolate variables.
|
|
68
|
+
-->
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Configure
|
|
3
|
+
description: "Add the {{{yamlEscape pluginName}}} data source in Grafana and connect it to your service."
|
|
4
|
+
keywords:
|
|
5
|
+
- "{{{yamlEscape pluginName}}}"
|
|
6
|
+
- data source
|
|
7
|
+
- configuration
|
|
8
|
+
- provisioning
|
|
9
|
+
sidebar_position: 2
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
This document explains how to add and configure the {{{pluginName}}} data source in Grafana. After you configure the data source, refer to the [{{{pluginName}}} query editor](./query-editor.md) to start querying your data.
|
|
13
|
+
|
|
14
|
+
## Before you begin
|
|
15
|
+
|
|
16
|
+
Before you configure the data source, ensure you have:
|
|
17
|
+
|
|
18
|
+
- **Grafana permissions:** The `Organization administrator` role. Only organization administrators can add data sources.
|
|
19
|
+
|
|
20
|
+
<!-- section-brief
|
|
21
|
+
Fill this in: Keep the list above. Add a bullet in the same **Label:** form for each other thing the reader needs: the instance of the service {{{pluginName}}} connects to and how Grafana reaches it, such as its address, default port and network access, and the credentials and permissions needed on it. If the service can sit behind a firewall, add a `> [!NOTE]` callout telling Grafana Cloud users to allowlist the Grafana Cloud outbound IP addresses, and link to https://grafana.com/docs/grafana-cloud/account-management/allow-traffic/.
|
|
22
|
+
-->
|
|
23
|
+
|
|
24
|
+
## Set up access in {{{pluginName}}}
|
|
25
|
+
|
|
26
|
+
<!-- section-brief
|
|
27
|
+
Fill this in: Steps the reader follows in the service {{{pluginName}}} connects to before adding the data source, such as creating a user, an API token or a cloud role. Take what's needed from the credential fields in the config editor, and work out the least access that works from what the backend calls, such as API endpoints, SQL statements or settings it changes. Say what fails if a permission is missing. Change the heading if necessary to name the task, such as "Create a read-only user". Leave the Grafana fields to Configure settings below.
|
|
28
|
+
|
|
29
|
+
If the reader only needs credentials they already have, remove this section and keep them as a bullet in Before you begin.
|
|
30
|
+
-->
|
|
31
|
+
|
|
32
|
+
## Add the data source
|
|
33
|
+
|
|
34
|
+
To add the {{{pluginName}}} data source:
|
|
35
|
+
|
|
36
|
+
1. Click **Connections** in the left-side menu.
|
|
37
|
+
1. Click **Add new connection**.
|
|
38
|
+
1. Enter `{{{pluginName}}}` in the search bar.
|
|
39
|
+
1. Select **{{{pluginName}}}**.
|
|
40
|
+
1. Click **Add new data source**.
|
|
41
|
+
|
|
42
|
+
## Configure settings
|
|
43
|
+
|
|
44
|
+
<!-- section-brief
|
|
45
|
+
Fill this in: An H3 for each section of the config editor, named and ordered as the editor shows them, such as Connection, Authentication, TLS or Additional settings. Under each H3, a table with this shape:
|
|
46
|
+
|
|
47
|
+
| Setting | Description | Required |
|
|
48
|
+
| ------- | ----------- | -------- |
|
|
49
|
+
|
|
50
|
+
Start the first table with **Name** and **Default**. Use the field labels from the config editor, in bold. Find the settings in the config editor component and the options type, including `jsonData` and `secureJsonData`.
|
|
51
|
+
|
|
52
|
+
In a description, say when a field only appears for some choice, such as a protocol, and when it affects another setting, such as a port that must change when TLS is turned on. If source shows the editor lacks an option readers expect, such as TLS settings, say so and what to do instead. For each authentication method, say when to use it. Use a `> [!NOTE]` callout for a method or setting that's only available in Grafana Cloud or Grafana Enterprise.
|
|
53
|
+
|
|
54
|
+
When a feature needs more than a table row, such as forwarding OAuth identity or HTTP headers, or cloud provider auth like AWS SigV4, give it its own H2 after this section with its setup, requirements and behavior.
|
|
55
|
+
-->
|
|
56
|
+
{{#if hasBackend}}
|
|
57
|
+
|
|
58
|
+
## Private data source connect
|
|
59
|
+
|
|
60
|
+
<!-- section-brief
|
|
61
|
+
Fill this in: Explain how to reach a service on a private network from Grafana Cloud with private data source connect (PDC), and link to https://grafana.com/docs/grafana-cloud/connect-externally-hosted/private-data-source-connect/ for setup. Start with a `> [!NOTE]` callout saying PDC is only available in Grafana Cloud. Name the toggle the config editor shows, and say it only appears when the secure SOCKS proxy is enabled for the Grafana instance. For self-managed Grafana, show the setting that enables it:
|
|
62
|
+
|
|
63
|
+
```ini
|
|
64
|
+
[secure_socks_datasource_proxy]
|
|
65
|
+
enabled = true
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Keep this section only if the backend supports the secure SOCKS proxy (look for `EnableSecureSocksProxy` or `secureSocksProxyEnabled` in source). Otherwise, remove it entirely.
|
|
69
|
+
-->
|
|
70
|
+
{{/if}}
|
|
71
|
+
|
|
72
|
+
## Verify the connection
|
|
73
|
+
|
|
74
|
+
Click **Save & test** to verify the connection.
|
|
75
|
+
|
|
76
|
+
<!-- section-brief
|
|
77
|
+
Fill this in: Give the message the reader sees when the connection works and the most common failure messages, each with what it means. Take the messages from the health check in source (`CheckHealth` in the backend, or `testDatasource` in the frontend). Link failures to [troubleshooting](./troubleshooting.md) with a relative link.
|
|
78
|
+
-->
|
|
79
|
+
|
|
80
|
+
## Provision the data source
|
|
81
|
+
|
|
82
|
+
You can provision the {{{pluginName}}} data source as code, with a Grafana provisioning file or with the Grafana Terraform provider.
|
|
83
|
+
|
|
84
|
+
<!-- section-brief
|
|
85
|
+
Fill this in: List the placeholders the examples below use, such as `<HOST>` or `<API_TOKEN>`, each with what to replace it with.
|
|
86
|
+
-->
|
|
87
|
+
|
|
88
|
+
### Provision with a configuration file
|
|
89
|
+
|
|
90
|
+
You can define the data source in a YAML file as part of the Grafana provisioning system. For more information, refer to [Provision Grafana](https://grafana.com/docs/grafana/latest/administration/provisioning/#data-sources).
|
|
91
|
+
|
|
92
|
+
<!-- section-brief
|
|
93
|
+
Fill this in: A YAML example with this shape, using the real `jsonData` and `secureJsonData` keys from the options type and placeholders for every value the reader must supply:
|
|
94
|
+
|
|
95
|
+
```yaml
|
|
96
|
+
apiVersion: 1
|
|
97
|
+
|
|
98
|
+
datasources:
|
|
99
|
+
- name: {{{pluginName}}}
|
|
100
|
+
type: {{pluginId}}
|
|
101
|
+
jsonData: {}
|
|
102
|
+
secureJsonData: {}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Follow it with a table of the keys it uses and what each one sets. Include `url`, `user` or other top-level fields only if the plugin reads them.
|
|
106
|
+
-->
|
|
107
|
+
|
|
108
|
+
### Provision with Terraform
|
|
109
|
+
|
|
110
|
+
You can provision the data source with the [Grafana Terraform provider](https://registry.terraform.io/providers/grafana/grafana/latest/docs/resources/data_source) using the `grafana_data_source` resource.
|
|
111
|
+
|
|
112
|
+
<!-- section-brief
|
|
113
|
+
Fill this in: A Terraform example with `type = "{{pluginId}}"` that sets the same values as the YAML example. Pass `jsonData` through `json_data_encoded` and `secureJsonData` through `secure_json_data_encoded`, both wrapped in `jsonencode()`.
|
|
114
|
+
-->
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Dashboards
|
|
3
|
+
description: "Import and use the dashboards that ship with {{{yamlEscape pluginName}}}."
|
|
4
|
+
keywords:
|
|
5
|
+
- "{{{yamlEscape pluginName}}}"
|
|
6
|
+
- data source
|
|
7
|
+
- dashboards
|
|
8
|
+
sidebar_position: 7
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
{{{pluginName}}} ships with ready-made dashboards that you can import and use as they are, or as a starting point for your own. For general information about dashboards, refer to [Dashboards](https://grafana.com/docs/grafana/latest/dashboards/).
|
|
12
|
+
|
|
13
|
+
## Import a dashboard
|
|
14
|
+
|
|
15
|
+
To import a dashboard that ships with {{{pluginName}}}:
|
|
16
|
+
|
|
17
|
+
1. Click **Connections** > **Data sources** in the left-side menu.
|
|
18
|
+
1. Select your {{{pluginName}}} data source.
|
|
19
|
+
1. Click the **Dashboards** tab.
|
|
20
|
+
1. Click **Import** next to the dashboard.
|
|
21
|
+
|
|
22
|
+
Imported dashboards don't update when you upgrade the plugin. When a plugin upgrade ships a newer version of a dashboard, click **Update** next to it. This overwrites any changes you made to it.
|
|
23
|
+
|
|
24
|
+
## Included dashboards
|
|
25
|
+
|
|
26
|
+
<!-- section-brief
|
|
27
|
+
Fill this in: One H3 per dashboard in the `includes` list of `src/plugin.json` whose `type` is `dashboard`, using its `name`. For each one, describe what it shows and what data or settings it needs to work, based on the panels and queries in its JSON file.
|
|
28
|
+
-->
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Introduction
|
|
3
|
+
description: "Where to start and what to read next in the {{{yamlEscape pluginName}}} docs."
|
|
4
|
+
keywords:
|
|
5
|
+
- "{{{yamlEscape pluginName}}}"
|
|
6
|
+
- data source
|
|
7
|
+
sidebar_position: 1
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
<!-- section-brief
|
|
11
|
+
Fill this in: Write a short orientation for someone who already has {{{pluginName}}} installed and landed here from the Documentation tab. One or two sentences on what this section covers and how it's organized. Do not restate what the data source connects to, its feature list or its requirements - that's the README's job on the Overview tab, and this reader has already seen it there. Do not list every page in this folder either - the sidebar already does that; use prose to say what to read first and why.
|
|
12
|
+
-->
|
|
13
|
+
|
|
14
|
+
## Recommended path
|
|
15
|
+
|
|
16
|
+
<!-- section-brief
|
|
17
|
+
Fill this in: Give a short, ordered reading path for someone new to {{{pluginName}}} - two or three sentences, not a repeat of the sidebar. Most readers need to connect the data source before anything else, e.g. "Start with **Configure** to connect {{{pluginName}}} to your service, then read **Query editor** to build your first query."
|
|
18
|
+
-->
|
|
19
|
+
|
|
20
|
+
## Common tasks
|
|
21
|
+
|
|
22
|
+
<!-- section-brief
|
|
23
|
+
Fill this in: List the jobs someone lands here to do, phrased as tasks rather than page titles, each linked to the page that answers it. For a typical data source plugin this might look like:
|
|
24
|
+
|
|
25
|
+
- [Connect {{{pluginName}}} and choose an authentication method](./configure.md)
|
|
26
|
+
- [Build and run a query](./query-editor.md)
|
|
27
|
+
- [Make dashboards dynamic with template variables](./template-variables.md)
|
|
28
|
+
{{#if hasAnnotations}}
|
|
29
|
+
- [Mark events on your graphs with annotations](./annotations.md)
|
|
30
|
+
{{/if}}
|
|
31
|
+
{{#if hasAlerting}}
|
|
32
|
+
- [Create alert rules from your queries](./alerting.md)
|
|
33
|
+
{{/if}}
|
|
34
|
+
{{#if hasDashboards}}
|
|
35
|
+
- [Import the dashboards that ship with the plugin](./dashboards.md)
|
|
36
|
+
{{/if}}
|
|
37
|
+
- [Fix connection, authentication and query errors](./troubleshooting.md)
|
|
38
|
+
|
|
39
|
+
Adapt this to {{{pluginName}}}'s actual entry points - add, remove or reword tasks so each one matches a real job a user comes here to do. This is a curated set of jobs, not a mechanical list of every file in this folder.
|
|
40
|
+
-->
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Query editor
|
|
3
|
+
description: "Build and run queries with the {{{yamlEscape pluginName}}} query editor."
|
|
4
|
+
keywords:
|
|
5
|
+
- "{{{yamlEscape pluginName}}}"
|
|
6
|
+
- data source
|
|
7
|
+
- query editor
|
|
8
|
+
- queries
|
|
9
|
+
sidebar_position: 3
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
This document explains how to use the {{{pluginName}}} query editor to build queries and visualize {{{pluginName}}} data in Grafana dashboards.
|
|
13
|
+
|
|
14
|
+
## Before you begin
|
|
15
|
+
|
|
16
|
+
- [Configure the {{{pluginName}}} data source](./configure.md).
|
|
17
|
+
|
|
18
|
+
<!-- section-brief
|
|
19
|
+
Fill this in: Keep the bullet above. Add a bullet for each other thing a reader needs before writing a query, such as read access to the data they query, a feature to enable on the target service or a query language to know. For access, link to the matching section of [configure](./configure.md). If there is nothing else, delete only this brief.
|
|
20
|
+
-->
|
|
21
|
+
|
|
22
|
+
## Editor modes
|
|
23
|
+
|
|
24
|
+
<!-- section-brief
|
|
25
|
+
Fill this in: An H3 for each mode the editor offers, such as a builder and a code editor, named as the editor names them. Say what each is for and when to use it, and how to switch between them. Add a screenshot of each mode when you can capture one, saved under `img/`. Never link an image that doesn't exist.
|
|
26
|
+
|
|
27
|
+
If the editor has one mode, remove this section entirely.
|
|
28
|
+
-->
|
|
29
|
+
|
|
30
|
+
## Query types
|
|
31
|
+
|
|
32
|
+
<!-- section-brief
|
|
33
|
+
Fill this in: Document the fields the editor shows, in tables with this shape:
|
|
34
|
+
|
|
35
|
+
| Field | Description |
|
|
36
|
+
| ----- | ----------- |
|
|
37
|
+
|
|
38
|
+
Use the field labels from the editor, in bold, and say which fields are required and their defaults and limits. If the editor has several query types or APIs, put the fields every type shares in a table first, then an H3 for each type that says when to use it and lists its own fields. Mention any shortcut that runs the query, such as **Shift+Enter**. Take the fields from the query editor component and the query type in source.
|
|
39
|
+
|
|
40
|
+
If the editor has one query type, skip the H3s, give one table of its fields and rename the heading to "Query fields".
|
|
41
|
+
-->
|
|
42
|
+
|
|
43
|
+
## Format the query results
|
|
44
|
+
|
|
45
|
+
<!-- section-brief
|
|
46
|
+
Fill this in: Describe each result format the editor can return, such as time series, table, logs or traces, and say when to use each. For each format, say what the query must return for Grafana to show it, such as a `time` column plus at least one numeric column, sorted by time, and the column order that produces several series. Take the formats from the query editor and the code that builds data frames in source.
|
|
47
|
+
|
|
48
|
+
If the editor has one result format, describe what the query must return in a paragraph without listing formats.
|
|
49
|
+
-->
|
|
50
|
+
{{#if hasBackend}}
|
|
51
|
+
|
|
52
|
+
## Macros
|
|
53
|
+
|
|
54
|
+
<!-- section-brief
|
|
55
|
+
Fill this in: A table of every macro the plugin expands in queries, such as `$__timeFilter`, with this shape:
|
|
56
|
+
|
|
57
|
+
| Macro | Description | Example |
|
|
58
|
+
| ----- | ----------- | ------- |
|
|
59
|
+
|
|
60
|
+
Macros are expanded in the backend, in the `QueryData` handler that implements `backend.QueryDataHandler`, or in code it calls. Take the macros from there, and show the syntax exactly as a reader writes it. Start with one example query that uses a macro. If a standard Grafana macro such as `$__timeGroup` doesn't work with this service, add a `> [!WARNING]` callout saying what to use instead.
|
|
61
|
+
|
|
62
|
+
If the plugin has no macros, remove this section entirely.
|
|
63
|
+
-->
|
|
64
|
+
{{/if}}
|
|
65
|
+
|
|
66
|
+
## Query examples
|
|
67
|
+
|
|
68
|
+
<!-- section-brief
|
|
69
|
+
Fill this in: Give realistic examples of the common query types from Query types, with an H3 for each type. If there is only one type, give examples for the jobs people use {{{pluginName}}} for instead. For each example, say what it does and show the query the way a reader enters it in the editor, using the field names and syntax the editor really accepts.
|
|
70
|
+
|
|
71
|
+
Follow each example with the query as dashboard JSON stores it, a `targets` entry in a `json` code block. Take the shape from the query model in source and from any dashboard JSON under `provisioning/dashboards/`, and replace real UIDs and credentials with placeholders.
|
|
72
|
+
-->
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Template variables
|
|
3
|
+
description: "Use template variables with {{{yamlEscape pluginName}}} to build dynamic, reusable dashboards."
|
|
4
|
+
keywords:
|
|
5
|
+
- "{{{yamlEscape pluginName}}}"
|
|
6
|
+
- data source
|
|
7
|
+
- template variables
|
|
8
|
+
sidebar_position: 4
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
Use template variables to create dynamic, reusable dashboards that let you change query parameters without editing individual panels. For general information about template variables, refer to [Templates and variables](https://grafana.com/docs/grafana/latest/dashboards/variables/).
|
|
12
|
+
|
|
13
|
+
<!-- section-brief
|
|
14
|
+
Fill this in: Delete only this brief.
|
|
15
|
+
|
|
16
|
+
If the plugin supports no variable types and interpolates no variables in its queries, delete this page and its link in `index.md`.
|
|
17
|
+
-->
|
|
18
|
+
|
|
19
|
+
## Before you begin
|
|
20
|
+
|
|
21
|
+
- [Configure the {{{pluginName}}} data source](./configure.md).
|
|
22
|
+
- Understand [Grafana template variables](https://grafana.com/docs/grafana/latest/dashboards/variables/).
|
|
23
|
+
- Know how to write queries in the [{{{pluginName}}} query editor](./query-editor.md).
|
|
24
|
+
|
|
25
|
+
## Supported variable types
|
|
26
|
+
|
|
27
|
+
The {{{pluginName}}} data source supports the following variable types:
|
|
28
|
+
|
|
29
|
+
<!-- section-brief
|
|
30
|
+
Fill this in: A table with a Yes or No for each variable type, in this order:
|
|
31
|
+
|
|
32
|
+
| Variable type | Supported |
|
|
33
|
+
| -------------- | --------- |
|
|
34
|
+
| Query | |
|
|
35
|
+
| Custom | Yes |
|
|
36
|
+
| Data source | Yes |
|
|
37
|
+
| Ad hoc filters | |
|
|
38
|
+
|
|
39
|
+
Custom and Data source variables are handled by Grafana itself and work with every data source, so keep them as Yes. Query is Yes if the data source class sets `variables` or implements `metricFindQuery`. Ad hoc filters is Yes if it implements both `getTagKeys` and `getTagValues`.
|
|
40
|
+
-->
|
|
41
|
+
|
|
42
|
+
## Use variables in queries
|
|
43
|
+
|
|
44
|
+
<!-- section-brief
|
|
45
|
+
Fill this in: Explain how to use a variable in the {{{pluginName}}} query editor, field by field, since fields accept variables in different ways. For each field that accepts one, say how the reader adds it: picked from a drop-down that lists dashboard variables, perhaps with a prefix such as `var:`, or typed into an input or code editor as `$variable` or `${variable}`. Note fields that don't accept variables, and any difference between editor modes, such as a builder and a code editor. Give an example, and say how a single value is substituted, such as whether a string needs quotes. Say which Grafana global variables, such as `$__interval` or `$__from`, work and in which fields.
|
|
46
|
+
|
|
47
|
+
Find which fields list variables in the query editor component, usually from `getTemplateSrv().getVariables()`, and which fields are interpolated in `applyTemplateVariables` or `interpolateVariablesInQueries`, or in the backend.
|
|
48
|
+
|
|
49
|
+
If the plugin doesn't interpolate variables in its queries, remove this section entirely.
|
|
50
|
+
-->
|
|
51
|
+
|
|
52
|
+
## Query variables
|
|
53
|
+
|
|
54
|
+
A query variable fills its drop-down by running a query against {{{pluginName}}}, so its options stay current with your data. Use one to let viewers pick a value, such as a host, a table or a project, and update every panel that uses it.
|
|
55
|
+
|
|
56
|
+
To create a query variable:
|
|
57
|
+
|
|
58
|
+
1. Navigate to **Dashboard settings** > **Variables**.
|
|
59
|
+
1. Click **Add variable**.
|
|
60
|
+
1. Select **Query** as the variable type.
|
|
61
|
+
1. Select the **{{{pluginName}}}** data source.
|
|
62
|
+
|
|
63
|
+
<!-- section-brief
|
|
64
|
+
Fill this in: Continue the list above with the steps for the variable query editor, using its field labels in bold. Say whether it's the same editor as the query editor or a separate one, from the variable support in source.
|
|
65
|
+
|
|
66
|
+
If the variable query editor has several query types, such as projects or environments, add an H3 for each that says what it lists, its fields and which part of each result becomes the display text and which the value. Otherwise, explain how the query result becomes the options: which column becomes the display text and which the value, and whether columns are matched by name, such as `text` and `value`, or by position, with one example for a single column and one for separate text and value. Take this from `metricFindQuery` or the variable support class in source.
|
|
67
|
+
|
|
68
|
+
If the plugin doesn't support query variables, remove this whole section, including its heading and the text above.
|
|
69
|
+
-->
|