diff --git a/docs/sources/datasources/_index.md b/docs/sources/datasources/_index.md index c85f69d6021..75fedbcf086 100644 --- a/docs/sources/datasources/_index.md +++ b/docs/sources/datasources/_index.md @@ -54,9 +54,21 @@ For example, this video demonstrates the visual Prometheus query builder: For general information about querying in Grafana, and common options and user interface elements across all query editors, refer to [Query and transform data]({{< relref "../panels-visualizations/query-transform-data/" >}}). +## Special data sources + +Grafana includes three special data sources: + +- **Grafana:** A built-in data source that generates random walk data and can poll the [Testdata]({{< relref "./testdata/" >}}) data source. Additionally, it can list files and get other data from a Grafana installation. This can be helpful for testing visualizations and running experiments. +- **Mixed:** An abstraction that lets you query multiple data sources in the same panel. + When you select Mixed, you can then select a different data source for each new query that you add. + - The first query uses the data source that was selected before you selected **Mixed**. + - You can't change an existing query to use the **Mixed** data source. + - Grafana Play example: [Mixed data sources](https://play.grafana.org/d/000000100/mixed-datasources?orgId=1) +- **Dashboard:** A data source that uses the result set from another panel in the same dashboard. The dashboard data source can use data either directly from the selected panel or from annotations attached to the selected panel. + ## Built-in core data sources -These built-in core data sources are included in the Grafana documentation: +These built-in core data sources are also included in the Grafana documentation: - [Alertmanager]({{< relref "./alertmanager/" >}}) - [AWS CloudWatch]({{< relref "./aws-cloudwatch/" >}}) @@ -75,16 +87,3 @@ These built-in core data sources are included in the Grafana documentation: - [Tempo]({{< relref "./tempo/" >}}) - [Testdata]({{< relref "./testdata/" >}}) - [Zipkin]({{< relref "./zipkin/" >}}) - -## Special data sources - -Grafana also includes three special data sources: - -- **Grafana:** A built-in data source that generates random walk data and can poll the [Testdata]({{< relref "./testdata/" >}}) data source. - This helps you test visualizations and run experiments. -- **Mixed:** An abstraction that lets you query multiple data sources in the same panel. - When you select Mixed, you can then select a different data source for each new query that you add. - - The first query uses the data source that was selected before you selected **Mixed**. - - You can't change an existing query to use the Mixed data source. - - Grafana Play example: [Mixed data sources](https://play.grafana.org/d/000000100/mixed-datasources?orgId=1) -- **Dashboard:** A data source that uses the result set from another panel in the same dashboard. diff --git a/public/app/plugins/datasource/dashboard/DashboardQueryEditor.tsx b/public/app/plugins/datasource/dashboard/DashboardQueryEditor.tsx index 91d18d5e3bf..f585c791885 100644 --- a/public/app/plugins/datasource/dashboard/DashboardQueryEditor.tsx +++ b/public/app/plugins/datasource/dashboard/DashboardQueryEditor.tsx @@ -5,7 +5,17 @@ import React, { useCallback, useMemo } from 'react'; import { useAsync } from 'react-use'; import { DataQuery, GrafanaTheme2, PanelData, SelectableValue, DataTopic } from '@grafana/data'; -import { Field, Select, useStyles2, VerticalGroup, Spinner, Switch, RadioButtonGroup, Icon } from '@grafana/ui'; +import { + Card, + Field, + Select, + useStyles2, + VerticalGroup, + HorizontalGroup, + Spinner, + Switch, + RadioButtonGroup, +} from '@grafana/ui'; import config from 'app/core/config'; import { getDashboardSrv } from 'app/features/dashboard/services/DashboardSrv'; import { PanelModel } from 'app/features/dashboard/state'; @@ -52,6 +62,7 @@ export function DashboardQueryEditor({ panelData, queries, onChange, onRunQuerie return { refId: query.refId, query: fmt(query), + name: ds.name, img: ds.meta.info.logos.small, data: queryData.series, error: queryData.error, @@ -106,6 +117,7 @@ export function DashboardQueryEditor({ panelData, queries, onChange, onRunQuerie ); const dashboard = getDashboardSrv().getCurrent(); + const showTransforms = Boolean(query.withTransforms || panel?.transformations?.length); const panels: Array> = useMemo( () => dashboard?.panels @@ -141,9 +153,6 @@ export function DashboardQueryEditor({ panelData, queries, onChange, onRunQuerie } const selected = panels.find((panel) => panel.value === query.panelId); - // Same as current URL, but different panelId - const editURL = `d/${dashboard.uid}/${dashboard.title}?&editPanel=${query.panelId}`; - const showTransforms = Boolean(query.withTransforms || panel?.transformations?.length); return ( <> @@ -158,65 +167,54 @@ export function DashboardQueryEditor({ panelData, queries, onChange, onRunQuerie /> + + + + + + {showTransforms && ( + + + + )} + + {loadingResults ? ( ) : ( <> {results && Boolean(results.length) && ( - + {results.map((target, i) => ( -
-
- - {target.refId}: -
- -
+ + {target.refId} + + {target.name} + + {target.query} + ))}
)} )} - - {showTransforms && ( - - - - )} - - - - ); } function getStyles(theme: GrafanaTheme2) { return { - results: css({ - padding: theme.spacing(2), + horizontalField: css({ + marginRight: theme.spacing(2), }), noQueriesText: css({ padding: theme.spacing(1.25), }), - refId: css({ - padding: theme.spacing(1.25), - }), - queryEditorRowHeader: css` - label: queryEditorRowHeader; - display: flex; - padding: 4px 8px; - flex-flow: row wrap; - background: ${theme.colors.background.secondary}; - align-items: center; - `, }; } diff --git a/public/app/plugins/datasource/dashboard/types.ts b/public/app/plugins/datasource/dashboard/types.ts index 8f107c2629e..983c79260fc 100644 --- a/public/app/plugins/datasource/dashboard/types.ts +++ b/public/app/plugins/datasource/dashboard/types.ts @@ -10,6 +10,7 @@ export interface DashboardQuery extends DataQuery { export type ResultInfo = { img: string; // The Datasource + name: string; refId: string; query: string; // As text data: DataFrame[];