Skip to content

Commit d10c206

Browse files
Docs: Externally shared dashboard datasource plugin support (#1496)
Co-authored-by: David Harris <[email protected]>
1 parent 3060e7d commit d10c206

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
id: add-support-for-externally-shared-dashboards
3+
title: Add support for externally shared dashboards
4+
description: How to add support for externally share dashboards (previously called Public dashboards).
5+
keywords:
6+
- grafana
7+
- plugins
8+
- plugin
9+
- externally shared dashboards
10+
- public dashboards
11+
- data source
12+
- datasource
13+
---
14+
15+
[Externally shared dashboards](https://grafana.com/docs/grafana/latest/dashboards/share-dashboards-panels/shared-dashboards/#externally-shared-dashboards) (previously called Public dashboards) allow Grafana users to share access to their dashboards with anyone, without needing to add them to their Grafana organization as a user. When a dashboard is accessed in this way, it retrieves the query from the backend, instead of receiving it from the frontend. This is to avoid exposing sensitive data and performing unauthorized queries.
16+
17+
Because of this, it's necessary to not pass any frontend-transformed body to the request, as it won't be used in the externally shared dashboard panel request.
18+
19+
:::note
20+
21+
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).
24+
25+
:::
26+
27+
## Support externally shared dashboards in your data source plugin
28+
29+
To make your data source plugin work in an externally shared dashboard scope, follow these steps:
30+
31+
1. Extend your DataSource class from `DataSourceWithBackend`
32+
33+
```ts
34+
export class MyDataSourceClass extends DataSourceWithBackend<TQuery, TOptions> {
35+
// your logic
36+
}
37+
```
38+
39+
2. Implement the `query` method with your customized code, if necessary. Don't transform the request body if this will change the backend query response (targets property). This body won't be passed as argument when calling the shared externally dashboard endpoint.
40+
41+
Then, call `super.query(request)`.
42+
This is where the externally shared dashboard endpoint is called.
43+
44+
```ts
45+
export class MyDataSourceClass extends DataSourceWithBackend<TQuery, TOptions> {
46+
47+
query(request: DataQueryRequest<TQuery>): Observable<DataQueryResponse> {
48+
// your logic
49+
return super.query(request).pipe(
50+
map((response) => {
51+
// your logic
52+
})
53+
);
54+
}
55+
}
56+
57+
3. Add `"backend": true` to your `plugin.json`
58+
59+
```json title="src/plugin.json"
60+
"backend": true
61+
```

docusaurus/docs/how-to-guides/data-source-plugins/convert-a-frontend-datasource-to-backend.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ To convert the frontend data source, we recommend scaffolding a new backend data
1717

1818
## Why
1919

20-
There are multiple features available only in backend plugins, such as Grafana Alerting or Recorded queries. See the use cases for implementing a backend plugin in the [backend plugins introduction](../../key-concepts/backend-plugins/#use-cases-for-implementing-a-backend-plugin).
20+
There are multiple features available only in backend plugins, such as Grafana Alerting, Recorded queries, or externally shared dashboards (previously called Public dashboards). Refer to the use cases for implementing a backend plugin in the [backend plugins introduction](../../key-concepts/backend-plugins/#use-cases-for-implementing-a-backend-plugin).
2121

2222
## Before you begin
2323

0 commit comments

Comments
 (0)