From 70d6b32e14edd2653a81e1dd52fc834e55c21456 Mon Sep 17 00:00:00 2001 From: minki Date: Sun, 22 May 2016 05:38:57 +0900 Subject: [PATCH 1/4] Fixed type --- public/app/core/directives/plugin_component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/core/directives/plugin_component.ts b/public/app/core/directives/plugin_component.ts index 6f693a13d68..c8fb5c9ba91 100644 --- a/public/app/core/directives/plugin_component.ts +++ b/public/app/core/directives/plugin_component.ts @@ -244,7 +244,7 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $ registerPluginComponent(scope, elem, attrs, componentInfo); }).catch(err => { $rootScope.appEvent('alert-error', ['Plugin Error', err.message || err]); - console.log('Plugin componnet error', err); + console.log('Plugin component error', err); }); } }; From cf87e8ecf569f7bb52cfb7e6c3bb301a7235243c Mon Sep 17 00:00:00 2001 From: hc4 Date: Fri, 27 May 2016 18:26:20 +0300 Subject: [PATCH 2/4] Fix parsing of intervals. defined in ms (#5151) * Fix parsing of intervals. defined in ms Fix parsing of intervals. defined in ms. Increase accuracy for sub-second inrevals. Closes #5008 * Tests for sub-ms intervals Unit test for https://github.com/grafana/grafana/commit/2034d4b9710b0cb9fd0cdf14aa9981cd0417eda4 --- public/app/core/utils/kbn.js | 23 ++++++++++++++++++----- public/test/core/utils/kbn_specs.js | 6 ++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/public/app/core/utils/kbn.js b/public/app/core/utils/kbn.js index 9d714c34fb3..f54979b0e97 100644 --- a/public/app/core/utils/kbn.js +++ b/public/app/core/utils/kbn.js @@ -12,9 +12,21 @@ function($, _) { kbn.round_interval = function(interval) { switch (true) { - // 0.3s - case (interval <= 300): - return 100; // 0.1s + // 0.015s + case (interval <= 15): + return 10; // 0.01s + // 0.035s + case (interval <= 35): + return 20; // 0.02s + // 0.075s + case (interval <= 75): + return 50; // 0.05s + // 0.15s + case (interval <= 150): + return 100; // 0.1s + // 0.35s + case (interval <= 350): + return 200; // 0.2s // 0.75s case (interval <= 750): return 500; // 0.5s @@ -133,7 +145,7 @@ function($, _) { return str; }; - kbn.interval_regex = /(\d+(?:\.\d+)?)([Mwdhmsy])/; + kbn.interval_regex = /(\d+(?:\.\d+)?)(ms|[Mwdhmsy])/; // histogram & trends kbn.intervals_in_seconds = { @@ -143,7 +155,8 @@ function($, _) { d: 86400, h: 3600, m: 60, - s: 1 + s: 1, + ms: 0.001 }; kbn.calculateInterval = function(range, resolution, userInterval) { diff --git a/public/test/core/utils/kbn_specs.js b/public/test/core/utils/kbn_specs.js index 7e75e880546..0a2ad165253 100644 --- a/public/test/core/utils/kbn_specs.js +++ b/public/test/core/utils/kbn_specs.js @@ -147,5 +147,11 @@ define([ var str = kbn.calculateInterval(range, 1000, '>10s'); expect(str).to.be('20m'); }); + + it('10s 900 resolution and user low limit in ms', function() { + var range = { from: dateMath.parse('now-10s'), to: dateMath.parse('now') }; + var str = kbn.calculateInterval(range, 900, '>15ms'); + expect(str).to.be('15ms'); + }); }); }); From ca8543348b2f8430f5d8ad205f54c84ae002f361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 28 May 2016 10:13:51 +0200 Subject: [PATCH 3/4] docker(): added collectd system metrics collector that writes to graphite, just for testing --- docker/blocks/collectd/Dockerfile | 16 +++++ docker/blocks/collectd/README.md | 37 ++++++++++++ docker/blocks/collectd/collectd.conf.tpl | 76 ++++++++++++++++++++++++ docker/blocks/collectd/etc_mtab | 1 + docker/blocks/collectd/fig | 11 ++++ docker/blocks/collectd/start_container | 5 ++ 6 files changed, 146 insertions(+) create mode 100644 docker/blocks/collectd/Dockerfile create mode 100644 docker/blocks/collectd/README.md create mode 100644 docker/blocks/collectd/collectd.conf.tpl create mode 100644 docker/blocks/collectd/etc_mtab create mode 100644 docker/blocks/collectd/fig create mode 100644 docker/blocks/collectd/start_container diff --git a/docker/blocks/collectd/Dockerfile b/docker/blocks/collectd/Dockerfile new file mode 100644 index 00000000000..a08b1f9c1b2 --- /dev/null +++ b/docker/blocks/collectd/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:xenial + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get -y update +RUN apt-get -y install collectd curl python-pip + +# add a fake mtab for host disk stats +ADD etc_mtab /etc/mtab + +ADD collectd.conf.tpl /etc/collectd/collectd.conf.tpl + +RUN pip install envtpl +ADD start_container /usr/bin/start_container +RUN chmod +x /usr/bin/start_container +CMD start_container diff --git a/docker/blocks/collectd/README.md b/docker/blocks/collectd/README.md new file mode 100644 index 00000000000..2c1a8cb79fc --- /dev/null +++ b/docker/blocks/collectd/README.md @@ -0,0 +1,37 @@ +collectd-write-graphite +======================= + +Basic collectd-based server monitoring. Sends stats to Graphite. + +Collectd metrics: + +* CPU used/free/idle/etc +* Free disk (via mounting hosts '/' into container, eg: -v /:/hostfs:ro) +* Disk performance +* Load average +* Memory used/free/etc +* Uptime +* Network interface +* Swap + +Environment variables +--------------------- + +* `HOST_NAME` + - Will be sent to Graphite + - Required +* `GRAPHITE_HOST` + - Graphite IP or hostname + - Required +* `GRAPHITE_PORT` + - Graphite port + - Optional, defaults to 2003 +* `GRAPHITE_PREFIX` + - Graphite prefix + - Optional, defaults to collectd. +* `REPORT_BY_CPU` + - Report per-CPU metrics if true, global sum of CPU metrics if false (details: [collectd.conf man page](https://collectd.org/documentation/manpages/collectd.conf.5.shtml#plugin_cpu)) + - Optional, defaults to false. +* `COLLECT_INTERVAL` + - Collection interval and thus resolution of metrics + - Optional, defaults to 10 diff --git a/docker/blocks/collectd/collectd.conf.tpl b/docker/blocks/collectd/collectd.conf.tpl new file mode 100644 index 00000000000..c19654b39f9 --- /dev/null +++ b/docker/blocks/collectd/collectd.conf.tpl @@ -0,0 +1,76 @@ +Hostname "{{ HOST_NAME }}" + +FQDNLookup false +Interval {{ COLLECT_INTERVAL | default("10") }} +Timeout 2 +ReadThreads 5 + +LoadPlugin cpu +LoadPlugin df +LoadPlugin load +LoadPlugin memory +LoadPlugin disk +LoadPlugin interface +LoadPlugin uptime +LoadPlugin swap +LoadPlugin write_graphite + + + ReportByCpu {{ REPORT_BY_CPU | default("false") }} + + + + # expose host's mounts into container using -v /:/host:ro (location inside container does not matter much) + # ignore rootfs; else, the root file-system would appear twice, causing + # one of the updates to fail and spam the log + FSType rootfs + # ignore the usual virtual / temporary file-systems + FSType sysfs + FSType proc + FSType devtmpfs + FSType devpts + FSType tmpfs + FSType fusectl + FSType cgroup + FSType overlay + FSType debugfs + FSType pstore + FSType securityfs + FSType hugetlbfs + FSType squashfs + FSType mqueue + MountPoint "/etc/resolv.conf" + MountPoint "/etc/hostname" + MountPoint "/etc/hosts" + IgnoreSelected true + ReportByDevice false + ReportReserved true + ReportInodes true + + + + Disk "/^[hs]d[a-z]/" + IgnoreSelected false + + + + + Interface "lo" + Interface "/^veth.*/" + Interface "/^docker.*/" + IgnoreSelected true + + + + + + Host "{{ GRAPHITE_HOST }}" + Port "{{ GRAPHITE_PORT | default("2003") }}" + Prefix "{{ GRAPHITE_PREFIX | default("collectd.") }}" + EscapeCharacter "_" + SeparateInstances true + StoreRates true + AlwaysAppendDS false + + + diff --git a/docker/blocks/collectd/etc_mtab b/docker/blocks/collectd/etc_mtab new file mode 100644 index 00000000000..749f9789482 --- /dev/null +++ b/docker/blocks/collectd/etc_mtab @@ -0,0 +1 @@ +hostfs /.dockerinit ext4 ro,relatime,user_xattr,barrier=1,data=ordered 0 0 diff --git a/docker/blocks/collectd/fig b/docker/blocks/collectd/fig new file mode 100644 index 00000000000..99f45a66d12 --- /dev/null +++ b/docker/blocks/collectd/fig @@ -0,0 +1,11 @@ +collectd: + build: blocks/collectd + environment: + HOST_NAME: myserver + GRAPHITE_HOST: graphite + GRAPHITE_PORT: 2003 + GRAPHITE_PREFIX: collectd. + REPORT_BY_CPU: 'false' + COLLECT_INTERVAL: 10 + links: + - graphite diff --git a/docker/blocks/collectd/start_container b/docker/blocks/collectd/start_container new file mode 100644 index 00000000000..b01cd0d5ff2 --- /dev/null +++ b/docker/blocks/collectd/start_container @@ -0,0 +1,5 @@ +#!/bin/bash + +envtpl /etc/collectd/collectd.conf.tpl + +collectd -f From 1ea54049d07c4cc7959e20a6f9b6ffde24e670b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 28 May 2016 16:59:29 +0200 Subject: [PATCH 4/4] feat(templating): added new template variable type constant --- public/app/features/templating/editorCtrl.js | 20 +++++++++++++++++++ .../features/templating/partials/editor.html | 10 +++++++++- .../features/templating/templateValuesSrv.js | 8 +++++++- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/public/app/features/templating/editorCtrl.js b/public/app/features/templating/editorCtrl.js index 43bda1db05f..5efebc21e30 100644 --- a/public/app/features/templating/editorCtrl.js +++ b/public/app/features/templating/editorCtrl.js @@ -25,6 +25,7 @@ function (angular, _) { {value: "interval", text: "Interval"}, {value: "datasource", text: "Data source"}, {value: "custom", text: "Custom"}, + {value: "constant", text: "Constant"}, ]; $scope.refreshOptions = [ @@ -141,15 +142,34 @@ function (angular, _) { $scope.current = angular.copy(replacementDefaults); }; + $scope.showSelectionOptions = function() { + if ($scope.current) { + if ($scope.current.type === 'query') { + return true; + } + if ($scope.current.type === 'custom') { + return true; + } + } + return false; + }; + $scope.typeChanged = function () { if ($scope.current.type === 'interval') { $scope.current.query = '1m,10m,30m,1h,6h,12h,1d,7d,14d,30d'; + $scope.current.refresh = 0; } if ($scope.current.type === 'query') { $scope.current.query = ''; } + if ($scope.current.type === 'constant') { + $scope.current.query = ''; + $scope.current.refresh = 0; + $scope.current.hide = 2; + } + if ($scope.current.type === 'datasource') { $scope.current.query = $scope.datasourceTypes[0].value; $scope.current.regex = ''; diff --git a/public/app/features/templating/partials/editor.html b/public/app/features/templating/partials/editor.html index fc387ff44cf..19f9c25715b 100644 --- a/public/app/features/templating/partials/editor.html +++ b/public/app/features/templating/partials/editor.html @@ -152,6 +152,14 @@ +
+
Constant options
+
+ Value + +
+
+
Query Options
@@ -214,7 +222,7 @@
-
+
Selection Options