diff --git a/public/app/plugins/datasource/prometheus/components/PromCheatSheet.tsx b/public/app/plugins/datasource/prometheus/components/PromCheatSheet.tsx
index e1c8c56bf13..a38f0540d30 100644
--- a/public/app/plugins/datasource/prometheus/components/PromCheatSheet.tsx
+++ b/public/app/plugins/datasource/prometheus/components/PromCheatSheet.tsx
@@ -18,20 +18,27 @@ const CHEAT_SHEET_ITEMS = [
expression: 'sort_desc(sum(sum_over_time(ALERTS{alertstate="firing"}[24h])) by (alertname))',
label: 'Sums up the alerts that have been firing over the last 24 hours.',
},
+ {
+ title: 'Step',
+ label:
+ 'Defines the graph resolution using a duration format (15s, 1m, 3h, ...). Small steps create high-resolution graphs but can be slow over larger time ranges. Using a longer step lowers the resolution and smooths the graph by producing fewer datapoints. If no step is given the resolution is calculated automatically.',
+ },
];
export default (props: ExploreStartPageProps) => (
PromQL Cheat Sheet
- {CHEAT_SHEET_ITEMS.map(item => (
-
+ {CHEAT_SHEET_ITEMS.map((item, index) => (
+
{item.title}
-
props.onClickExample({ refId: 'A', expr: item.expression } as DataQuery)}
- >
- {item.expression}
-
+ {item.expression ? (
+
props.onClickExample({ refId: 'A', expr: item.expression } as DataQuery)}
+ >
+ {item.expression}
+
+ ) : null}
{item.label}
))}
diff --git a/public/app/plugins/datasource/prometheus/components/PromExploreQueryEditor.tsx b/public/app/plugins/datasource/prometheus/components/PromExploreQueryEditor.tsx
new file mode 100644
index 00000000000..1518801248c
--- /dev/null
+++ b/public/app/plugins/datasource/prometheus/components/PromExploreQueryEditor.tsx
@@ -0,0 +1,85 @@
+import React, { PureComponent } from 'react';
+
+// Types
+import { ExploreQueryFieldProps } from '@grafana/data';
+import { FormLabel } from '@grafana/ui';
+
+import { PrometheusDatasource } from '../datasource';
+import { PromQuery, PromOptions } from '../types';
+
+import PromQueryField from './PromQueryField';
+export type Props = ExploreQueryFieldProps
;
+
+interface State {
+ interval: string;
+}
+
+export class PromExploreQueryEditor extends PureComponent {
+ // Query target to be modified and used for queries
+ query: PromQuery;
+
+ constructor(props: Props) {
+ super(props);
+ const { query } = props;
+ this.query = query;
+ // Query target properties that are fully controlled inputs
+ this.state = {
+ // Fully controlled text inputs
+ interval: query.interval,
+ };
+ }
+
+ onFieldChange = (query: PromQuery, override?: any) => {
+ this.query.expr = query.expr;
+ };
+
+ onIntervalChange = (e: React.SyntheticEvent) => {
+ const interval = e.currentTarget.value;
+ this.query.interval = interval;
+ this.setState({ interval });
+ };
+
+ onRunQuery = () => {
+ const { query } = this;
+ this.props.onChange(query);
+ this.props.onRunQuery();
+ };
+
+ onReturnKeyDown = (e: React.KeyboardEvent) => {
+ if (e.key === 'Enter') {
+ this.onRunQuery();
+ }
+ };
+
+ render() {
+ const { datasource, query, data, history } = this.props;
+ const { interval } = this.state;
+
+ return (
+
+ );
+ }
+}
diff --git a/public/app/plugins/datasource/prometheus/components/PromQueryField.tsx b/public/app/plugins/datasource/prometheus/components/PromQueryField.tsx
index b27dd7bc358..6ba778bbbfa 100644
--- a/public/app/plugins/datasource/prometheus/components/PromQueryField.tsx
+++ b/public/app/plugins/datasource/prometheus/components/PromQueryField.tsx
@@ -291,7 +291,7 @@ class PromQueryField extends React.PureComponent
-
+
- {showError ?
{data.error.message}
: null}
+ {showError ? (
+
+ ) : null}
{hint ? (
-
- {hint.label}{' '}
- {hint.fix ? (
-
- {hint.fix.label}
-
- ) : null}
+
) : null}
>
diff --git a/public/app/plugins/datasource/prometheus/module.ts b/public/app/plugins/datasource/prometheus/module.ts
index 15d48493295..5d767e5a4ba 100644
--- a/public/app/plugins/datasource/prometheus/module.ts
+++ b/public/app/plugins/datasource/prometheus/module.ts
@@ -3,7 +3,7 @@ import { PrometheusDatasource } from './datasource';
import { PromQueryEditor } from './components/PromQueryEditor';
import PromCheatSheet from './components/PromCheatSheet';
-import PromQueryField from './components/PromQueryField';
+import { PromExploreQueryEditor } from './components/PromExploreQueryEditor';
import { ConfigEditor } from './configuration/ConfigEditor';
@@ -14,6 +14,6 @@ class PrometheusAnnotationsQueryCtrl {
export const plugin = new DataSourcePlugin(PrometheusDatasource)
.setQueryEditor(PromQueryEditor)
.setConfigEditor(ConfigEditor)
- .setExploreMetricsQueryField(PromQueryField)
+ .setExploreMetricsQueryField(PromExploreQueryEditor)
.setAnnotationQueryCtrl(PrometheusAnnotationsQueryCtrl)
.setExploreStartPage(PromCheatSheet);
diff --git a/public/sass/pages/_explore.scss b/public/sass/pages/_explore.scss
index 36d7af6359a..8f833329e69 100644
--- a/public/sass/pages/_explore.scss
+++ b/public/sass/pages/_explore.scss
@@ -229,6 +229,10 @@
}
}
+.explore-input--ml {
+ margin-left: 4px;
+}
+
.navbar .elapsed-time {
position: absolute;
left: 0;
@@ -273,6 +277,11 @@
flex-grow: 1;
}
+.query-row-break {
+ height: 0;
+ flex-basis: 100%;
+}
+
.query-transactions {
display: table;
}