From af56cc4c281476dc6e87e873e1710819dfa91e4e Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Wed, 19 Jul 2017 21:45:57 +0300 Subject: [PATCH 1/7] Panel Alertlist: use dashboard timezone (#8880) * panel-alertlist: use dashboard timezone, fixes #8874 * alert state history: use dashboard timezone, issue #8874 * alert state history: minor refactor --- public/app/features/alerting/alert_tab_ctrl.ts | 2 +- public/app/plugins/panel/alertlist/module.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/app/features/alerting/alert_tab_ctrl.ts b/public/app/features/alerting/alert_tab_ctrl.ts index 938b24ebc21..5d23ebfec3a 100644 --- a/public/app/features/alerting/alert_tab_ctrl.ts +++ b/public/app/features/alerting/alert_tab_ctrl.ts @@ -79,7 +79,7 @@ export class AlertTabCtrl { getAlertHistory() { this.backendSrv.get(`/api/annotations?dashboardId=${this.panelCtrl.dashboard.id}&panelId=${this.panel.id}&limit=50`).then(res => { this.alertHistory = _.map(res, ah => { - ah.time = moment(ah.time).format('MMM D, YYYY HH:mm:ss'); + ah.time = this.dashboardSrv.getCurrent().formatDate(ah.time, 'MMM D, YYYY HH:mm:ss'); ah.stateModel = alertDef.getStateDisplayModel(ah.newState); ah.info = alertDef.getAlertAnnotationInfo(ah); return ah; diff --git a/public/app/plugins/panel/alertlist/module.ts b/public/app/plugins/panel/alertlist/module.ts index c934902e7e1..17d06132751 100644 --- a/public/app/plugins/panel/alertlist/module.ts +++ b/public/app/plugins/panel/alertlist/module.ts @@ -104,7 +104,7 @@ class AlertListPanel extends PanelCtrl { this.backendSrv.get(`/api/annotations`, params) .then(res => { this.alertHistory = _.map(res, al => { - al.time = moment(al.time).format('MMM D, YYYY HH:mm:ss'); + al.time = this.dashboard.formatDate(al.time, 'MMM D, YYYY HH:mm:ss'); al.stateModel = alertDef.getStateDisplayModel(al.newState); al.info = alertDef.getAlertAnnotationInfo(al); return al; From 9d50ab8fb5606aa7d7e6845de150a37a64786255 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Thu, 20 Jul 2017 21:11:51 +0900 Subject: [PATCH 2/7] (cloudwatch) check auth type before assume role (#8895) --- pkg/api/cloudwatch/cloudwatch.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/api/cloudwatch/cloudwatch.go b/pkg/api/cloudwatch/cloudwatch.go index bd0d61ec272..bfafc8b912b 100644 --- a/pkg/api/cloudwatch/cloudwatch.go +++ b/pkg/api/cloudwatch/cloudwatch.go @@ -39,6 +39,7 @@ type cwRequest struct { type datasourceInfo struct { Profile string Region string + AuthType string AssumeRoleArn string Namespace string @@ -47,6 +48,7 @@ type datasourceInfo struct { } func (req *cwRequest) GetDatasourceInfo() *datasourceInfo { + authType := req.DataSource.JsonData.Get("authType").MustString() assumeRoleArn := req.DataSource.JsonData.Get("assumeRoleArn").MustString() accessKey := "" secretKey := "" @@ -61,6 +63,7 @@ func (req *cwRequest) GetDatasourceInfo() *datasourceInfo { } return &datasourceInfo{ + AuthType: authType, AssumeRoleArn: assumeRoleArn, Region: req.Region, Profile: req.DataSource.Database, @@ -110,7 +113,7 @@ func getCredentials(dsInfo *datasourceInfo) (*credentials.Credentials, error) { sessionToken := "" var expiration *time.Time expiration = nil - if strings.Index(dsInfo.AssumeRoleArn, "arn:aws:iam:") == 0 { + if dsInfo.AuthType == "arn" && strings.Index(dsInfo.AssumeRoleArn, "arn:aws:iam:") == 0 { params := &sts.AssumeRoleInput{ RoleArn: aws.String(dsInfo.AssumeRoleArn), RoleSessionName: aws.String("GrafanaSession"), From b16b649c9beacbae159f30e01d23e0c2836f3d45 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Thu, 20 Jul 2017 21:12:56 +0900 Subject: [PATCH 3/7] (cloudwatch) add new elb metrics (#8894) --- pkg/api/cloudwatch/metrics.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/api/cloudwatch/metrics.go b/pkg/api/cloudwatch/metrics.go index f8b93d361f5..2daa93bfb03 100644 --- a/pkg/api/cloudwatch/metrics.go +++ b/pkg/api/cloudwatch/metrics.go @@ -42,7 +42,7 @@ func init() { "AWS/EC2Spot": {"AvailableInstancePoolsCount", "BidsSubmittedForCapacity", "EligibleInstancePoolCount", "FulfilledCapacity", "MaxPercentCapacityAllocation", "PendingCapacity", "PercentCapacityAllocation", "TargetCapacity", "TerminatingCapacity"}, "AWS/ECS": {"CPUReservation", "MemoryReservation", "CPUUtilization", "MemoryUtilization"}, "AWS/EFS": {"BurstCreditBalance", "ClientConnections", "DataReadIOBytes", "DataWriteIOBytes", "MetadataIOBytes", "TotalIOBytes", "PermittedThroughput", "PercentIOLimit"}, - "AWS/ELB": {"HealthyHostCount", "UnHealthyHostCount", "RequestCount", "Latency", "HTTPCode_ELB_4XX", "HTTPCode_ELB_5XX", "HTTPCode_Backend_2XX", "HTTPCode_Backend_3XX", "HTTPCode_Backend_4XX", "HTTPCode_Backend_5XX", "BackendConnectionErrors", "SurgeQueueLength", "SpilloverCount"}, + "AWS/ELB": {"HealthyHostCount", "UnHealthyHostCount", "RequestCount", "Latency", "HTTPCode_ELB_4XX", "HTTPCode_ELB_5XX", "HTTPCode_Backend_2XX", "HTTPCode_Backend_3XX", "HTTPCode_Backend_4XX", "HTTPCode_Backend_5XX", "BackendConnectionErrors", "SurgeQueueLength", "SpilloverCount", "EstimatedALBActiveConnectionCount", "EstimatedALBConsumedLCUs", "EstimatedALBNewConnectionCount", "EstimatedProcessedBytes"}, "AWS/ElastiCache": { "CPUUtilization", "FreeableMemory", "NetworkBytesIn", "NetworkBytesOut", "SwapUsage", "BytesUsedForCacheItems", "BytesReadIntoMemcached", "BytesWrittenOutFromMemcached", "CasBadval", "CasHits", "CasMisses", "CmdFlush", "CmdGet", "CmdSet", "CurrConnections", "CurrItems", "DecrHits", "DecrMisses", "DeleteHits", "DeleteMisses", "Evictions", "GetHits", "GetMisses", "IncrHits", "IncrMisses", "Reclaimed", From bbfdfc012f7fe30297e2dc2eb09549efca736f1a Mon Sep 17 00:00:00 2001 From: Kakuya Ando Date: Fri, 21 Jul 2017 16:51:25 +0900 Subject: [PATCH 4/7] fix(prometheus) when tag value duplicate, tags not working. (#8040) --- .../plugins/datasource/prometheus/metric_find_query.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/datasource/prometheus/metric_find_query.js b/public/app/plugins/datasource/prometheus/metric_find_query.js index 04149881d40..a33044fddf6 100644 --- a/public/app/plugins/datasource/prometheus/metric_find_query.js +++ b/public/app/plugins/datasource/prometheus/metric_find_query.js @@ -59,9 +59,13 @@ function (_) { return this.datasource._request('GET', url) .then(function(result) { - return _.map(result.data.data, function(metric) { + var _labels = _.map(result.data.data, function(metric) { + return metric[label]; + }); + + return _.uniq(_labels).map(function(metric) { return { - text: metric[label], + text: metric, expandable: true }; }); From 1a25b78ef29c5e097eadb12a77f8c072a054bccf Mon Sep 17 00:00:00 2001 From: Nicholas Nadeau Date: Fri, 21 Jul 2017 15:46:54 -0400 Subject: [PATCH 5/7] homogenized `docker run` command (#8907) There are three locations where the `docker run` command is referenced: - 2x http://docs.grafana.org/installation/docker/ - 1x https://grafana.com/grafana/download?platform=docker The fix syncs the given `docker run` command arguments with the other two. --- docs/sources/installation/docker.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sources/installation/docker.md b/docs/sources/installation/docker.md index 85349dc58fb..03e6979d72b 100644 --- a/docs/sources/installation/docker.md +++ b/docs/sources/installation/docker.md @@ -14,7 +14,7 @@ weight = 4 Grafana is very easy to install and run using the offical docker container. - $ docker run -i -p 3000:3000 grafana/grafana + $ docker run -d -p 3000:3000 grafana/grafana All Grafana configuration settings can be defined using environment variables, this is especially useful when using the above container. From 4a678c288461ec1264d001b4e35ae453a023bbc4 Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Sat, 22 Jul 2017 01:31:26 +0200 Subject: [PATCH 6/7] influxdb: fix for adding math query part Fixes #8870. Fixes out of bound exception on adding a math query part when there is no group by interval (or only one query part). --- public/app/plugins/datasource/influxdb/query_part.ts | 2 +- .../datasource/influxdb/specs/influx_query_specs.ts | 11 +++++++++++ .../datasource/influxdb/specs/query_part_specs.ts | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/public/app/plugins/datasource/influxdb/query_part.ts b/public/app/plugins/datasource/influxdb/query_part.ts index 683b3bddd55..0e63e3c7e24 100644 --- a/public/app/plugins/datasource/influxdb/query_part.ts +++ b/public/app/plugins/datasource/influxdb/query_part.ts @@ -87,7 +87,7 @@ function addMathStrategy(selectParts, partModel) { return; } // if next to last is math, replace it - if (selectParts[partCount-2].def.type === 'math') { + if (partCount > 1 && selectParts[partCount-2].def.type === 'math') { selectParts[partCount-2] = partModel; return; } else if (selectParts[partCount-1].def.type === 'alias') { // if last is alias add it before diff --git a/public/app/plugins/datasource/influxdb/specs/influx_query_specs.ts b/public/app/plugins/datasource/influxdb/specs/influx_query_specs.ts index 96d37f34323..595861064fd 100644 --- a/public/app/plugins/datasource/influxdb/specs/influx_query_specs.ts +++ b/public/app/plugins/datasource/influxdb/specs/influx_query_specs.ts @@ -236,6 +236,17 @@ describe('InfluxQuery', function() { expect(query.target.select[0][2].type).to.be('math'); }); + it('should add math when one only query part', function() { + var query = new InfluxQuery({ + measurement: 'cpu', + select: [[{type: 'field', params: ['value']}]] + }, templateSrv, {}); + + query.addSelectPart(query.selectModels[0], 'math'); + expect(query.target.select[0].length).to.be(2); + expect(query.target.select[0][1].type).to.be('math'); + }); + describe('when render adhoc filters', function() { it('should generate correct query segment', function() { var query = new InfluxQuery({measurement: 'cpu', }, templateSrv, {}); diff --git a/public/app/plugins/datasource/influxdb/specs/query_part_specs.ts b/public/app/plugins/datasource/influxdb/specs/query_part_specs.ts index 299ec9b47fd..ba32c961909 100644 --- a/public/app/plugins/datasource/influxdb/specs/query_part_specs.ts +++ b/public/app/plugins/datasource/influxdb/specs/query_part_specs.ts @@ -5,7 +5,7 @@ import queryPart from '../query_part'; describe('InfluxQueryPart', () => { - describe('series with mesurement only', () => { + describe('series with measurement only', () => { it('should handle nested function parts', () => { var part = queryPart.create({ type: 'derivative', @@ -25,7 +25,7 @@ describe('InfluxQueryPart', () => { expect(part.render('value')).to.be('spread(value)'); }); - it('should handle suffirx parts', () => { + it('should handle suffix parts', () => { var part = queryPart.create({ type: 'math', params: ['/ 100'], From f500dfd1e55697c12e50acfe9477cb54bf445fc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 24 Jul 2017 12:23:07 +0200 Subject: [PATCH 7/7] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4c62309d38..6107a078d22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ## Bug Fixes +* **Dashboard(settings)**: Closing setting views using ESC key did not update url correctly, fixes [#8869](https://github.com/grafana/grafana/issues/8869) * **Forms(TextArea)**: Bug fix for no scroll in text areas [#8797](https://github.com/grafana/grafana/issues/8797) # 4.4.1 (2017-07-05)