From b8572b69f0f833bcf37b5f974d27c2cbc3c52587 Mon Sep 17 00:00:00 2001 From: Darrian Date: Wed, 21 Dec 2016 22:30:32 +0000 Subject: [PATCH 01/18] Register new queries available in InfluxDB - Holt Winters fixes #5619 For correct data fill on holt winters predictions, the time function needed modification to allow a 2nd param for offset, as per https://docs.influxdata.com/influxdb/v1.0/query_language/data_exploratio n/#advanced-group-by-time-syntax --- pkg/tsdb/influxdb/query_part.go | 9 +++++++ .../plugins/datasource/influxdb/query_part.ts | 24 +++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/pkg/tsdb/influxdb/query_part.go b/pkg/tsdb/influxdb/query_part.go index 222e0b054ee..22848dd3ee2 100644 --- a/pkg/tsdb/influxdb/query_part.go +++ b/pkg/tsdb/influxdb/query_part.go @@ -33,6 +33,15 @@ func init() { renders["median"] = QueryDefinition{Renderer: functionRenderer} renders["sum"] = QueryDefinition{Renderer: functionRenderer} + renders["holt_winters"] = QueryDefinition{ + Renderer: functionRenderer, + Params: []DefinitionParameters{{Name: "number", Type: "number"}, {Name: "season", Type: "number"}}, + } + renders["holt_winters_with_fit"] = QueryDefinition{ + Renderer: functionRenderer, + Params: []DefinitionParameters{{Name: "number", Type: "number"}, {Name: "season", Type: "number"}}, + } + renders["derivative"] = QueryDefinition{ Renderer: functionRenderer, Params: []DefinitionParameters{{Name: "duration", Type: "interval"}}, diff --git a/public/app/plugins/datasource/influxdb/query_part.ts b/public/app/plugins/datasource/influxdb/query_part.ts index c0592204bc8..ea66bedd316 100644 --- a/public/app/plugins/datasource/influxdb/query_part.ts +++ b/public/app/plugins/datasource/influxdb/query_part.ts @@ -241,8 +241,9 @@ register({ register({ type: 'time', category: groupByTimeFunctions, - params: [{ name: "interval", type: "time", options: ['auto', '1s', '10s', '1m', '5m', '10m', '15m', '1h'] }], - defaultParams: ['auto'], + params: [{ name: "interval", type: "time", options: ['auto', '1s', '10s', '1m', '5m', '10m', '15m', '1h'] }, + { name: "offset", type: "time", options: ['auto', '1s', '10s', '1m', '5m', '10m', '15m', '1h'] }], + defaultParams: ['auto', 'auto'], renderer: functionRenderer, }); @@ -263,6 +264,25 @@ register({ renderer: functionRenderer, }); +// predictions +register({ + type: 'holt_winters', + addStrategy: addTransformationStrategy, + category: categories.Predictions, + params: [{ name: "number", type: "number", options: [5, 10, 20, 30, 40]}, { name: "season", type: "number", options: [0, 1, 2, 5, 10]}], + defaultParams: [10, 2], + renderer: functionRenderer, +}); + +register({ + type: 'holt_winters_with_fit', + addStrategy: addTransformationStrategy, + category: categories.Predictions, + params: [{ name: "number", type: "number", options: [5, 10, 20, 30, 40]}, { name: "season", type: "number", options: [0, 1, 2, 5, 10]}], + defaultParams: [10, 2], + renderer: functionRenderer, +}); + // Selectors register({ type: 'bottom', From 27ead53382df6beea018b9327d46af24a999f5d6 Mon Sep 17 00:00:00 2001 From: Darrian Date: Wed, 21 Dec 2016 22:54:56 +0000 Subject: [PATCH 02/18] Set indentation to tabs --- pkg/tsdb/influxdb/query_part.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/tsdb/influxdb/query_part.go b/pkg/tsdb/influxdb/query_part.go index 22848dd3ee2..0ea4a435df1 100644 --- a/pkg/tsdb/influxdb/query_part.go +++ b/pkg/tsdb/influxdb/query_part.go @@ -33,15 +33,15 @@ func init() { renders["median"] = QueryDefinition{Renderer: functionRenderer} renders["sum"] = QueryDefinition{Renderer: functionRenderer} - renders["holt_winters"] = QueryDefinition{ - Renderer: functionRenderer, - Params: []DefinitionParameters{{Name: "number", Type: "number"}, {Name: "season", Type: "number"}}, - } - renders["holt_winters_with_fit"] = QueryDefinition{ - Renderer: functionRenderer, - Params: []DefinitionParameters{{Name: "number", Type: "number"}, {Name: "season", Type: "number"}}, - } - + renders["holt_winters"] = QueryDefinition{ + Renderer: functionRenderer, + Params: []DefinitionParameters{{Name: "number", Type: "number"}, {Name: "season", Type: "number"}}, + } + renders["holt_winters_with_fit"] = QueryDefinition{ + Renderer: functionRenderer, + Params: []DefinitionParameters{{Name: "number", Type: "number"}, {Name: "season", Type: "number"}}, + } + renders["derivative"] = QueryDefinition{ Renderer: functionRenderer, Params: []DefinitionParameters{{Name: "duration", Type: "interval"}}, @@ -59,7 +59,7 @@ func init() { renders["stddev"] = QueryDefinition{Renderer: functionRenderer} renders["time"] = QueryDefinition{ Renderer: functionRenderer, - Params: []DefinitionParameters{{Name: "interval", Type: "time"}}, + Params: []DefinitionParameters{{Name: "interval", Type: "time"}, {Name: "offset", Type: "time"}}, } renders["fill"] = QueryDefinition{ Renderer: functionRenderer, From 96f3ee9e4cb2305057839e4421a66295dee39435 Mon Sep 17 00:00:00 2001 From: Darrian Date: Wed, 21 Dec 2016 22:55:18 +0000 Subject: [PATCH 03/18] Added missing category for Predictions --- public/app/plugins/datasource/influxdb/query_part.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/public/app/plugins/datasource/influxdb/query_part.ts b/public/app/plugins/datasource/influxdb/query_part.ts index ea66bedd316..94d876780be 100644 --- a/public/app/plugins/datasource/influxdb/query_part.ts +++ b/public/app/plugins/datasource/influxdb/query_part.ts @@ -15,6 +15,7 @@ var categories = { Aggregations: [], Selectors: [], Transformations: [], + Predictions: [], Math: [], Aliasing: [], Fields: [], From cdfb24ab85fdfe996716270733a8de5e8aede459 Mon Sep 17 00:00:00 2001 From: Darrian Date: Wed, 21 Dec 2016 22:58:40 +0000 Subject: [PATCH 04/18] Added offset interval to specs --- .../plugins/datasource/influxdb/specs/influx_query_specs.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 52beed1d080..ef4ece940e9 100644 --- a/public/app/plugins/datasource/influxdb/specs/influx_query_specs.ts +++ b/public/app/plugins/datasource/influxdb/specs/influx_query_specs.ts @@ -124,7 +124,7 @@ describe('InfluxQuery', function() { var queryText = query.render(); expect(queryText).to.be('SELECT mean("value") FROM "cpu" WHERE $timeFilter ' + - 'GROUP BY time($interval), "host"'); + 'GROUP BY time($interval, $interval), "host"'); }); }); @@ -148,7 +148,7 @@ describe('InfluxQuery', function() { groupBy: [{type: 'time'}, {type: 'fill', params: ['0']}], }, templateSrv, {}); var queryText = query.render(); - expect(queryText).to.be('SELECT "value" FROM "cpu" WHERE $timeFilter GROUP BY time($interval) fill(0)'); + expect(queryText).to.be('SELECT "value" FROM "cpu" WHERE $timeFilter GROUP BY time($interval, $interval) fill(0)'); }); }); From 3ca3c9622696d5cce1b7d5c23f2056e97baae8fa Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Thu, 6 Apr 2017 11:59:01 +0200 Subject: [PATCH 05/18] profiling: adds profiling and tracing If grafana-server binary is started with the -profile flag then tracing will create a trace.out file and pprof data can be accessed on the 6060 port. A custom port for pprof profiling can be set with the -profile-port flag. --- pkg/cmd/grafana-server/main.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pkg/cmd/grafana-server/main.go b/pkg/cmd/grafana-server/main.go index 7e8a6061a3f..cd3dd0dbd36 100644 --- a/pkg/cmd/grafana-server/main.go +++ b/pkg/cmd/grafana-server/main.go @@ -8,10 +8,14 @@ import ( "os/signal" "path/filepath" "runtime" + "runtime/trace" "strconv" "syscall" "time" + "net/http" + _ "net/http/pprof" + "github.com/grafana/grafana/pkg/log" "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/services/sqlstore" @@ -44,12 +48,33 @@ func init() { func main() { v := flag.Bool("v", false, "prints current version and exits") + profile := flag.Bool("profile", false, "Turn on pprof profiling") + profilePort := flag.Int("profile-port", 6060, "Define custom port for profiling") flag.Parse() if *v { fmt.Printf("Version %s (commit: %s)\n", version, commit) os.Exit(0) } + if *profile { + runtime.SetBlockProfileRate(1) + go func() { + http.ListenAndServe(fmt.Sprintf("localhost:%d", *profilePort), nil) + }() + + f, err := os.Create("trace.out") + if err != nil { + panic(err) + } + defer f.Close() + + err = trace.Start(f) + if err != nil { + panic(err) + } + defer trace.Stop() + } + buildstampInt64, _ := strconv.ParseInt(buildstamp, 10, 64) if buildstampInt64 == 0 { buildstampInt64 = time.Now().Unix() @@ -113,6 +138,8 @@ func listenToSystemSignals(server models.GrafanaServer) { select { case sig := <-signalChan: + // Stops trace if profiling has been enabled + trace.Stop() server.Shutdown(0, fmt.Sprintf("system signal: %s", sig)) case code = <-exitChan: server.Shutdown(code, "startup error") From e0640487dfa5527b22d689b472a2a17ca23516a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 11 Apr 2017 13:38:13 +0200 Subject: [PATCH 06/18] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 024bc39d2dd..5c32dcdba40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,10 @@ * **InfluxDB**: Small fix for the "glow" when focus the field for LIMIT and SLIMIT [#7799](https://github.com/grafana/grafana/pull/7799) thx [@thuck](https://github.com/thuck) * **Panels**: Delay loading & Lazy load panels as they become visible (scrolled into view) [#5216](https://github.com/grafana/grafana/issues/5216) thx [@jifwin](https://github.com/jifwin) * **Graph**: Support auto grid min/max when using log scale [#3090](https://github.com/grafana/grafana/issues/3090), thx [@bigbenhur](https://github.com/bigbenhur) +* **Graph**: Support for histograms [#600](https://github.com/grafana/grafana/issues/600) * **Elasticsearch**: Support histogram aggregations [#3164](https://github.com/grafana/grafana/issues/3164) + ## Minor Enchancements * **Prometheus**: Make Prometheus query field a textarea [#7663](https://github.com/grafana/grafana/issues/7663), thx [@hagen1778](https://github.com/hagen1778) From 9099119f6293f7648c43d074eac5d0e4e4a9266d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 11 Apr 2017 14:42:35 +0200 Subject: [PATCH 07/18] grunt: minor watch fix --- tasks/options/watch.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/tasks/options/watch.js b/tasks/options/watch.js index b74eb4a0c6a..545a149054a 100644 --- a/tasks/options/watch.js +++ b/tasks/options/watch.js @@ -54,19 +54,12 @@ module.exports = function(config, grunt) { grunt.task.run('css'); } - // if (/(\.ts)$/.test(filepath)) { - // newPath = filepath.replace(/^public/, 'public_gen'); - // grunt.log.writeln('Copying to ' + newPath); - // grunt.file.copy(filepath, newPath); - // - // // copy ts file also used by source maps - // //changes changed file source to that of the changed file - // grunt.config('typescript.build.src', filepath); - // grunt.config('tslint.source.files.src', filepath); - // - // grunt.task.run('exec:tscompile'); - // grunt.task.run('exec:tslint'); - // } + if (/(\.ts)$/.test(filepath)) { + newPath = filepath.replace(/^public/, 'public_gen'); + grunt.log.writeln('Copying to ' + newPath); + grunt.file.copy(filepath, newPath); + grunt.task.run('exec:tslint'); + } done(); firstRun = false; From 89a7c2c686854790f5306ab6de7f7aa48a55643b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 11 Apr 2017 15:05:30 +0200 Subject: [PATCH 08/18] influxdb: validate database exist when saving data source, fixes #7864 --- public/app/core/components/query_part/query_part.ts | 2 -- public/app/plugins/datasource/influxdb/datasource.ts | 11 ++++++++++- public/app/plugins/datasource/influxdb/query_part.ts | 1 - 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/public/app/core/components/query_part/query_part.ts b/public/app/core/components/query_part/query_part.ts index cf6780ac182..00538102fb2 100644 --- a/public/app/core/components/query_part/query_part.ts +++ b/public/app/core/components/query_part/query_part.ts @@ -119,5 +119,3 @@ export function identityRenderer(part, innerExpr) { export function quotedIdentityRenderer(part, innerExpr) { return '"' + part.params[0] + '"'; } - - diff --git a/public/app/plugins/datasource/influxdb/datasource.ts b/public/app/plugins/datasource/influxdb/datasource.ts index dc6aaaf7a03..98c7ba87bd2 100644 --- a/public/app/plugins/datasource/influxdb/datasource.ts +++ b/public/app/plugins/datasource/influxdb/datasource.ts @@ -193,8 +193,17 @@ export default class InfluxDatasource { } testDatasource() { - return this.metricFindQuery('SHOW MEASUREMENTS LIMIT 1').then(() => { + return this.metricFindQuery('SHOW DATABASES').then(res => { + let found = _.find(res, {text: this.database}); + if (!found) { + return { status: "error", message: "Could not find the specified database name.", title: "DB Not found" }; + } return { status: "success", message: "Data source is working", title: "Success" }; + }).catch(err => { + if (err.data && err.message) { + return { status: "error", message: err.data.message, title: "InfluxDB Error" }; + } + return { status: "error", message: err.toString(), title: "InfluxDB Error" }; }); } diff --git a/public/app/plugins/datasource/influxdb/query_part.ts b/public/app/plugins/datasource/influxdb/query_part.ts index 6b55b19f4d2..20274ccc580 100644 --- a/public/app/plugins/datasource/influxdb/query_part.ts +++ b/public/app/plugins/datasource/influxdb/query_part.ts @@ -292,7 +292,6 @@ register({ renderer: functionRenderer, }); -debugger; register({ type: 'holt_winters_with_fit', addStrategy: addTransformationStrategy, From a109049de4af907e38c2a31c9d1410ebd7331cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 11 Apr 2017 16:41:07 +0200 Subject: [PATCH 09/18] smpt: Added smtp docker block --- docker/blocks/smtp/fig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/blocks/smtp/fig b/docker/blocks/smtp/fig index c2d37e01c21..3aa25e01311 100644 --- a/docker/blocks/smtp/fig +++ b/docker/blocks/smtp/fig @@ -1,4 +1,4 @@ snmpd: - build: blocks/snmpd + image: namshi/smtp ports: - - "161:161" + - "25:25" From 07466b6725e2ea050eb2950bee3a473270fad6aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 11 Apr 2017 16:50:16 +0200 Subject: [PATCH 10/18] security: fixed returning info on weither user exists or not in password reset call, fixes #7619 --- pkg/api/password.go | 3 ++- public/app/partials/reset_password.html | 15 +++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pkg/api/password.go b/pkg/api/password.go index f3c2b0b7058..e71f1317ee4 100644 --- a/pkg/api/password.go +++ b/pkg/api/password.go @@ -12,7 +12,8 @@ func SendResetPasswordEmail(c *middleware.Context, form dtos.SendResetPasswordEm userQuery := m.GetUserByLoginQuery{LoginOrEmail: form.UserOrEmail} if err := bus.Dispatch(&userQuery); err != nil { - return ApiError(404, "User does not exist", err) + c.Logger.Info("Requested password reset for user that was not found", "user", userQuery.LoginOrEmail) + return ApiError(200, "Email sent", err) } emailCmd := m.SendResetPasswordEmailCommand{User: userQuery.Result} diff --git a/public/app/partials/reset_password.html b/public/app/partials/reset_password.html index b0807a06920..82024932a16 100644 --- a/public/app/partials/reset_password.html +++ b/public/app/partials/reset_password.html @@ -21,15 +21,22 @@
+
+
-
- An email with a reset link as been sent to the email address, you should receive it shortly. -
+ +
+ An email with a reset link as been sent to the email address.
+ You should receive it shortly. +
+ +
+