43 Commits

Author SHA1 Message Date
e5bf3027fc Refactor: Move sql_engine to sub package of tsdb (#18991)
this way importing the tsdb package does not come with xorm dependencies
2019-09-10 15:50:04 -04:00
a0bb01103e MySQL/Postgres/MSSQL: Add parsing for day, weeks and year intervals in macros (#13086)
closes #11431
2019-05-30 09:58:29 +02:00
54c1bf0cc9 Chore: a bit of spring cleaning (#16710)
* Chore: use early return technic everywhere

And enable "indent-error-flow" revive rule

* Chore: remove if-return rule from revive config

* Chore: improve error messages

And enable "error-strings" revive rule

* Chore: enable "error-naming" revive rule

* Chore: make linter happy

* Chore: do not duplicate gofmt execution

* Chore: make linter happy

* Chore: address the pull review comments
2019-04-23 11:24:47 +03:00
3801a75131 FIxed syntaxis mistake unixEpochNanoFrom and unixEpochNanoTo 2019-01-03 22:25:10 +01:00
ed6782402b Merge remote-tracking branch 'upstream/master' into nanosecond-postgresql 2019-01-03 21:48:10 +01:00
9105625f24 Added unixEpochNanoTo and unixEpochNanoFrom macros to postgresql 2019-01-03 21:31:47 +01:00
4d8d2a9690 Renamed unixEpochFilterNano to unixEpochNanoFilter 2019-01-03 20:40:17 +01:00
4c51e8df20 Don't cut off subsecond precision for postgres macros
Change time format to RFC3339Nano for $__timeFilter, $__timeFrom and
$__timeTo macros
2019-01-02 23:38:09 +01:00
1a67a8db80 Nanosecond timestamp support postgresql 2019-01-02 23:00:21 +01:00
624e5e5b3d let each sql datasource handle timeFrom and timeTo macros 2018-11-30 14:30:02 +01:00
94d6d51726 move timeFrom, timeTo, unixEpochFrom and unixEpochTo macros to sql_engine 2018-10-02 20:19:34 +02:00
0254a29e35 Interpolate $__interval in backend for alerting with sql datasources (#13156)
add support for interpolate $__interval and  $__interval_ms in sql datasources
2018-09-13 16:51:00 +02:00
313a8bd033 Merge pull request #12891 from svenklemm/unixepochgroup
add $__unixEpochGroup and $__unixEpochGroupAlias to sql datasources
2018-08-17 14:41:33 +02:00
74077be19e Merge pull request #12680 from svenklemm/timebucket
[postgres] add timescaledb option to postgres datasource
2018-08-14 12:12:43 +02:00
3955133f7e Don't pass datasource to newPostgresMacroEngine 2018-08-14 09:15:24 +02:00
3552a4cb86 refactor timescaledb handling in MacroEngine 2018-08-14 08:47:33 +02:00
bfe28ee061 Add $__unixEpochGroup macro to postgres datasource 2018-08-13 12:08:14 +02:00
d81a23becf Refactor setting fillmode
This adds SetupFillmode to the tsdb package to be used by the sql
datasources.
2018-08-12 10:51:58 +02:00
d2984f3b0f fix rebase error 2018-08-09 10:14:14 +02:00
c3aad10047 change timescaledb to checkbox instead of select 2018-08-09 10:05:35 +02:00
b987aee7cf add timescaledb option to postgres datasource
This adds an option to the postgres datasource config for
timescaledb support. When set to auto it will check for
timescaledb when testing the datasource.

When this option is enabled the $__timeGroup macro will
use the time_bucket function from timescaledb to group
times by an interval.

This also passes the datasource edit control to testDatasource
to allow for setting additional settings, this might be useful
for other datasources aswell which have optional or version
dependant features which can be queried.
2018-08-09 10:05:35 +02:00
ee7602ec1f change fillmode from last to previous 2018-08-07 21:01:41 +02:00
bfc66a7ed0 add fillmode "last" to sql datasource
This adds a new fill mode last (last observation carried forward) for grafana
to the sql datasources. This fill mode will fill in the last seen value in a
series when a timepoint is missing or NULL if no value for that series has
been seen yet.
2018-08-02 20:35:09 +02:00
dc22e24642 add compatibility code to handle pre 5.3 usage 2018-08-01 15:06:18 +02:00
42f1892826 Add $__timeGroupAlias to postgres macros 2018-08-01 09:03:34 +02:00
43295f9c18 remove alias from postgres $__timeGroup macro 2018-08-01 08:50:19 +02:00
2f3851b915 postgres: use new sql engine 2018-07-26 18:10:17 +02:00
c2c22c142b [postgres] fix timeGroup macro rounding (#12468)
* fix timeGroup tests to check for correct grouping

* do explicit floor rounding in $__timeGroup macro

* fix typo in comments
2018-07-01 06:55:46 -07:00
5dc36afe71 calculate datetime for timeFrom and timeTo macro in go 2018-04-16 23:02:24 +02:00
a2a7d3d436 add GetFromAsTimeUTC and GetToAsTimeUTC and use them in timeFilter macro 2018-04-16 19:38:35 +02:00
6d3da9a73d remove postgresversion and convert unix timestamp in go 2018-04-15 22:14:13 +02:00
9b61ffb48a make timefilter macro aware of pg version 2018-04-15 18:38:20 +02:00
a86ee304ff tsdb: remove unnecessary type casts in sql data sources macro engines 2018-04-12 19:08:35 +02:00
f5586b1270 tsdb: sql data sources should handle time ranges before epoch start correctly 2018-04-12 18:53:12 +02:00
113bfb3d3e don't convert to uint64 2018-04-09 13:28:32 +02:00
f1ba9137c0 remove spaces around arguments before calling macro expansion 2018-03-02 19:20:30 +01:00
e2a3590d8b allow optional 3rd argument to timeGroup to control filling missing
values
2017-12-10 09:59:33 +01:00
b6df91d56b pass Query to MacroEngine Interpolate 2017-12-08 23:30:33 +01:00
ce809de1ed postgres: change $__timeGroup macro to include "AS time" column alias (#10119)
* change $__timeGroup macro to include column alias

* update docs and help text for $__timeGroup macro
2017-12-08 15:14:10 +01:00
108f582ec4 sync documentation, add remark about to_timestamp and redshift (#9841) 2017-11-14 11:33:55 +01:00
34da0711ab add __timeGroup macro for mysql (#9596)
* add __timeGroup macro for mysql

* put example __timeGroup query in frontend help

* do __timeGroup interval parsing in go similar to mysql

* ignore whitespace around interval
2017-10-27 11:26:25 +02:00
b2d880c6de modify $__timeGroup macro so it can be used in select clause (#9527)
* modify $__timeGroup macro so it can be used in select clause

* fix $__interval_ms for postgres datasource

* use $__timeGroup macro in documentation

* fix annotation template query
remove title since its no longer used and add tags instead

* change __timeFilter macro to work on postgresql < 8.1 and redshift
2017-10-18 18:10:01 +02:00
d1c9760fa8 Postgres Data Source (#9475)
* add postgresql datasource

* add rest of files for postgres datasource

* fix timeseries query, remove unused code

* consistent naming, refactoring

* s/mysql/postgres/

* s/mysql/postgres/

* couple more tests

* tests for more datatypes

* fix macros for postgres

* add __timeSec macro

* add frontend for postgres datasource

* adjust documentation

* fix formatting

* add proper plugin description

* merge editor changes from mysql

* port changes from mysql datasource

* set proper defaultQuery for postgres

* add time_sec to timeseries query
accept int for value for timeseries query

* revert allowing time_sec and handle int or float values as unix
timestamp for "time" column

* fix tslint error

* handle decimal values in timeseries query

* allow setting sslmode for postgres datasource

* use type switch for handling data types

* fix value for timeseries query

* refactor timeseries queries to make them more flexible

* remove debug statement from inner loop in type conversion

* use plain for loop in getTypedRowData

* fix timeseries queries

* adjust postgres datasource to tsdb refactoring

* adjust postgres datasource to frontend changes

* update lib/pq to latest version

* move type conversion to getTypedRowData

* handle address types cidr, inet and macaddr

* adjust response parser and docs for annotations

* convert unknown types to string

* add documentation for postgres datasource

* add another example query with metric column

* set more helpful default query

* update help text in query editor

* handle NULL in value column of timeseries query

* add __timeGroup macro

* add test for __timeGroup macro

* document __timeGroup and set proper default query for annotations

* fix typos in docs

* add postgres to list of datasources

* add postgres to builtInPlugins

* mysql: refactoring as prep for merging postgres

Refactors out the initialization of the xorm engine and the query logic
for an sql data source.

* mysql: rename refactoring + test update

* postgres:refactor to use SqlEngine(same as mysql)

Refactored to use a common base class with the MySql data source.

Other changes from the original PR:
- Changed time column to be time_sec to allow other time units in the
future and to be the same as MySQL
- Changed integration test to test the main Query method rather than
the private transformToTable method
- Changed the __timeSec macro name to __timeEpoch
- Renamed PostgresExecutor to PostgresQueryEndpoint

Fixes #9209 (the original PR)

* postgres: encrypt password on config page

With some other cosmetic changes to the config page:
- placeholder texts
- reset button for the password after it has been encrypted.
- default value for the sslmode field.

* postgres: change back col name to time from time_sec

* postgres mysql: remove annotation title

Title has been removed from annotations

* postgres: fix images for docs page

* postgres mysql: fix specs
2017-10-10 15:19:14 +02:00