diff --git a/CHANGELOG.md b/CHANGELOG.md index afde0874f87..a3c0ce494f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,18 +14,24 @@ * **Cloudwatch**: Show all available CloudWatch regions [#12308](https://github.com/grafana/grafana/issues/12308), thx [@mtanda](https://github.com/mtanda) * **Cloudwatch**: AWS/Connect metrics and dimensions [#13970](https://github.com/grafana/grafana/pull/13970), thx [@zcoffy](https://github.com/zcoffy) * **Postgres**: Add delta window function to postgres query builder [#13925](https://github.com/grafana/grafana/issues/13925), thx [svenklemm](https://github.com/svenklemm) -* **Units**: New clock time format, to format ms or second values as for example `01h:59m`, [#13635](https://github.com/grafana/grafana/issues/13635), thx [@franciscocpg](https://github.com/franciscocpg) -* **Datasource Proxy**: Keep trailing slash for datasource proxy requests [#13326](https://github.com/grafana/grafana/pull/13326), thx [@ryantxu](https://github.com/ryantxu) -* **DingDing**: Can't receive DingDing alert when alert is triggered [#13723](https://github.com/grafana/grafana/issues/13723), thx [@Yukinoshita-Yukino](https://github.com/Yukinoshita-Yukino) -* **Internal metrics**: Renamed `grafana_info` to `grafana_build_info` and added branch, goversion and revision [#13876](https://github.com/grafana/grafana/pull/13876) -* **Alerting**: Increaste default duration for queries [#13945](https://github.com/grafana/grafana/pull/13945) +* **Elasticsearch**: Fix switching to/from es raw document metric query [#6367](https://github.com/grafana/grafana/issues/6367) +* **Elasticsearch**: Fix deprecation warning about terms aggregation order key in Elasticsearch 6.x [#11977](https://github.com/grafana/grafana/issues/11977) * **Table**: Fix CSS alpha background-color applied twice in table cell with link [#13606](https://github.com/grafana/grafana/issues/13606), thx [@grisme](https://github.com/grisme) +* **Units**: New clock time format, to format ms or second values as for example `01h:59m`, [#13635](https://github.com/grafana/grafana/issues/13635), thx [@franciscocpg](https://github.com/franciscocpg) +* **Alerting**: Increaste default duration for queries [#13945](https://github.com/grafana/grafana/pull/13945) * **Alerting**: More options for the Slack Alert notifier [#13993](https://github.com/grafana/grafana/issues/13993), thx [@andreykaipov](https://github.com/andreykaipov) +* **Alerting**: Can't receive DingDing alert when alert is triggered [#13723](https://github.com/grafana/grafana/issues/13723), thx [@Yukinoshita-Yukino](https://github.com/Yukinoshita-Yukino) +* **Internal metrics**: Renamed `grafana_info` to `grafana_build_info` and added branch, goversion and revision [#13876](https://github.com/grafana/grafana/pull/13876) +* **Datasource Proxy**: Keep trailing slash for datasource proxy requests [#13326](https://github.com/grafana/grafana/pull/13326), thx [@ryantxu](https://github.com/ryantxu) ### Breaking changes * Postgres/MySQL/MSSQL datasources now per default uses `max open connections` = `unlimited` (earlier 10), `max idle connections` = `2` (earlier 10) and `connection max lifetime` = `4` hours (earlier unlimited) +# 5.3.5 (unreleased) + +* **Security**: Upgrade macaron session package to fix security issue. [#14043](https://github.com/grafana/grafana/pull/14043) + # 5.3.4 (2018-11-13) * **Alerting**: Delete alerts when parent folder was deleted [#13322](https://github.com/grafana/grafana/issues/13322) diff --git a/public/app/features/explore/Explore.tsx b/public/app/features/explore/Explore.tsx index 753f158fd9f..238c5c917b9 100644 --- a/public/app/features/explore/Explore.tsx +++ b/public/app/features/explore/Explore.tsx @@ -94,6 +94,10 @@ export class Explore extends React.PureComponent { * Not kept in component state to prevent edit-render roundtrips. */ queryExpressions: string[]; + /** + * Local ID cache to compare requested vs selected datasource + */ + requestedDatasourceId: string; constructor(props) { super(props); @@ -167,6 +171,9 @@ export class Explore extends React.PureComponent { const datasourceId = datasource.meta.id; let datasourceError = null; + // Keep ID to track selection + this.requestedDatasourceId = datasourceId; + try { const testResult = await datasource.testDatasource(); datasourceError = testResult.status === 'success' ? null : testResult.message; @@ -174,6 +181,11 @@ export class Explore extends React.PureComponent { datasourceError = (error && error.statusText) || 'Network error'; } + if (datasourceId !== this.requestedDatasourceId) { + // User already changed datasource again, discard results + return; + } + const historyKey = `grafana.explore.history.${datasourceId}`; const history = store.getObject(historyKey, []); diff --git a/public/app/plugins/datasource/elasticsearch/config_ctrl.ts b/public/app/plugins/datasource/elasticsearch/config_ctrl.ts index 154ff9bcb91..fad3a6895ae 100644 --- a/public/app/plugins/datasource/elasticsearch/config_ctrl.ts +++ b/public/app/plugins/datasource/elasticsearch/config_ctrl.ts @@ -28,9 +28,13 @@ export class ElasticConfigCtrl { ]; indexPatternTypeChanged() { - const def = _.find(this.indexPatternTypes, { - value: this.current.jsonData.interval, - }); - this.current.database = def.example || 'es-index-name'; + if (!this.current.database || + this.current.database.length === 0 || + this.current.database.startsWith('[logstash-]')) { + const def = _.find(this.indexPatternTypes, { + value: this.current.jsonData.interval, + }); + this.current.database = def.example || 'es-index-name'; + } } } diff --git a/public/app/plugins/datasource/elasticsearch/metric_agg.ts b/public/app/plugins/datasource/elasticsearch/metric_agg.ts index 1dd0d892360..56f874d90b9 100644 --- a/public/app/plugins/datasource/elasticsearch/metric_agg.ts +++ b/public/app/plugins/datasource/elasticsearch/metric_agg.ts @@ -160,6 +160,12 @@ export class ElasticMetricAggCtrl { $scope.agg.settings = {}; $scope.agg.meta = {}; $scope.showOptions = false; + + // reset back to metric/group by query + if ($scope.target.bucketAggs.length === 0 && $scope.agg.type !== 'raw_document') { + $scope.target.bucketAggs = [queryDef.defaultBucketAgg()]; + } + $scope.updatePipelineAggOptions(); $scope.onChange(); }; diff --git a/public/app/plugins/datasource/elasticsearch/query_builder.ts b/public/app/plugins/datasource/elasticsearch/query_builder.ts index 21af0ba9b80..efdeee68370 100644 --- a/public/app/plugins/datasource/elasticsearch/query_builder.ts +++ b/public/app/plugins/datasource/elasticsearch/query_builder.ts @@ -181,8 +181,8 @@ export class ElasticQueryBuilder { build(target, adhocFilters?, queryString?) { // make sure query has defaults; - target.metrics = target.metrics || [{ type: 'count', id: '1' }]; - target.bucketAggs = target.bucketAggs || [{ type: 'date_histogram', id: '2', settings: { interval: 'auto' } }]; + target.metrics = target.metrics || [queryDef.defaultMetricAgg()]; + target.bucketAggs = target.bucketAggs || [queryDef.defaultBucketAgg()]; target.timeField = this.timeField; let i, nestedAggs, metric; diff --git a/public/app/plugins/datasource/elasticsearch/query_ctrl.ts b/public/app/plugins/datasource/elasticsearch/query_ctrl.ts index 422d35dd277..81dbd5b8f8a 100644 --- a/public/app/plugins/datasource/elasticsearch/query_ctrl.ts +++ b/public/app/plugins/datasource/elasticsearch/query_ctrl.ts @@ -17,6 +17,19 @@ export class ElasticQueryCtrl extends QueryCtrl { super($scope, $injector); this.esVersion = this.datasource.esVersion; + + this.target = this.target || {}; + this.target.metrics = this.target.metrics || [queryDef.defaultMetricAgg()]; + this.target.bucketAggs = this.target.bucketAggs || [queryDef.defaultBucketAgg()]; + + if (this.target.bucketAggs.length === 0) { + const metric = this.target.metrics[0]; + if (!metric || metric.type !== 'raw_document') { + this.target.bucketAggs = [queryDef.defaultBucketAgg()]; + } + this.refresh(); + } + this.queryUpdated(); } diff --git a/public/app/plugins/datasource/elasticsearch/query_def.ts b/public/app/plugins/datasource/elasticsearch/query_def.ts index dd65a8b373e..3ea5945f54d 100644 --- a/public/app/plugins/datasource/elasticsearch/query_def.ts +++ b/public/app/plugins/datasource/elasticsearch/query_def.ts @@ -228,3 +228,11 @@ export function describeOrderBy(orderBy, target) { return 'metric not found'; } } + +export function defaultMetricAgg() { + return { type: 'count', id: '1' }; +} + +export function defaultBucketAgg() { + return { type: 'date_histogram', id: '2', settings: { interval: 'auto' } }; +} diff --git a/public/sass/pages/_explore.scss b/public/sass/pages/_explore.scss index 4b07b04e330..58b4ca17840 100644 --- a/public/sass/pages/_explore.scss +++ b/public/sass/pages/_explore.scss @@ -320,8 +320,11 @@ .ReactTable { border: none; +} + +.ReactTable .rt-table { // Allow some space for the no-data text - min-height: 120px; + min-height: 90px; } .ReactTable .rt-thead.-header { @@ -350,6 +353,11 @@ .ReactTable .rt-tbody .rt-td:last-child { border-right: none; } +.ReactTable .-pagination { + border-top: none; + box-shadow: none; + margin-top: $panel-margin; +} .ReactTable .-pagination .-btn { color: $blue; background: $list-item-bg; @@ -371,6 +379,10 @@ .ReactTable .rt-tr .rt-td:last-child { text-align: right; } +.ReactTable .rt-noData { + top: 60px; + z-index: inherit; +} // React-component cascade fix: show "loading" even though item can expand