From 2e5a1328a84d627cc81573f59f3a8ffa384fce55 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Fri, 4 Mar 2016 11:36:30 +0900 Subject: [PATCH 001/165] (cloudwatch) support interval template variable --- .../plugins/datasource/cloudwatch/datasource.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/datasource/cloudwatch/datasource.js b/public/app/plugins/datasource/cloudwatch/datasource.js index a034134e657..34522344931 100644 --- a/public/app/plugins/datasource/cloudwatch/datasource.js +++ b/public/app/plugins/datasource/cloudwatch/datasource.js @@ -3,9 +3,10 @@ define([ 'lodash', 'moment', 'app/core/utils/datemath', + 'app/core/utils/kbn', './annotation_query', ], -function (angular, _, moment, dateMath, CloudWatchAnnotationQuery) { +function (angular, _, moment, dateMath, kbn, CloudWatchAnnotationQuery) { 'use strict'; /** @ngInject */ @@ -36,7 +37,16 @@ function (angular, _, moment, dateMath, CloudWatchAnnotationQuery) { query.statistics = target.statistics; var range = end - start; - query.period = parseInt(target.period, 10) || (query.namespace === 'AWS/EC2' ? 300 : 60); + if (!target.period) { + query.period = (query.namespace === 'AWS/EC2') ? 300 : 60; + } else if (/^\d+$/.test(target.period)) { + query.period = parseInt(target.period, 10); + } else { + query.period = kbn.interval_to_seconds(templateSrv.replace(target.period, options.scopedVars)); + } + if (query.period < 60) { + query.period = 60; + } if (range / query.period >= 1440) { query.period = Math.ceil(range / 1440 / 60) * 60; } From ab9abee67b6292e0ecb135346aaa2e563f1c92ce Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Tue, 19 Apr 2016 23:14:41 +0900 Subject: [PATCH 002/165] (cloudwatch) add test for interval variable --- .../cloudwatch/specs/datasource_specs.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts b/public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts index 86e085b3f6f..cd13c4502d7 100644 --- a/public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts +++ b/public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts @@ -82,6 +82,35 @@ describe('CloudWatchDatasource', function() { ctx.$rootScope.$apply(); }); + it('should generate the correct query with interval variable', function(done) { + ctx.templateSrv.data = { + period: '10m' + }; + + var query = { + range: { from: 'now-1h', to: 'now' }, + targets: [ + { + region: 'us-east-1', + namespace: 'AWS/EC2', + metricName: 'CPUUtilization', + dimensions: { + InstanceId: 'i-12345678' + }, + statistics: ['Average'], + period: '[[period]]' + } + ] + }; + + ctx.ds.query(query).then(function() { + var params = requestParams.data.parameters; + expect(params.period).to.be(600); + done(); + }); + ctx.$rootScope.$apply(); + }); + it('should return series list', function(done) { ctx.ds.query(query).then(function(result) { expect(result.data[0].target).to.be('CPUUtilization_Average'); From b66d94343ed12f713429a44d349322728e4bf29b Mon Sep 17 00:00:00 2001 From: bergquist Date: Fri, 30 Sep 2016 07:35:48 +0200 Subject: [PATCH 003/165] tech(tsdb): add basic skeleton for alerting --- pkg/tsdb/opentsdb/opentsdb.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 pkg/tsdb/opentsdb/opentsdb.go diff --git a/pkg/tsdb/opentsdb/opentsdb.go b/pkg/tsdb/opentsdb/opentsdb.go new file mode 100644 index 00000000000..57134657603 --- /dev/null +++ b/pkg/tsdb/opentsdb/opentsdb.go @@ -0,0 +1,30 @@ +package opentsdb + +import ( + "net/http" + + "github.com/grafana/grafana/pkg/log" + "github.com/grafana/grafana/pkg/tsdb" +) + +type OpenTsdbExecutor struct { + *tsdb.DataSourceInfo +} + +func NewOpenTsdbExecutorExecutor(dsInfo *tsdb.DataSourceInfo) tsdb.Executor { + return &OpenTsdbExecutor{dsInfo} +} + +var ( + plog log.Logger + HttpClient http.Client +) + +func init() { + plog = log.New("tsdb.opentsdb") + tsdb.RegisterExecutor("opentsdb", NewOpenTsdbExecutorExecutor) +} + +func (e *OpenTsdbExecutor) Execute(queries tsdb.QuerySlice, queryContext *tsdb.QueryContext) *tsdb.BatchResult { + panic("Missing implementation") +} From 1226beba31e385f8d06614db6b489d9da90c8540 Mon Sep 17 00:00:00 2001 From: bergquist Date: Fri, 30 Sep 2016 16:50:50 +0200 Subject: [PATCH 004/165] feat(opentsdb): add alerting support to plugin.json --- public/app/plugins/datasource/opentsdb/plugin.json | 1 + 1 file changed, 1 insertion(+) diff --git a/public/app/plugins/datasource/opentsdb/plugin.json b/public/app/plugins/datasource/opentsdb/plugin.json index 02ba02e6e89..7de072c6948 100644 --- a/public/app/plugins/datasource/opentsdb/plugin.json +++ b/public/app/plugins/datasource/opentsdb/plugin.json @@ -6,6 +6,7 @@ "metrics": true, "defaultMatchFormat": "pipe", "annotations": true, + "alerting": true, "info": { "author": { From 91b180168e04b2395f467cbc5ea1f98d1c00235e Mon Sep 17 00:00:00 2001 From: bergquist Date: Sat, 1 Oct 2016 15:50:50 +0200 Subject: [PATCH 005/165] tech(notifications): remove unused filter markup --- public/app/features/alerting/notification_edit_ctrl.ts | 5 ----- public/app/features/alerting/partials/notification_edit.html | 5 +---- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/public/app/features/alerting/notification_edit_ctrl.ts b/public/app/features/alerting/notification_edit_ctrl.ts index de5703a0631..593dbef20f7 100644 --- a/public/app/features/alerting/notification_edit_ctrl.ts +++ b/public/app/features/alerting/notification_edit_ctrl.ts @@ -7,7 +7,6 @@ import config from 'app/core/config'; export class AlertNotificationEditCtrl { model: any; - showTest: boolean = false; testSeverity: string = "critical"; /** @ngInject */ @@ -53,10 +52,6 @@ export class AlertNotificationEditCtrl { this.model.settings = {}; } - toggleTest() { - this.showTest = !this.showTest; - } - testNotification() { var payload = { name: this.model.name, diff --git a/public/app/features/alerting/partials/notification_edit.html b/public/app/features/alerting/partials/notification_edit.html index 65964b2c7c4..9292ada852a 100644 --- a/public/app/features/alerting/partials/notification_edit.html +++ b/public/app/features/alerting/partials/notification_edit.html @@ -74,10 +74,7 @@
-
- -
-
+
From 4f2263552ce589a53e41c7a007baea51d05b8c3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 1 Oct 2016 16:31:57 +0200 Subject: [PATCH 006/165] feat(alerting): updated look for alerting panel, #6136 --- public/sass/pages/_alerting.scss | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/public/sass/pages/_alerting.scss b/public/sass/pages/_alerting.scss index 79eaa8ad8ee..c0f4818c690 100644 --- a/public/sass/pages/_alerting.scss +++ b/public/sass/pages/_alerting.scss @@ -50,7 +50,8 @@ .panel-alert-state { &--alerting { - box-shadow: 0 0 10px $critical; + animation: alerting-panel 2s 0s infinite; + opacity: 1; .panel-alert-icon:before { color: $critical; @@ -59,7 +60,7 @@ } &--ok { - //box-shadow: 0 0 5px rgba(0,200,0,10.8); + box-shadow: 0 0 5px rgba(0,200,0,10.8); .panel-alert-icon:before { color: $online; content: "\e611"; @@ -67,4 +68,16 @@ } } +@keyframes alerting-panel { + 0% { + box-shadow: none; + } + 50% { + box-shadow: 0 0 10px $critical; + } + 100% { + box-shadow: none; + } +} + From a6918617ff6c24a89bfde6fb8a97bac2160540b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 1 Oct 2016 16:41:27 +0200 Subject: [PATCH 007/165] feat(api): fixed minor issue with error message when trying to create duplicate datasource, fixes #6164 --- pkg/api/datasources.go | 5 +++++ pkg/models/datasource.go | 3 ++- pkg/services/sqlstore/datasource.go | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/api/datasources.go b/pkg/api/datasources.go index 18b48cd8e29..2b9964f7a71 100644 --- a/pkg/api/datasources.go +++ b/pkg/api/datasources.go @@ -92,6 +92,11 @@ func AddDataSource(c *middleware.Context, cmd m.AddDataSourceCommand) { cmd.OrgId = c.OrgId if err := bus.Dispatch(&cmd); err != nil { + if err == m.ErrDataSourceNameExists { + c.JsonApiErr(409, err.Error(), err) + return + } + c.JsonApiErr(500, "Failed to add datasource", err) return } diff --git a/pkg/models/datasource.go b/pkg/models/datasource.go index 794266ba71e..883cc3a90bd 100644 --- a/pkg/models/datasource.go +++ b/pkg/models/datasource.go @@ -22,7 +22,8 @@ const ( // Typed errors var ( - ErrDataSourceNotFound = errors.New("Data source not found") + ErrDataSourceNotFound = errors.New("Data source not found") + ErrDataSourceNameExists = errors.New("Data source with same name already exists") ) type DsAccess string diff --git a/pkg/services/sqlstore/datasource.go b/pkg/services/sqlstore/datasource.go index 2f1b40b2d61..56ca4f859e9 100644 --- a/pkg/services/sqlstore/datasource.go +++ b/pkg/services/sqlstore/datasource.go @@ -60,6 +60,14 @@ func DeleteDataSource(cmd *m.DeleteDataSourceCommand) error { func AddDataSource(cmd *m.AddDataSourceCommand) error { return inTransaction(func(sess *xorm.Session) error { + + existing := m.DataSource{OrgId: cmd.OrgId, Name: cmd.Name} + has, _ := x.Get(&existing) + + if has { + return m.ErrDataSourceNameExists + } + ds := &m.DataSource{ OrgId: cmd.OrgId, Name: cmd.Name, From 1f5a68aab1b0e3290ea15e0b6c416e2e5f4d8613 Mon Sep 17 00:00:00 2001 From: miao <362622365@qq.com> Date: Sat, 1 Oct 2016 22:50:09 +0800 Subject: [PATCH 008/165] Modify basic introductions of docs and make it exact (#6166) --- docs/sources/guides/basic_concepts.md | 6 +++--- docs/sources/guides/gettingstarted.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/sources/guides/basic_concepts.md b/docs/sources/guides/basic_concepts.md index b654554fa48..6141bb5f284 100644 --- a/docs/sources/guides/basic_concepts.md +++ b/docs/sources/guides/basic_concepts.md @@ -12,7 +12,7 @@ This document is a “bottom up” introduction to basic concepts in Grafana, an ### ** Data Source ** Grafana supports many different storage backends for your time series data (Data Source). Each Data Source has a specific Query Editor that is customized for the features and capabilities that the particular Data Source exposes. -The following datasources are officially supported: [Graphite](/datasources/graphite/), [InfluxDB](/datasources/influxdb/), [OpenTSDB](/datasources/opentsdb/), and [KairosDB](/datasources/kairosdb) +The following datasources are officially supported: [Graphite](/datasources/graphite/), [InfluxDB](/datasources/influxdb/), [OpenTSDB](/datasources/opentsdb/), [Prometheus](/datasources/prometheus/), [Elasticsearch](/datasources/elasticsearch/), [CloudWatch](/datasources/cloudwatch/), and [KairosDB](/datasources/kairosdb) The query language and capabilities of each Data Source are obviously very different. You can combine data from multiple Data Sources onto a single Dashboard, but each Panel is tied to a specific Data Source that belongs to a particular Organization. @@ -58,7 +58,7 @@ There are a wide variety of styling and formatting options that each Panel expos Panels can be dragged and dropped and rearranged on the Dashboard. They can also be resized. -There are currently four Panel types: [Graph](/reference/graph/), [Singlestat](/reference/singlestat/), [Dashlist](/reference/dashlist/), and [Text](/reference/text/). +There are currently four Panel types: [Graph](/reference/graph/), [Singlestat](/reference/singlestat/), [Dashlist](/reference/dashlist/), [Table](/reference/table_panel/),and [Text](/reference/text/). Panels like the [Graph](/reference/graph/) panel allow you to graph as many metrics and series as you want. Other panels like [Singlestat](/reference/singlestat/) require a reduction of a single query into a single number. [Dashlist](/reference/dashlist/) and [Text](/reference/text/) are special panels that do not connect to any Data Source. @@ -66,7 +66,7 @@ Panels can be made more dynamic by utilizing [Dashboard Templating](/reference/t Utilize the [Repeating Panel](/reference/templating/#utilizing-template-variables-with-repeating-panels-and-repeating-rows) functionality to dynamically create or remove Panels based on the [Templating Variables](/reference/templating/#utilizing-template-variables-with-repeating-panels-and-repeating-rows) selected. -The time range on Panels is normally what is set in the [Dashboard time picker](/reference/timerange/) but this can be overridden by utilizes [Panel specific time overrides](/reference/timerange/#panel-time-override). +The time range on Panels is normally what is set in the [Dashboard time picker](/reference/timerange/) but this can be overridden by utilizes [Panel specific time overrides](/reference/timerange/#panel-time-overrides-timeshift). Panels (or an entire Dashboard) can be [Shared](/reference/sharing/) easily in a variety of ways. You can send a link to someone who has a login to your Grafana. You can use the [Snapshot](/reference/sharing/#snapshots) feature to encode all the data currently being viewed into a static and interactive JSON document; it's so much better than emailing a screenshot! diff --git a/docs/sources/guides/gettingstarted.md b/docs/sources/guides/gettingstarted.md index 004b1fcdadb..73e162854e6 100644 --- a/docs/sources/guides/gettingstarted.md +++ b/docs/sources/guides/gettingstarted.md @@ -29,7 +29,7 @@ The image above shows you the top header for a Dashboard. 6. Settings: Manage Dashboard settings and features such as Templating and Annotations. ## Dashboards, Panels, Rows, the building blocks of Grafana... -Dashboards are at the core of what Grafana is all about. Dashboards are composed of individual Panels arranged on a number of Rows. Grafana ships with a variety of Panels. Grafana makes it easy to construct the right queries, and customize the display properties so that you can create the perfect Dashboard for your need. Each Panel can interact with data from any configured Grafana Data Source (currently InfluxDB, Graphite, OpenTSDB, and KairosDB). The [Core Concepts](/guides/basic_concepts) guide explores these key ideas in detail. +Dashboards are at the core of what Grafana is all about. Dashboards are composed of individual Panels arranged on a number of Rows. Grafana ships with a variety of Panels. Grafana makes it easy to construct the right queries, and customize the display properties so that you can create the perfect Dashboard for your need. Each Panel can interact with data from any configured Grafana Data Source (currently InfluxDB, Graphite, OpenTSDB, and KairosDB). The [Basic Concepts](/guides/basic_concepts) guide explores these key ideas in detail. ## Adding & Editing Graphs and Panels From 72f81b3b2a7de3893b92eb57987650ff5fbe071c Mon Sep 17 00:00:00 2001 From: HeroCC Date: Sat, 1 Oct 2016 10:50:56 -0400 Subject: [PATCH 009/165] Make Slack Logo link to Slack (#6165) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 98f4b4d3c9d..fac9cb94c88 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [Website](http://grafana.org) | [Twitter](https://twitter.com/grafana) | [IRC](https://webchat.freenode.net/?channels=grafana) | -![](https://brandfolder.com/api/favicon/icon?size=16&domain=www.slack.com) +[![Slack](https://brandfolder.com/api/favicon/icon?size=16&domain=www.slack.com)](http://slack.raintank.io) [Slack](http://slack.raintank.io) | [Email](mailto:contact@grafana.org) From c6cf6d4655d1ab050787ce9fc8125d00dcab0724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 1 Oct 2016 16:52:35 +0200 Subject: [PATCH 010/165] fix(api): fixed issue with api content-type in api success messages, fixes #6160 --- pkg/api/common.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/api/common.go b/pkg/api/common.go index 82eed0db5fe..bd1c8be477d 100644 --- a/pkg/api/common.go +++ b/pkg/api/common.go @@ -79,7 +79,7 @@ func Json(status int, body interface{}) *NormalResponse { func ApiSuccess(message string) *NormalResponse { resp := make(map[string]interface{}) resp["message"] = message - return Respond(200, resp) + return Json(200, resp) } func ApiError(status int, message string, err error) *NormalResponse { From 4ec2377e09d444d49610007dacce53999f44c410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 1 Oct 2016 17:14:45 +0200 Subject: [PATCH 011/165] fix(notifications): added form validation and restored Send Test button which was always hidden, #6159 --- .../alerting/notification_edit_ctrl.ts | 9 ++ .../alerting/partials/notification_edit.html | 131 +++++++++--------- public/app/features/plugins/ds_edit_ctrl.ts | 2 +- 3 files changed, 73 insertions(+), 69 deletions(-) diff --git a/public/app/features/alerting/notification_edit_ctrl.ts b/public/app/features/alerting/notification_edit_ctrl.ts index 593dbef20f7..19b804f4697 100644 --- a/public/app/features/alerting/notification_edit_ctrl.ts +++ b/public/app/features/alerting/notification_edit_ctrl.ts @@ -7,6 +7,7 @@ import config from 'app/core/config'; export class AlertNotificationEditCtrl { model: any; + theForm: any; testSeverity: string = "critical"; /** @ngInject */ @@ -35,6 +36,10 @@ export class AlertNotificationEditCtrl { } save() { + if (!this.theForm.$valid) { + return; + } + if (this.model.id) { this.backendSrv.put(`/api/alert-notifications/${this.model.id}`, this.model).then(res => { this.model = res; @@ -53,6 +58,10 @@ export class AlertNotificationEditCtrl { } testNotification() { + if (!this.theForm.$valid) { + return; + } + var payload = { name: this.model.name, type: this.model.type, diff --git a/public/app/features/alerting/partials/notification_edit.html b/public/app/features/alerting/partials/notification_edit.html index 9292ada852a..817035d21a3 100644 --- a/public/app/features/alerting/partials/notification_edit.html +++ b/public/app/features/alerting/partials/notification_edit.html @@ -6,78 +6,73 @@
-