Merge pull request #12891 from svenklemm/unixepochgroup

add $__unixEpochGroup and $__unixEpochGroupAlias to sql datasources
This commit is contained in:
Marcus Efraimsson
2018-08-17 14:41:33 +02:00
committed by GitHub
15 changed files with 704 additions and 47 deletions

View File

@@ -57,6 +57,8 @@ Macros:
by setting fillvalue grafana will fill in missing values according to the interval
fillvalue can be either a literal value, NULL or previous; previous will fill in the previous seen value or NULL if none has been seen yet
- $__timeGroupAlias(column, '5m'[, fillvalue]) -> CAST(ROUND(DATEDIFF(second, '1970-01-01', column)/300.0, 0) as bigint)*300 AS [time]
- $__unixEpochGroup(column,'5m') -> FLOOR(column/300)*300
- $__unixEpochGroupAlias(column,'5m') -> FLOOR(column/300)*300 AS [time]
Example of group by and order by with $__timeGroup:
SELECT

View File

@@ -57,6 +57,8 @@ Macros:
by setting fillvalue grafana will fill in missing values according to the interval
fillvalue can be either a literal value, NULL or previous; previous will fill in the previous seen value or NULL if none has been seen yet
- $__timeGroupAlias(column,'5m') -> cast(cast(UNIX_TIMESTAMP(column)/(300) as signed)*300 as signed) AS "time"
- $__unixEpochGroup(column,'5m') -> column DIV 300 * 300
- $__unixEpochGroupAlias(column,'5m') -> column DIV 300 * 300 AS "time"
Example of group by and order by with $__timeGroup:
SELECT

View File

@@ -57,6 +57,8 @@ Macros:
by setting fillvalue grafana will fill in missing values according to the interval
fillvalue can be either a literal value, NULL or previous; previous will fill in the previous seen value or NULL if none has been seen yet
- $__timeGroupAlias(column,'5m') -> (extract(epoch from column)/300)::bigint*300 AS "time"
- $__unixEpochGroup(column,'5m') -> floor(column/300)*300
- $__unixEpochGroupAlias(column,'5m') -> floor(column/300)*300 AS "time"
Example of group by and order by with $__timeGroup:
SELECT