diff --git a/.circleci/deploy-docs.sh b/.circleci/deploy-docs.sh index ab919f2..e497ad0 100755 --- a/.circleci/deploy-docs.sh +++ b/.circleci/deploy-docs.sh @@ -10,15 +10,15 @@ set -o pipefail echo "current dir: $(pwd)" # Setup git env -git config --global user.email $CI_GIT_EMAIL -git config --global user.name $CI_GIT_USER +git config --global user.email "$CI_GIT_EMAIL" +git config --global user.name "$CI_GIT_USER" echo "git user is $CI_GIT_USER ($CI_GIT_EMAIL)" -git checkout -b $GH_PAGES_BRANCH -rm -rf * || true +git checkout -b "$GH_PAGES_BRANCH" +rm -rf ./* || true mv ../gh-pages/docs/site/* ./ git add --force . git commit -m "build docs from commit ${CIRCLE_SHA1:0:7} (branch $CIRCLE_BRANCH)" git log -n 3 -git push origin $GH_PAGES_BRANCH --force +git push origin "$GH_PAGES_BRANCH" --force diff --git a/.circleci/make-release.sh b/.circleci/make-release.sh index f972d86..aeecab7 100755 --- a/.circleci/make-release.sh +++ b/.circleci/make-release.sh @@ -8,13 +8,13 @@ set -o errexit set -o pipefail # Setup git env -git config --global user.email $CI_GIT_EMAIL -git config --global user.name $CI_GIT_USER +git config --global user.email "$CI_GIT_EMAIL" +git config --global user.name "$CI_GIT_USER" echo "git user is $CI_GIT_USER ($CI_GIT_EMAIL)" -RELEASE_VER=$(echo $CIRCLE_TAG | grep -Po "(?<=v)[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)") +RELEASE_VER=$(echo "$CIRCLE_TAG" | grep -Po "(?<=v)[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)") -if [ -z $RELEASE_VER ]; then +if [ -z "$RELEASE_VER" ]; then echo "No release version provided" exit 1 fi @@ -36,7 +36,7 @@ git add --force dist/ git commit -m "release $RELEASE_VER" RELEASE_COMMIT_HASH=$(git log -n 1 | grep -Po "(?<=commit )[0-9a-z]{40}") -echo $RELEASE_COMMIT_HASH +echo "$RELEASE_COMMIT_HASH" # Push release branch -git push origin $RELEASE_BRANCH +git push origin "$RELEASE_BRANCH" diff --git a/.codespell_ignore b/.codespell_ignore new file mode 100644 index 0000000..87b3610 --- /dev/null +++ b/.codespell_ignore @@ -0,0 +1 @@ +hist diff --git a/docs/sources/reference/functions.md b/docs/sources/reference/functions.md index be6305f..fe7e580 100644 --- a/docs/sources/reference/functions.md +++ b/docs/sources/reference/functions.md @@ -1,6 +1,23 @@ Functions reference =================== +## Functions Variables + +There are some built-in template variables available for using in functions: + +- `$__range_ms` - panel time range in ms +- `$__range_s` - panel time range in seconds +- `$__range` - panel time range, string representation (`30s`, `1m`, `1h`) +- `$__range_series` - invoke function over all series values + +Examples: +``` +groupBy($__range, avg) +percentile($__range_series, 95) - 95th percentile over all values +``` + +--- + ## Transform @@ -10,7 +27,7 @@ Functions reference groupBy(interval, function) ``` -Takes each timeseries and consolidate its points falled in given _interval_ into one point using _function_, which can be one of: _avg_, _min_, _max_, _median_. +Takes each timeseries and consolidate its points fallen in the given _interval_ into one point using _function_, which can be one of: _avg_, _min_, _max_, _median_. Examples: ``` @@ -124,7 +141,7 @@ Replaces `null` values with N aggregateBy(interval, function) ``` -Takes all timeseries and consolidate all its points falled in given _interval_ into one point using _function_, which can be one of: _avg_, _min_, _max_, _median_. +Takes all timeseries and consolidate all its points fallen in the given _interval_ into one point using _function_, which can be one of: _avg_, _min_, _max_, _median_. Examples: ``` @@ -142,6 +159,20 @@ This will add metrics together and return the sum at each datapoint. This method --- +### _percentile_ +``` +percentile(interval, N) +``` +Takes all timeseries and consolidate all its points fallen in the given _interval_ into one point by Nth percentile. + +Examples: +``` +percentile(1h, 99) +percentile($__range_series, 95) - 95th percentile over all values +``` + +--- + ### _average_ ``` average(interval) diff --git a/src/datasource-zabbix/components/FunctionEditor.tsx b/src/datasource-zabbix/components/FunctionEditor.tsx index 285a88a..c6ae673 100644 --- a/src/datasource-zabbix/components/FunctionEditor.tsx +++ b/src/datasource-zabbix/components/FunctionEditor.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { FunctionDescriptor, FunctionEditorControlsProps, FunctionEditorControls } from './FunctionEditorControls'; // @ts-ignore -import { PopperController, Popper } from '@grafana/ui'; +import { PopoverController, Popover } from '@grafana/ui'; interface FunctionEditorProps extends FunctionEditorControlsProps { func: FunctionDescriptor; @@ -66,12 +66,12 @@ class FunctionEditor extends React.PureComponent + {(showPopper, hidePopper, popperProps) => { return ( <> {this.triggerRef && ( - ); }} - + ); } } diff --git a/src/datasource-zabbix/constants.js b/src/datasource-zabbix/constants.js index af3c8d1..79d2edc 100644 --- a/src/datasource-zabbix/constants.js +++ b/src/datasource-zabbix/constants.js @@ -37,3 +37,5 @@ export const TRIGGER_SEVERITY = [ /** Minimum interval for SLA over time (1 hour) */ export const MIN_SLA_INTERVAL = 3600; + +export const RANGE_VARIABLE_VALUE = 'range_series'; diff --git a/src/datasource-zabbix/dataProcessor.js b/src/datasource-zabbix/dataProcessor.js index 4ff8c9e..e69ceda 100644 --- a/src/datasource-zabbix/dataProcessor.js +++ b/src/datasource-zabbix/dataProcessor.js @@ -1,9 +1,8 @@ import _ from 'lodash'; import * as utils from './utils'; -import ts from './timeseries'; +import ts, { groupBy_perf as groupBy } from './timeseries'; let downsampleSeries = ts.downsample; -let groupBy = ts.groupBy_perf; let groupBy_exported = (interval, groupFunc, datapoints) => groupBy(datapoints, interval, groupFunc); let sumSeries = ts.sumSeries; let delta = ts.delta; diff --git a/src/datasource-zabbix/datasource.js b/src/datasource-zabbix/datasource.js index 294ab32..a2b1d06 100644 --- a/src/datasource-zabbix/datasource.js +++ b/src/datasource-zabbix/datasource.js @@ -132,6 +132,9 @@ export class ZabbixDatasource extends DataSourceApi { let timeFrom = Math.ceil(dateMath.parse(options.range.from) / 1000); let timeTo = Math.ceil(dateMath.parse(options.range.to) / 1000); + // Add range variables + options.scopedVars = Object.assign({}, options.scopedVars, utils.getRangeScopedVars(options.range)); + // Prevent changes of original object let target = _.cloneDeep(t); diff --git a/src/datasource-zabbix/partials/annotations.editor.html b/src/datasource-zabbix/partials/annotations.editor.html index 6e2e495..16453e5 100644 --- a/src/datasource-zabbix/partials/annotations.editor.html +++ b/src/datasource-zabbix/partials/annotations.editor.html @@ -1,5 +1,4 @@
-
Filter Triggers
Group @@ -36,8 +35,9 @@
+
Options
- Minimum severity + Minimum severity