Skip to content

Commit

Permalink
show datasource dropdown on cloud (#4382)
Browse files Browse the repository at this point in the history
# What this PR does

- show data source filter also on cloud
- use custom All option value to prevent invalid queries when there are
too many values

<!--
*Note*: if you have more than one GitHub issue that this PR closes, be
sure to preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
  • Loading branch information
brojd authored May 23, 2024
1 parent 375f6ba commit 7646060
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
3 changes: 3 additions & 0 deletions grafana-plugin/src/dashboards/oncall_metrics_dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,7 @@
"type": "query"
},
{
"allValue": ".+",
"current": {
"selected": true,
"text": ["All"],
Expand Down Expand Up @@ -1419,6 +1420,7 @@
"type": "query"
},
{
"allValue": ".+",
"current": {
"selected": true,
"text": ["All"],
Expand Down Expand Up @@ -1446,6 +1448,7 @@
"type": "query"
},
{
"allValue": ".+",
"current": {
"selected": true,
"text": ["All"],
Expand Down
20 changes: 8 additions & 12 deletions grafana-plugin/src/pages/insights/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { InsightsConfig } from './Insights.types';
const DEFAULT_VARIABLE_CONFIG: Partial<ConstructorParameters<typeof QueryVariable>[0]> = {
hide: 0,
includeAll: true,
allValue: `.+`,
isMulti: true,
options: [],
refresh: 1,
Expand All @@ -14,18 +15,13 @@ const DEFAULT_VARIABLE_CONFIG: Partial<ConstructorParameters<typeof QueryVariabl
type: 'query',
};

const getVariables = ({ isOpenSource, datasource, stack }: InsightsConfig) => ({
// Selectable
...(isOpenSource
? {
datasource: new DataSourceVariable({
name: 'datasource',
label: 'Data source',
pluginId: 'prometheus',
value: 'grafanacloud-usage',
}),
}
: {}),
const getVariables = ({ datasource, stack }: InsightsConfig) => ({
datasource: new DataSourceVariable({
name: 'datasource',
label: 'Data source',
pluginId: 'prometheus',
value: 'grafanacloud-usage',
}),
team: new QueryVariable({
...DEFAULT_VARIABLE_CONFIG,
name: 'team',
Expand Down

0 comments on commit 7646060

Please sign in to comment.