PublicDashboards: Refresh ds plugin supported list (#74947)

This commit is contained in:
Juan Cabanas 2023-09-21 16:24:08 -03:00 committed by GitHub
parent 158c669d1a
commit 633605af4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 111 additions and 33 deletions

View File

@ -164,10 +164,8 @@ guaranteed because plugin developers can override this functionality. The follow
<tr>
<td>
<ul>
<li>Altinity plugin for ClickHouse</li>
<li>ClickHouse</li>
<li>Elasticsearch</li>
<li>Graphite</li>
<li>Infinity</li>
<li>InfluxDB</li>
<li>Loki</li>
@ -178,7 +176,6 @@ guaranteed because plugin developers can override this functionality. The follow
<ul>
<li>MongoDB</li>
<li>MySQL</li>
<li>OpenTSDB</li>
<li>Oracle Database</li>
<li>PostgreSQL</li>
<li>Prometheus</li>
@ -189,18 +186,26 @@ guaranteed because plugin developers can override this functionality. The follow
</tr>
</table>
### Unconfirmed:
{{% admonition type="note" %}}
If you've confirmed one of these data sources work with public dashboards, let us know in our [Github](https://github.com/grafana/grafana/discussions/49253) discussion, and we'll mark it as confirmed!
{{% /admonition %}}
### Unsupported:
<table>
<tr>
<td>
<ul>
<li>CloudWatch</li>
<li>Graphite</li>
</ul>
</td>
</tr>
</table>
### Unconfirmed:
<table>
<tr>
<td>
<ul>
<li>Altinity plugin for ClickHouse</li>
<li>Amazon Athena</li>
<li>Amazon Redshift</li>
<li>Amazon Timestream</li>
@ -209,7 +214,6 @@ If you've confirmed one of these data sources work with public dashboards, let u
<li>Azure Data Explorer Datasource</li>
<li>Azure Monitor</li>
<li>CSV</li>
<li>CloudWatch</li>
<li>DB2 Datasource</li>
<li>Databricks</li>
<li>Datadog</li>
@ -231,12 +235,13 @@ If you've confirmed one of these data sources work with public dashboards, let u
<li>OPC UA (Unified Architecture)</li>
<li>Open Distro for Elasticsearch</li>
<li>OpenSearch</li>
<li>Orbit</li>
<li>SAP HANA®</li>
<li>OpenTSDB</li>
</ul>
</td>
<td>
<ul>
<li>Orbit</li>
<li>SAP HANA®</li>
<li>Salesforce</li>
<li>Sentry</li>
<li>ServiceNow</li>

View File

@ -12,6 +12,11 @@ import (
var grafanaDatasources = []string{expr.DatasourceType, "datasource"}
// there are some datasources that have backend flag as true but don't call /ds/query endpoint
var unsupportedDataSourcesMap = map[string]bool{
"cloudwatch": true,
}
type listPluginResponse struct {
Items []struct {
Slug string `json:"slug"`
@ -40,7 +45,7 @@ func GetCompatibleDatasources(baseUrl string) ([]string, error) {
// we only consider a datasource to be supported when alerting and backend are both true
var supported []string
for _, datasource := range datasources {
if datasource.Alerting && datasource.Backend {
if datasource.Alerting && datasource.Backend && !unsupportedDataSourcesMap[datasource.Slug] {
supported = append(supported, datasource.Slug)
}
}

View File

@ -30,11 +30,8 @@ import { NoUpsertPermissionsAlert } from '../ModalAlerts/NoUpsertPermissionsAler
import { SaveDashboardChangesAlert } from '../ModalAlerts/SaveDashboardChangesAlert';
import { UnsupportedDataSourcesAlert } from '../ModalAlerts/UnsupportedDataSourcesAlert';
import { UnsupportedTemplateVariablesAlert } from '../ModalAlerts/UnsupportedTemplateVariablesAlert';
import {
dashboardHasTemplateVariables,
generatePublicDashboardUrl,
getUnsupportedDashboardDatasources,
} from '../SharePublicDashboardUtils';
import { dashboardHasTemplateVariables, generatePublicDashboardUrl } from '../SharePublicDashboardUtils';
import { useGetUnsupportedDataSources } from '../useGetUnsupportedDataSources';
import { Configuration } from './Configuration';
import { EmailSharingConfiguration } from './EmailSharingConfiguration';
@ -60,7 +57,8 @@ const ConfigPublicDashboard = () => {
const dashboardState = useSelector((store) => store.dashboard);
const dashboard = dashboardState.getModel()!;
const dashboardVariables = dashboard.getVariables();
const unsupportedDataSources = getUnsupportedDashboardDatasources(dashboard.panels);
const { unsupportedDataSources } = useGetUnsupportedDataSources(dashboard);
const { data: publicDashboard, isFetching: isGetLoading } = useGetPublicDashboardQuery(dashboard.uid);
const [update, { isLoading: isUpdateLoading }] = useUpdatePublicDashboardMutation();

View File

@ -14,7 +14,8 @@ import { shareDashboardType } from '../../utils';
import { NoUpsertPermissionsAlert } from '../ModalAlerts/NoUpsertPermissionsAlert';
import { UnsupportedDataSourcesAlert } from '../ModalAlerts/UnsupportedDataSourcesAlert';
import { UnsupportedTemplateVariablesAlert } from '../ModalAlerts/UnsupportedTemplateVariablesAlert';
import { dashboardHasTemplateVariables, getUnsupportedDashboardDatasources } from '../SharePublicDashboardUtils';
import { dashboardHasTemplateVariables } from '../SharePublicDashboardUtils';
import { useGetUnsupportedDataSources } from '../useGetUnsupportedDataSources';
import { AcknowledgeCheckboxes } from './AcknowledgeCheckboxes';
@ -31,8 +32,8 @@ const CreatePublicDashboard = ({ isError }: { isError: boolean }) => {
const hasWritePermissions = contextSrv.hasPermission(AccessControlAction.DashboardsPublicWrite);
const dashboardState = useSelector((store) => store.dashboard);
const dashboard = dashboardState.getModel()!;
const unsupportedDataSources = getUnsupportedDashboardDatasources(dashboard.panels);
const { unsupportedDataSources } = useGetUnsupportedDataSources(dashboard);
const [createPublicDashboard, { isLoading: isSaveLoading }] = useCreatePublicDashboardMutation();
const disableInputs = !hasWritePermissions || isSaveLoading || isError;

View File

@ -23,7 +23,7 @@ export const UnsupportedDataSourcesAlert = ({ unsupportedDataSources }: { unsupp
sources may not function properly: {unsupportedDataSources}.
</p>
<a
href="https://grafana.com/docs/grafana/latest/dashboards/dashboard-public/"
href="https://grafana.com/docs/grafana/next/dashboards/dashboard-public/"
className={cx('text-link', styles.unsupportedDataSourceDescription)}
>
Read more about supported data sources

View File

@ -1,5 +1,7 @@
import { DataSourceRef, DataQuery } from '@grafana/data/src/types/query';
import { DataSourceWithBackend } from '@grafana/runtime';
import { updateConfig } from 'app/core/config';
import { mockDataSource } from 'app/features/alerting/unified/mocks';
import { PanelModel } from 'app/features/dashboard/state/PanelModel';
import { VariableModel } from 'app/features/variables/types';
@ -11,6 +13,29 @@ import {
getUnsupportedDashboardDatasources,
} from './SharePublicDashboardUtils';
const mockDS = mockDataSource({
name: 'mock-ds',
type: 'mock-ds-type',
});
jest.mock('@grafana/runtime/src/services/dataSourceSrv', () => {
return {
getDataSourceSrv: () => ({
get: () =>
Promise.resolve(
new DataSourceWithBackend({
...mockDS,
meta: {
...mockDS.meta,
alerting: true,
backend: true,
},
})
),
}),
};
});
describe('dashboardHasTemplateVariables', () => {
it('false', () => {
let variables: VariableModel[] = [];
@ -50,7 +75,7 @@ describe('publicDashboardPersisted', () => {
});
describe('getUnsupportedDashboardDatasources', () => {
it('itIsSupported', () => {
it('itIsSupported', async () => {
const pm = {
targets: [
{
@ -65,10 +90,11 @@ describe('getUnsupportedDashboardDatasources', () => {
] as DataQuery[],
} as PanelModel;
const panelArray: PanelModel[] = [pm];
expect(getUnsupportedDashboardDatasources(panelArray)).toEqual([]);
const unsupportedDataSources = await getUnsupportedDashboardDatasources(panelArray);
expect(unsupportedDataSources).toEqual([]);
});
it('itIsNotSupported', () => {
it('itIsNotSupported', async () => {
const pm = {
targets: [
{
@ -77,6 +103,8 @@ describe('getUnsupportedDashboardDatasources', () => {
] as DataQuery[],
} as PanelModel;
const panelArray: PanelModel[] = [pm];
expect(getUnsupportedDashboardDatasources(panelArray)).toEqual(['blah']);
const unsupportedDataSources = await getUnsupportedDashboardDatasources(panelArray);
expect(unsupportedDataSources).toEqual(['blah']);
});
});

View File

@ -1,4 +1,6 @@
import { DataSourceWithBackend } from '@grafana/runtime';
import { getConfig } from 'app/core/config';
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
import { VariableModel } from 'app/features/variables/types';
import { PanelModel } from '../../../state';
@ -50,14 +52,21 @@ export const publicDashboardPersisted = (publicDashboard?: PublicDashboard): boo
/**
* Get unique datasource names from all panels that are not currently supported by public dashboards.
*/
export const getUnsupportedDashboardDatasources = (panels: PanelModel[]): string[] => {
export const getUnsupportedDashboardDatasources = async (panels: PanelModel[]): Promise<string[]> => {
let unsupportedDS = new Set<string>();
for (const panel of panels) {
for (const target of panel.targets) {
let ds = target?.datasource?.type;
if (ds && !supportedDatasources.has(ds)) {
unsupportedDS.add(ds);
const dsType = target?.datasource?.type;
if (dsType) {
if (!supportedDatasources.has(dsType)) {
unsupportedDS.add(dsType);
} else {
const ds = await getDatasourceSrv().get(target.datasource);
if (!(ds instanceof DataSourceWithBackend)) {
unsupportedDS.add(dsType);
}
}
}
}
}

View File

@ -2,11 +2,13 @@
export const supportedDatasources = new Set<string>([
'__expr__',
'apache-iotdb-datasource',
'aquaqanalytics-kdbbackend-datasource',
'cloudwatch',
'axiomhq-axiom-datasource',
'cnos-cnosdb-datasource',
'datasource',
'dlopes7-appdynamics-datasource',
'doitintl-bigquery-datasource',
'dvelop-odata-datasource',
'elasticsearch',
'frser-sqlite-datasource',
'grafadruid-druid-datasource',
@ -20,11 +22,13 @@ export const supportedDatasources = new Set<string>([
'grafana-db2-datasource',
'grafana-dynatrace-datasource',
'grafana-es-open-distro-datasource',
'grafana-falconlogscale-datasource',
'grafana-github-datasource',
'grafana-gitlab-datasource',
'grafana-honeycomb-datasource',
'grafana-iot-sitewise-datasource',
'grafana-jira-datasource',
'grafana-looker-datasource',
'grafana-mock-datasource',
'grafana-mongodb-datasource',
'grafana-newrelic-datasource',
@ -46,6 +50,7 @@ export const supportedDatasources = new Set<string>([
'grafana-x-ray-datasource',
'graphite',
'hadesarchitect-cassandra-datasource',
'influxdata-flightsql-datasource',
'influxdb',
'innius-grpc-datasource',
'kniepdennis-neo4j-datasource',
@ -55,13 +60,19 @@ export const supportedDatasources = new Set<string>([
'mssql',
'mysql',
'nagasudhirpulla-api-datasource',
'needleinajaystack-haystack-datasource',
'opentsdb',
'postgres',
'prometheus',
'quickwit-quickwit-datasource',
'redis-datasource',
'sentinelone-dataset-datasource',
'sneller-sneller-datasource',
'spiceai-spicexyz-datasource',
'stackdriver',
'tdengine-datasource',
'vertamedia-clickhouse-datasource',
'vertica-grafana-datasource',
'ydbtech-ydb-datasource',
'yesoreyeram-infinity-datasource',
]);

View File

@ -0,0 +1,21 @@
import { useEffect, useState } from 'react';
import { DashboardModel } from 'app/features/dashboard/state';
import { getUnsupportedDashboardDatasources } from './SharePublicDashboardUtils';
export const useGetUnsupportedDataSources = (dashboard: DashboardModel) => {
const [unsupportedDataSources, setUnsupportedDataSources] = useState<string[]>([]);
useEffect(() => {
const fetchUnsupportedDataSources = async () => {
return await getUnsupportedDashboardDatasources(dashboard.panels);
};
fetchUnsupportedDataSources().then((dsList) => {
setUnsupportedDataSources(dsList);
});
}, [dashboard.panels]);
return { unsupportedDataSources };
};