Skip to content

Commit b3c84cb

Browse files
Docs: More BE/FE sweep (#2076)
Co-authored-by: Andres Martinez Gotor <[email protected]>
1 parent 280d794 commit b3c84cb

24 files changed

+94
-95
lines changed

docusaurus/docs/get-started/get-started.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Grafana plugin development allows you to create many different types of user exp
4040

4141
:::tip
4242

43-
If this is your first time creating a plugin, we recommend that you familiarize yourself with the fundamentals of plugin types, frontend and backend plugin components, data frames, and other essentials. Learn more about the [key concepts of Grafana plugin development](/key-concepts/).
43+
If this is your first time creating a plugin, we recommend that you familiarize yourself with the fundamentals of plugin types, frontend and backend components, data frames, and other essentials. Learn more about the [key concepts of Grafana plugin development](/key-concepts/).
4444

4545
:::
4646

docusaurus/docs/how-to-guides/data-source-plugins/add-authentication-for-data-source-plugins.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ Grafana plugins can perform authenticated requests against a third-party API by
1717

1818
Configure your data source plugin to authenticate against a third-party API in one of either of two ways:
1919

20-
- Use the [_data source proxy_](#authenticate-using-the-data-source-proxy) method, or
21-
- Build a [_backend plugin_](#authenticate-using-a-backend-plugin).
20+
- Use the [data source proxy](#authenticate-using-the-data-source-proxy) method, or
21+
- Build a [plugin backend component](#authenticate-using-a-plugin-backend).
2222

2323
| Case | Use |
2424
| ----------------------------------------------------------------------------------------------- | -------------------------- |
@@ -311,14 +311,14 @@ Be aware that `tokenAuth` configuration is only supported in data source plugins
311311

312312
:::
313313

314-
## Authenticate using a backend plugin
314+
## Authenticate using a plugin backend
315315

316316
While the data source proxy supports the most common authentication methods for HTTP APIs, using proxy routes has a few limitations:
317317

318318
- Proxy routes only support HTTP or HTTPS.
319319
- Proxy routes don't support custom token authentication.
320320

321-
If any of these limitations apply to your plugin, you need to add a [backend plugin](../../key-concepts/backend-plugins/#caching-and-connection-pooling). Because backend plugins run on the server, they can access decrypted secrets, which makes it easier to implement custom authentication methods.
321+
If any of these limitations apply to your plugin, you need to add a [backend component](../../key-concepts/backend-plugins/#caching-and-connection-pooling). Because plugin backend components run on the server, they can access decrypted secrets, which makes it easier to implement custom authentication methods.
322322

323323
The decrypted secrets are available from the `DecryptedSecureJSONData` field in the instance settings.
324324

docusaurus/docs/how-to-guides/data-source-plugins/add-features-for-explore-queries.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ keywords:
1111
- explore
1212
---
1313

14-
[Explore](https://grafana.com/docs/grafana/latest/explore/) allows users can make ad-hoc queries without the use of a dashboard. This is useful when they want to troubleshoot or learn more about the data.
14+
[Explore](https://grafana.com/docs/grafana/latest/explore/) allows you to make ad-hoc queries without having to use a dashboard. This is useful when you want to troubleshoot or learn more about the data. Your data source supports Explore by default and uses the existing query editor.
1515

16-
Your data source supports Explore by default and uses the existing query editor for the data source. This guide explains how to extend functionality for Explore queries in a data source plugin.
16+
This guide explains how to extend functionality for Explore queries in a data source plugin.
1717

1818
## Add an Explore-specific query editor
1919

20-
To extend Explore functionality for your data source, define an Explore-specific query editor.
20+
To extend the Explore functionality for your data source, define an Explore-specific query editor.
2121

2222
1. Create a file `ExploreQueryEditor.tsx` in the `src` directory of your plugin, with content similar to this:
2323

@@ -59,7 +59,7 @@ To extend Explore functionality for your data source, define an Explore-specific
5959

6060
## Select a preferred visualization type
6161

62-
By default, Explore should select an appropriate and useful visualization for your data. It can figure out whether the returned data is time series data or logs or something else, and creates the right type of visualization.
62+
By default, Explore identifies your returned data (time series, logs, or something else) and creates the right type of visualization.
6363

6464
However, if you want a custom visualization, you can add a hint to your returned data frame by setting the `meta` attribute to `preferredVisualisationType`.
6565

docusaurus/docs/how-to-guides/data-source-plugins/add-logs-metrics-traces-for-backend-plugins.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
id: add-logs-metrics-traces-for-backend-plugins
3-
title: Add logs, metrics, and traces for backend plugins
4-
description: How to add logs, metrics and traces for backend plugins.
3+
title: Add logs, metrics, and traces to plugin backends
4+
description: How to add logs, metrics and traces to plugin backend components.
55
keywords:
66
- grafana
77
- plugins
@@ -16,7 +16,7 @@ keywords:
1616
- back-end
1717
---
1818

19-
Adding [logs](#logs), [metrics](#metrics) and [traces](#traces) for backend plugins makes it easier to diagnose and resolve issues for both plugin developers and Grafana operators. This document provides guidance, conventions and best practices to help you effectively instrument your plugins, as well as how to access this data when the plugin is installed.
19+
Adding [logs](#logs), [metrics](#metrics) and [traces](#traces) to plugin backend components makes it easier to diagnose and resolve issues for both plugin developers and Grafana operators. This document provides guidance, conventions and best practices to help you effectively instrument your plugins, as well as how to access this data when the plugin is installed.
2020

2121
:::note
2222

@@ -255,9 +255,9 @@ Incoming requests of high frequency are normally more common for the `QueryData`
255255

256256
### Inspect logs locally
257257

258-
Logs from a backend plugin are consumed by the connected Grafana instance and included in the Grafana server log.
258+
Logs from a plugin's backend are consumed by the connected Grafana instance and included in the Grafana server log.
259259

260-
Each log message for a backend plugin will include a logger name, `logger=plugin.<plugin id>`. Example:
260+
Each log message from a plugin backend component includes a logger name `logger=plugin.<plugin id>`. For example:
261261

262262
```shell
263263
DEBUG[11-14|15:26:26] Debug msg logger=plugin.grafana-basic-datasource someID=1
@@ -379,13 +379,13 @@ If a value originating from user input are unbounded, that is when the value cou
379379

380380
### Collect and visualize metrics locally
381381

382-
Please refer to [Pull metrics from Grafana backend plugin into Prometheus](https://grafana.com/docs/grafana/latest/setup-grafana/set-up-grafana-monitoring/#pull-metrics-from-grafana-backend-plugin-into-prometheus).
382+
Please refer to [Pull metrics from a Grafana plugin backend into Prometheus](https://grafana.com/docs/grafana/latest/setup-grafana/set-up-grafana-monitoring/#pull-metrics-from-grafana-backend-plugin-into-prometheus).
383383

384384
Further, see [How to collect and visualize logs, metrics and traces](#collect-and-visualize-logs-metrics-and-traces).
385385

386386
## Traces
387387

388-
Distributed tracing allows backend plugin developers to create custom spans in their plugins, and then send them to the same endpoint and with the same propagation format as the main Grafana instance. The tracing context is also propagated from the Grafana instance to the plugin, so the plugin's spans will be correlated to the correct trace.
388+
Distributed tracing allows plugin backend developers to create custom spans in their plugins, and then send them to the same endpoint and with the same propagation format as the main Grafana instance. The tracing context is also propagated from the Grafana instance to the plugin, so the plugin's spans will be correlated to the correct trace.
389389

390390
### OpenTelemetry configuration in Grafana
391391

docusaurus/docs/how-to-guides/data-source-plugins/add-router.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
id: add-router
3-
title: Add a router or multiplexer to your plugin
4-
description: Add a router or multiplexer to your plugin.
3+
title: Add a router or multiplexer to query different data types
4+
description: Add a router or multiplexer to your plugin backend to query different data types.
55
keywords:
66
- grafana
77
- plugins
@@ -10,15 +10,15 @@ keywords:
1010
- multiplexer
1111
---
1212

13-
# Add a query router or multiplexer to your data source backend
13+
# Add a router or multiplexer to query different data types
1414

15-
Normally you implement the `QueryData` method in your plugin's backend for data queries. But what if you need to support different kinds of queries: metrics, logs, and traces, for instance? That’s where the usage of a query _router_ (also known as a _multiplexer_) comes handy.
15+
The `QueryData` method in your plugin's backend allows you to query one type of data only. To support different kinds of queries (metrics, logs, and traces) you need to implement query router (also known as a _multiplexer_).
1616

17-
The plugin development requirement is that you need to populate the `queryType` property of your query model client-side, see the [`DataQuery`](https://github.com/grafana/grafana/blob/a728e9b4ddb6532b9fa2f916df106e792229e3e0/packages/grafana-data/src/types/query.ts#L47) interface.
17+
To do so:
1818

19-
With `queryType` populated in queries and sent to your backend plugin below is an example of how you would use the [`datasource.QueryTypeMux`](https://pkg.go.dev/github.com/grafana/grafana-plugin-sdk-go/backend/datasource#QueryTypeMux) to multiplex or route different query types to separate query handlers.
20-
21-
Implemented in this way, each query handler can then `json.Unmarshal` each query JSON field in [`DataQuery`](https://pkg.go.dev/github.com/grafana/grafana-plugin-sdk-go/backend#DataQuery) to a certain Go struct as shown in this example:
19+
1. Populate the `queryType` property of your query model client-side, as shown in the [`DataQuery`](https://github.com/grafana/grafana/blob/a728e9b4ddb6532b9fa2f916df106e792229e3e0/packages/grafana-data/src/types/query.ts#L47) interface.
20+
1. With `queryType` populated in queries and sent to your plugin backend component, use [`datasource.QueryTypeMux`](https://pkg.go.dev/github.com/grafana/grafana-plugin-sdk-go/backend/datasource#QueryTypeMux) to multiplex or route different query types to separate query handlers.
21+
1. Each query handler can then `json.Unmarshal` each query JSON field in [`DataQuery`](https://pkg.go.dev/github.com/grafana/grafana-plugin-sdk-go/backend#DataQuery) to a certain Go struct as shown in this example:
2222

2323
```go
2424
package mydatasource
@@ -78,7 +78,7 @@ func (d *MyDatasource) handleQueryFallback(ctx context.Context, req *backend.Que
7878

7979
## Advanced usage
8080

81-
An example of using [`QueryTypeMux`](https://pkg.go.dev/github.com/grafana/grafana-plugin-sdk-go/backend/datasource#QueryTypeMux) can be found for Grafana's built-in TestData data source. Refer to this code for examples of implementation:
81+
You can find an example of using [`QueryTypeMux`](https://pkg.go.dev/github.com/grafana/grafana-plugin-sdk-go/backend/datasource#QueryTypeMux) in Grafana's built-in TestData data source code:
8282

83-
- [create query type multiplexer](https://github.com/grafana/grafana/blob/623ee3a2be5c4cd84c61b6bbe82a32d18cc29828/pkg/tsdb/grafana-testdata-datasource/testdata.go#L22) and [calls registerScenarios](https://github.com/grafana/grafana/blob/623ee3a2be5c4cd84c61b6bbe82a32d18cc29828/pkg/tsdb/grafana-testdata-datasource/testdata.go#L44)
84-
- [registerScenarios method](https://github.com/grafana/grafana/blob/623ee3a2be5c4cd84c61b6bbe82a32d18cc29828/pkg/tsdb/grafana-testdata-datasource/scenarios.go#L33) uses a [helper method](https://github.com/grafana/grafana/blob/623ee3a2be5c4cd84c61b6bbe82a32d18cc29828/pkg/tsdb/grafana-testdata-datasource/scenarios.go#L204-L207) to register each query type handler. The latter also shows how you can wrap the actual handler in another handler to apply common functionality or middleware to all handlers. For example, logging and traces.
83+
- [Create a query type multiplexer](https://github.com/grafana/grafana/blob/623ee3a2be5c4cd84c61b6bbe82a32d18cc29828/pkg/tsdb/grafana-testdata-datasource/testdata.go#L22) and [call `registerScenarios`](https://github.com/grafana/grafana/blob/623ee3a2be5c4cd84c61b6bbe82a32d18cc29828/pkg/tsdb/grafana-testdata-datasource/testdata.go#L44).
84+
- The [`registerScenarios` method](https://github.com/grafana/grafana/blob/623ee3a2be5c4cd84c61b6bbe82a32d18cc29828/pkg/tsdb/grafana-testdata-datasource/scenarios.go#L33) uses a [helper method](https://github.com/grafana/grafana/blob/623ee3a2be5c4cd84c61b6bbe82a32d18cc29828/pkg/tsdb/grafana-testdata-datasource/scenarios.go#L204-L207) to register each query type handler. The latter also shows how you can wrap the actual handler in another handler to apply common functionality or middleware to all handlers, for example logging and traces.

docusaurus/docs/how-to-guides/data-source-plugins/add-support-for-externally-shared-dashboards.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ Because of this, it's necessary to not pass any frontend-transformed body to the
1919
:::note
2020

2121
Frontend data sources are not compatible with externally shared dashboards.
22-
To convert a frontend data source plugin into a backend plugin, refer to
23-
[convert a frontend data source to backend](./convert-a-frontend-datasource-to-backend).
22+
To convert a data source plugin frontend component into a backend component, refer to
23+
[convert a data source frontend into a backend](./convert-a-frontend-datasource-to-backend).
2424

2525
:::
2626

docusaurus/docs/how-to-guides/data-source-plugins/profile-backend-plugin.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ keywords:
1313
- back-end
1414
---
1515

16-
This guide provides instructions for configuring a plugin with a backend to enable certain diagnostics when it starts, generating _profiling data_. Profiling data provides potentially useful information
17-
for investigating certain performance problems, such as high CPU or memory usage, or when you want to use [continuous profiling](https://grafana.com/oss/pyroscope/).
16+
This guide provides instructions for configuring a plugin with a backend to enable certain diagnostics when it starts, generating _profiling data_. Profiling data provides potentially useful information to investigate certain performance problems, such as high CPU or memory usage, or when you want to use [continuous profiling](https://grafana.com/oss/pyroscope/).
1817

1918
## Configure profiling data
2019

docusaurus/docs/key-concepts/anatomy-of-a-plugin.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This guide walks you through the essential components of a Grafana plugin, and h
2828

2929
## Before you begin
3030

31-
Before proceeding, we recommend reviewing the [plugin types and usage guide](/key-concepts/plugin-types-usage) to gain a basic understanding of the different types of plugins available.
31+
Before proceeding, review the [plugin types and usage guide](/key-concepts/plugin-types-usage) to gain a basic understanding of the different types of plugins available.
3232

3333
Each Grafana plugin is composed of several essential components that extend Grafana’s functionality in different ways. First, we’ll explore the core parts of each of the three primary plugin types: apps, data sources, and panels.
3434

@@ -169,7 +169,7 @@ The following files are crucial for your plugin's development and functionality:
169169
- **Frontend code** (`src/`): Required. This directory contains all the frontend code for your plugin. The main files to be aware of here are `plugin.json` and `module.ts`.
170170
- `plugin.json`: Stores [metadata about your plugin](/reference/plugin-json), including information like its description, supported Grafana versions, and dependencies.
171171
- `module.ts`: The entry point for your plugin's frontend logic.
172-
- **Backend code** (`pkg/`): Required if your plugin has a backend component. If your plugin includes backend functionality, the code will reside in this directory, typically within `pkg/plugin/`. Backend plugins are written in Go, and `main.go` serves as the entry point for your backend logic.
172+
- **Backend code** (`pkg/`): Required if your plugin has a backend component. If your plugin includes backend functionality, the code will reside in this directory, typically within `pkg/plugin/`. Plugin backend components are written in Go, and `main.go` serves as the entry point for your backend logic.
173173
- **Test files** (`tests/`): Optional, but strongly recommended to ensure plugin quality. This folder contains your plugin’s test files, typically suffixed with `.spec.ts` for frontend tests. You can [learn more about testing your plugin](/e2e-test-a-plugin/index.md) in our E2E testing guide.
174174
- **Other files**:
175175
- `docker-compose.yaml`: Required for Docker environment only. Contains the Docker configuration for running a local development instance of Grafana.

docusaurus/docs/key-concepts/backend-plugins/index.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,41 @@ Introduced in Grafana v7.0, plugins with backend components allow you to integra
1919
A plugin with a backend requires a frontend component as well. For example, all data source plugins need a query editor component on the frontend.
2020
:::
2121

22-
## Benefits for plugin backend development
22+
## Benefits of plugin backend development
2323

24-
This approach has the following benefits:
24+
Adding a backend component to your plugin has the following benefits:
2525

26-
- **Stability:** Plugins can't crash your Grafana process: a panic in a plugin doesn't panic the server.
27-
- **Ease of development:** Grafana provides an officially supported SDK for Go and tooling to help create plugins.
28-
- **Security:** Plugins only have access to the interfaces and arguments given to them, not to the entire memory space of the process.
26+
- **Stability**: Plugins can't crash your Grafana process. A panic in a plugin doesn't panic the server.
27+
- **Ease of development**: Grafana provides an officially supported SDK for Go and tooling to help create plugins.
28+
- **Security**: Plugins only have access to the interfaces and arguments given to them, not to the entire memory space of the process.
2929

3030
## When to implement a plugin with a backend
3131

32-
The following examples give some common use cases for plugins with a backend component:
32+
Here's some common use cases for plugins with a backend component:
3333

3434
- Support [Grafana Alerting](https://grafana.com/docs/grafana/latest/alerting/), [Recorded Queries](https://grafana.com/docs/grafana/latest/administration/recorded-queries/) and [Query and resource caching](https://grafana.com/docs/grafana/latest/administration/data-source-management/#query-and-resource-caching) for data sources.
3535
- Connect to SQL database servers and other non-HTTP services that normally can't be connected to from a browser.
3636
- Keep state between users, for example, by implementing custom caching for data sources.
3737
- Use custom authentication methods and/or authorization checks that aren't supported in Grafana.
3838
- Use a custom data source request proxy (refer to [Resources](#resources) for more information).
3939

40-
## Capabilities of the plugin backend system
40+
## Capabilities of the Grafana plugin backend system
4141

4242
Grafana's plugin backend system exposes several key capabilities, or building blocks, that your backend component can implement:
4343

44-
- Query data
45-
- Resources
46-
- Health checks
47-
- Collect metrics
48-
- Streaming
44+
- [Query data](#query-data)
45+
- [Resources](#resources)
46+
- [Health checks](#health-checks)
47+
- [Collect metrics](#collect-metrics)
48+
- [Streaming](#streaming)
4949

5050
### Query data
5151

5252
The query data capability allows a plugin's backend to handle data source queries that are submitted from a [dashboard](https://grafana.com/docs/grafana/latest/dashboards), [Explore](https://grafana.com/docs/grafana/latest/explore) or [Grafana Alerting](https://grafana.com/docs/grafana/latest/alerting). The response contains [data frames](../data-frames), which are used to visualize metrics, logs, and traces.
5353

5454
:::note
5555

56-
Backend data source plugins are required to implement the query data capability.
56+
To implement the query data capability you need a data source plugin backend.
5757

5858
:::
5959

0 commit comments

Comments
 (0)