diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 000000000..9e0a6c2e7 --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,11 @@ +[bumpversion] +commit = True +tag = False +current_version = 2.0.2 + +[bumpversion:file:package.json] + +[bumpversion:file:src/plugin.json] + +[bumpversion:file:dist/plugin.json] + diff --git a/.gitignore b/.gitignore index 8d0326886..5be9566dc 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ npm-debug.log yarn.lock package-lock.json .cache +.release_env \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index bcb3587a9..e1f1add91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +# 2.0.2 (2020-07-06) + +## Enhancements: +* add alerts support for Windows and MacOSX +* improve ad-hoc filters for query field values as `SELECT DISTINCT field AS value FROM db.table LIMIT 300`, https://github.com/Vertamedia/clickhouse-grafana/pull/222 +* add ability to multiple JOIN parsing https://github.com/Vertamedia/clickhouse-grafana/pull/206 +* multiple improvements for docker-compose environments, add automatic dashboards and datasource provisions which help to reproduce most of the corner cases which happens in Grafana + ClickHouse + +## Fixes: +* apply a workaround for UTC timezone for Date and DateTime columns in grafana dashboards https://github.com/Vertamedia/clickhouse-grafana/issues/117 +* clear documentation about timestamp term for $from and $to https://github.com/Vertamedia/clickhouse-grafana/issues/115 +* fix AST parsing corner case in `WHERE [test, 'test']` "," was skipped, fix ah-doc ast FROM recursive parsing https://github.com/Vertamedia/clickhouse-grafana/issues/99 +* fix corner cases for table functions parsing when adhoc filter applied https://github.com/Vertamedia/clickhouse-grafana/issues/130 +* fix multiple grammar issues in README.md +* fix convert rules for Float, Decimal columns from Clickhouse to Grafana Table plugin https://github.com/Vertamedia/clickhouse-grafana/issues/199 +* fix corner cases when Grafana Template variable value represented as array of strings https://github.com/Vertamedia/clickhouse-grafana/issues/169 +* fix AST parsing corner cases for $macroFunctions correct position for FROM statement https://github.com/Vertamedia/clickhouse-grafana/issues/187 + # 2.0.1 (2020-06-19) ## Fixes: diff --git a/README.md b/README.md index 14c5c206f..3ef41683c 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Install from [grafana.net](https://grafana.net/plugins/vertamedia-clickhouse-dat OR -Copy files to your [Grafana plugin directory](http://docs.grafana.org/plugins/installation/#grafana-plugin-directory). Restart Grafana, check datasources list at http://your.grafana.instance/datasources/new, choose ClickHouse option. +Copy files to your [Grafana plugin directory](http://docs.grafana.org/plugins/installation/#grafana-plugin-directory). Restart Grafana, check data sources list at http://your.grafana.instance/datasources/new, choose ClickHouse option. ### Features: @@ -38,7 +38,7 @@ Using of [CHProxy](https://github.com/Vertamedia/chproxy) will bring additional to provide secure access. * Limit concurrency and execution time for requests from `Grafana` as shown [here](https://github.com/Vertamedia/chproxy#spread-selects-from-reporting-apps-among-cluster-nodes) to prevent `ClickHouse` overloading from `Grafana`. -* Protection against request bursts for dashboards with numerous graphs. `CHProxy` allows to queue requests and execute them sequentially. +* Protection against request bursts for dashboards with numerous graphs. `CHProxy` allows queueing requests and execute them sequentially. To learn more - read about params `max_queue_size` and `max_queue_time` at [CHProxy](https://github.com/Vertamedia/chproxy) page. * Response caching for the most frequent queries as shown [here](https://github.com/Vertamedia/chproxy#caching). `Caching` will protect `ClickHouse` from excessive refreshes and will be optimal option for popular dashboards. @@ -51,14 +51,14 @@ Query setup interface: ![query editor image](https://user-images.githubusercontent.com/2902918/32498037-2e9df438-c3d7-11e7-90de-73957c20cf6d.png) -First row `FROM` contains two options: database and table. Table values depends on selected database. +First row `FROM` contains two options: database and table. Table values depends on a selected database. Second row contains selectors for time filtering: * Column:Date ([EventDate](https://clickhouse.yandex/reference_en.html#Date)) * Column:DateTime ([DateTime](https://clickhouse.yandex/reference_en.html#DateTime)) or Column:TimeStamp (UInt32). > Plugin will try to detect date columns automatically -> Column:DateTime or Column:TimeStamp are required for time-based macros and functions, because all analytics is based on these values +> `Column:DateTime` or `Column:TimeStamp` are required for time-based macros and functions because all analytics based on these values Button `Go to Query` is just a toggler to Raw SQL Editor @@ -69,7 +69,7 @@ Raw Editor allows custom SQL queries to be written: ![raw editor image](https://user-images.githubusercontent.com/2902918/32843338-337f2efc-ca28-11e7-9bde-ec65faa3cdc9.png) -Raw Editor allows to type queries, get info about functions and macroses, format queries as Clickhouse do. +Raw Editor allows typing queries, get info about functions and macros, format queries as Clickhouse do. Under the Editor you can find a raw query (all macros and functions have already been replaced) which will be sent directly to ClickHouse. ### Macros @@ -77,14 +77,14 @@ Under the Editor you can find a raw query (all macros and functions have already Plugin supports the following marcos: * $table - replaced with selected table name from Query Builder -* $dateCol - replaced with Date:Col value from Query Builder -* $dateTimeCol - replaced with Column:DateTime or Column:TimeStamp value from Query Builder +* $dateCol - replaced with `Column:Date` value from Query Builder +* $dateTimeCol - replaced with `Column:DateTime` or `Column:TimeStamp` value from Query Builder * $from - replaced with (timestamp with ms)/1000 value of UI selected "Time Range:From" * $to - replaced with (timestamp with ms)/1000 value of UI selected "Time Range:To" -* $interval - replaced with selected "Group by time interval" value (as a number of seconds) +* $interval - replaced with selected "Group by a time interval" value (as a number of seconds) * $timeFilter - replaced with currently selected "Time Range". - Requires Column:Date and Column:DateTime or Column:TimeStamp to be selected -* $timeFilterByColumn($column) - replaced with currently selected "Time Range" for column passed as `$column` argument. Use it in queries or query variables as `...WHERE $timeFilterColumn($column)...` or `...WHERE $timeFilterColumn(created_at)...`. + Requires Column:Date and Column:DateTime or Column:TimeStamp to be selected. +* $timeFilterByColumn($column) - replaced with currently selected "Time Range" for a column passed as `$column` argument. Use it in queries or query variables as `...WHERE $timeFilterColumn($column)...` or `...WHERE $timeFilterColumn(created_at)...`. * $timeSeries - replaced with special ClickHouse construction to convert results as time-series data. Use it as "SELECT $timeSeries...". * $unescape - unescapes variable value by removing single quotes. Used for multiple-value string variables: "SELECT $unescape($column) FROM requests WHERE $unescape($column) = 5" * $adhoc - replaced with a rendered ad-hoc filter expression, or "1" if no ad-hoc filters exist. Since ad-hoc applies automatically only to outer queries the macros can be used for filtering in inner queries. @@ -93,12 +93,12 @@ A description of macros is available by typing their names in Raw Editor ### Functions -Functions are just templates of SQL queries and you can check the final query at [Raw SQL Editor mode](https://github.com/Vertamedia/clickhouse-grafana/blob/master/README.md#raw-sql-editor). -If some additional complexity is needed - just copy raw sql into Raw Editor and make according changes. Remember that macros are still available to use. +Functions are just templates of SQL queries, and you can check the final query at [Raw SQL Editor mode](https://github.com/Vertamedia/clickhouse-grafana/blob/master/README.md#raw-sql-editor). +If you need some additional complexity - just copy raw sql into Raw Editor and make according changes. Remember that macros are still available to use. There are some limits in function use because of poor query analysis: * Column:Date and Column:DateTime or Column:TimeStamp must be set in Query Builder -* Query must begins from function name +* Query must begin from function name * Only one function can be used per query Plugin supports the following functions: @@ -125,7 +125,7 @@ FROM FROM requests WHERE ((EventDate >= toDate(1482796747)) AND (EventDate <= toDate(1482853383))) AND ((EventTime >= toDateTime(1482796747)) AND (EventTime <= toDateTime(1482853383))) GROUP BY t - ORDER BY t ASC + ORDER BY t ) ``` --- @@ -157,11 +157,11 @@ FROM t, OSName ORDER BY - t ASC, - OSName ASC + t, + OSName ) GROUP BY t -ORDER BY t ASC +ORDER BY t ``` This will help to build the next graph: @@ -298,7 +298,7 @@ To use time range dependent macros like `timeFilterByColumn($column)` in your qu SELECT event_name FROM event_log WHERE $timeFilterByColumn(time_column) ``` -Another option is a query that can create a key/value variable. The query should return two columns that are named `__text` and `__value`. The `__text` column value should be unique (if it is not unique then the first value is used). The options in the dropdown will have a text and value that allows you to have a friendly name as text and an id as the value. An example query with `hostname` as the text and `id` as the value: +Another option is a query that can create a key/value variable. The query should return two columns that are named `__text` and `__value`. The `__text` column value should be unique (if it is not unique then the first value will use). The options in the dropdown will have a text and value that allows you to have a friendly name as text and an id as the value. An example query with `hostname` as the text and `id` as the value: ```sql SELECT hostname AS __text, id AS __value FROM host @@ -312,10 +312,10 @@ SELECT hostname FROM host WHERE region IN ($region) ### Conditional Predicate -If you are using templating to feed your predicate , you will face performance degradation when everything is selected as the predicate is not necessary. It's also true for textbox when nothing is enter , you have to write specific sql code to handle that. +If you are using templating to feed your predicate, you will face performance degradation when everything will select as the predicate, and it's not necessary. It's also true for textbox when nothing is enter, you have to write specific sql code to handle that. To workaround this issue a new macro $conditionalTest(SQL Predicate,$variable) can be used to remove some part of the query. -If the variable is type query with all selected or if the variable is a textbox with nothing enter , then the SQL Predicate is not included in the generated query. +If the variable is type query with all selected or if the variable is a textbox with nothing enter, then the SQL Predicate is not include in the generated query. To give an example: with 2 variables @@ -335,7 +335,7 @@ with 2 variables ORDER BY t ``` - if the $var is all selected and the $text is empty , the query will be converted into + if the `$var` is selected as "All" value, and the `$text` variable is empty, the query will be converted into: ```sql SELECT @@ -346,7 +346,7 @@ with 2 variables GROUP BY t ORDER BY t ``` - If $var have some element selected and the $text has at least one char , the query will be converted into + If the `$var` template variable have select some elements, and the `$text` template variable has at least one char, the query will be converted into: ```sql SELECT @@ -362,9 +362,9 @@ with 2 variables ### Working with panels -#### Piechart (https://grafana.com/plugins/grafana-piechart-panel) +#### Pie Chart (https://grafana.com/plugins/grafana-piechart-panel) -Remember that piechart plugin is not welcome for using in grafana - see https://grafana.com/blog/2015/12/04/friends-dont-let-friends-abuse-pie-charts +Remember that pie chart plugin is not welcome for using in grafana - see https://grafana.com/blog/2015/12/04/friends-dont-let-friends-abuse-pie-charts ![top5things](https://cloud.githubusercontent.com/assets/2902918/25392562/9fadb202-29e1-11e7-95ca-5b0d2921c592.png) @@ -396,7 +396,7 @@ LIMIT 5,10000000000000 /* select some ridiculous number after first 5 */ #### Table (https://grafana.com/plugins/table) -There are no any tricks in displaying time-series data. To print summary data, omit time column, and format the result as "Table". +There are don't contain any tricks in displaying time-series data. To print summary data, omit time column, and format the result as "Table". ```sql SELECT @@ -413,11 +413,11 @@ ORDER BY ![vertical histogram](https://cloud.githubusercontent.com/assets/2902918/25392561/9f3777e0-29e1-11e7-8b23-2ea9ae46a029.png) -To make vertical histogram from graph panel we will need to edit some settings: +To make the vertical histogram from graph panel we will need to edit some settings: * Display -> Draw Modes -> Bars * Axes -> X-Axis -> Mode -> Series -And use next query: +You can use next query: ``` $columns( Size, @@ -454,7 +454,7 @@ If you are using [geohash](https://github.com/grafana/worldmap-panel#geohashes-a ![Format](https://user-images.githubusercontent.com/2902918/32726398-96793438-c881-11e7-84b8-26e82dbdb40c.png) -And make following query with `Table` formatting: +You can make following query with `Table` formatting: ![geohash-query](https://user-images.githubusercontent.com/2902918/32726399-96a01e86-c881-11e7-9368-61207bae72fd.png) @@ -462,11 +462,12 @@ And make following query with `Table` formatting: ### Ad-hoc filters If there is an Ad-hoc variable, plugin will fetch all columns of all tables of all databases (except system database) as tags. -So in dropdown menu will be options like `database.table.column`. If the default database is specified, it will only fetch tables and columns from that database, and the dropdown menu will have option like `table.column`. If there are ENUM columns, -plugin will fetch their options and use them as tag values. +So in dropdown menu will be options like `database.table.column`. If you specify the default database it will only fetch tables and columns from that database, and the dropdown menu will have an option like `table.column`. +If there are ENUM columns, the plugin will fetch their options and use them as tag values. +Also, plugin will fetch 300 unique values for fields with other types. Plugin will apply Ad-hoc filters to all queries on the dashboard if their settings `$database` and `$table` are the same -as Ad-hoc's `database.table`. If the ad-hoc filter doesn't specify table, it will apply to all queries regardless of the table. +as `database.table` specified in Ad-hoc control. If the ad-hoc filter doesn't specify a table, it will apply to all queries regardless of the table. This is useful if the dashboard contains queries to multiple different tables. ![ad-hoc](https://user-images.githubusercontent.com/2902918/37139531-ed67f222-22b6-11e8-8815-9268850f16fb.png) @@ -475,11 +476,11 @@ This is useful if the dashboard contains queries to multiple different tables. > There are no option to use IN operator for Ad-hoc filters due to Grafana limitations -There may be cases when CH contains too many tables and columns so their fetching could take notably amount of time. And if you need +There may be cases when CH contains too many tables and columns so their fetching could take notably amount of time. So, if you need to have multiple dashboards with different databases using of `default database` won't help. The best way to solve this will be to have parametrized -ad-hoc variable in dashboard settings. Currently it's not supported by Grafana interface (see [issue](https://github.com/grafana/grafana/issues/13109)). -As a temporary workaround, plugin will try to look for variable with name `adhoc_query_filter` and if it exists will use it's value as query to fetch columns. -To do so we recommend to create some `constant` variable with name `adhoc_query_filter` and set value similar to following: +ad-hoc variable in dashboard settings. Currently, it's not supported by Grafana interface (see [issue](https://github.com/grafana/grafana/issues/13109)). +As a temporary workaround, plugin will try to look for variable with name `adhoc_query_filter` and if it exists will use its value as query to fetch columns. +For this purpose we recommend creating some variable `constant` with the name `adhoc_query_filter` and set the value similar to the following one: ``` SELECT database, table, name, type FROM system.columns WHERE table='myTable' ORDER BY database, table ``` @@ -497,7 +498,7 @@ SELECT ClientID FROM events WHERE EventTime > toDateTime($from) AND EventTime < ### Configure the Datasource with Provisioning It’s now possible to configure datasources using config files with Grafana’s provisioning system. -You can read more about how it works and all the settings you can set for datasources on the [provisioning docs page](http://docs.grafana.org/administration/provisioning/#datasources) +You can read more about how it works and all the settings you can set for datasources on the [provisioning docs page](http://docs.grafana.org/administration/provisioning/#datasources). Here are some provisioning example: ``` @@ -529,15 +530,15 @@ datasources: defaultDatabase: ``` -Some settings and security params are the same for all datasources. You can find them [here](http://docs.grafana.org/administration/provisioning/#example-datasource-config-file) +Some settings and security params are the same for all datasources. You can find them [here](http://docs.grafana.org/administration/provisioning/#example-datasource-config-file). ### FAQ > Why time series last point is not the real last point? -Plugin extrapolates last datapoint if timerange is `last N` to avoid displaying of constantly decreasing graphs -when timestamp in table is rounded to minute or bigger. +Plugin extrapolates last datapoint if time range is `last N` to avoid displaying of constantly decreasing graphs +when timestamp in a table is rounded to minute or bigger. If it so then in 99% cases last datapoint will be much less than previous one, because last minute is not finished yet. That's why plugin checks prev datapoints and tries to predict last datapoint value just as it was already written into db. This behavior could be turned off via "Extrapolation" checkbox in query editor. @@ -572,20 +573,20 @@ ORDER BY (EventDate, EventTime, Type, OS, Protocol, UserName) PARTITION BY toYYYYMM(EventDate); ``` -> Why no alerts support? +> What about alerts support? Alerts feature requires changes in `Grafana`'s backend, which can be extended only for Grafana 6.5+. `Grafana`'s maintainers are working on this feature. -Current alerts support for `clickhouse-grafana` datasource in alpha. +Current alerts support for `clickhouse-grafana` datasource plugin in beta and support only for amd64 architecture for Linux, MacOSX, Windows. ### Development There are following scripts defined in package.json: -- `build:prod` – production-ready build -- `build:dev` - development build (no uglify etc.) -- `build:watch` - automatically rebuilds code on change (handy while developing) -- `test` - runs test suite using Jest -- `test:watch` - runs test suite using Jest in watch mode. Automatically reruns tests on source change. +- `build:prod` – production-ready build of frontend part +- `build:dev` - development build (no uglify etc.) of frontend part +- `build:watch` - automatically rebuild frontend TypeScript+HTML part of codebase on change (handy while developing) +- `test` - runs frontend test suite using Jest +- `test:watch` - runs frontend test suite using Jest in watch mode. Automatically reruns tests on source change. Each script can be run using NPM or Yarn package managers: @@ -605,11 +606,12 @@ For test examples please see `spec` folder. We strongly encourage contributors t ### Docker-compose environment for development -This is a simple demo which mounts the current `dist` directory inside the grafana container. The grafana container is connected to the docker clickhouse database container. +This is a simple environment which mounts the current `dist` directory inside the `grafana` container. The `grafana` container connects to the docker `clickhouse` database container. +Also `grafana` container contains some datasource and dashboards installed via `/etc/grafana/provisioning/` folder. -To run the development environment: +To run the development environment install Docker and docker-compose: ```sh -docker-compose up -d +docker-compose up --no-deps -d grafana clickhouse ``` after that open http://localhost:3000/ to open grafana instance with one clickhouse datasource @@ -623,7 +625,7 @@ To develop using docker, the process looks like: 3. `docker-compose restart grafana` 4. open http://localhost:3000/ -To develop without docker, the process looks like: +To develop without build inside a docker, the development process for frontend part of code looks like: 1. change source files 2. `npm run test` 3. `npm run build:dev` @@ -634,7 +636,7 @@ To develop without docker, the process looks like: The backend builder is the docker container used to compile the golang source code into the `vertamedia-clickhouse-plugin_linux_amd64` binary in the `dist` dir. This will affect the grafana service used for running queries for alerting. The entrypoint for the go code is at `plugin.go`. -To develop using docker, the process looks like: +To develop using docker, the development process for backend part of code looks like: 1. change source files 2. `docker-compose up backend_builder` 3. `docker-compose restart grafana` @@ -653,8 +655,38 @@ The resulting alerts should look like this If you have any idea for an improvement or found a bug do not hesitate to open an issue or submit a pull request. We will appreciate any help from the community which will make working with such amazing products as ClickHouse and Grafana more convenient. -Plugin creation was inspired by great [grafana-sqldb-datasource](https://github.com/sraoss/grafana-sqldb-datasource) - +Plugin creation inspired by great [grafana-sqldb-datasource](https://github.com/sraoss/grafana-sqldb-datasource) + +### Make new release + +- fork https://github.com/Vertamedia/clickhouse-grafana and make git clone, if necessary +- look at https://github.com/Vertamedia/clickhouse-grafana/commits/master and add necessary items to [CHANGELOG.md](CHANGELOG.md) +- install Python3 and run `pip3 install -U bump2version` +- read https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token to getting value for `GITHUB_TOKEN` +- create .release_env file in root of your git working copy with following content: +```bash +#!/usr/bin/env bash +set +x +export GITHUB_LOGIN="" +export GITHUB_EMAIL="" +export GITHUB_TOKEN="" +set -xeuo pipefail +``` +- run `./release.sh` with following parameters: + - `./release.sh patch` - for minor hotfix releases + - `./release.sh minor` - for minor and backward compatible improvements releases + - `./release.sh major` - for major or backward incompatible improvements releases +- this script will run `frontend` and `backend` builders via `docker-compose` and run tests and make git commit + git push if test pass + +#### Final manual steps +- after git push to your github fork, please open new pull request between your fork and `master` branch in https://github.com/Vertamedia/clickhouse-grafana + copy/paste CHANGELOG.md items for new release to Pull Request message. +- after merge pull request in https://github.com/Vertamedia/clickhouse-grafana/, + please open https://github.com/Vertamedia/clickhouse-grafana/releases create new release or request tp somebody of [contributors](https://github.com/Vertamedia/clickhouse-grafana/graphs/contributors). +- after create new release on https://github.com/Vertamedia/clickhouse-grafana/releases, + please create new pull request in https://github.com/grafana/grafana-plugin-repository, please follow `grafana-plugin-repository` pull request message styleguide, + copy/paste CHANGELOG.md items for new release to Pull Request message. + License ------- MIT License, please see [LICENSE](https://github.com/Vertamedia/clickhouse-grafana/blob/master/LICENSE) for details. diff --git a/dist/README.md b/dist/README.md index 14c5c206f..3ef41683c 100644 --- a/dist/README.md +++ b/dist/README.md @@ -7,7 +7,7 @@ Install from [grafana.net](https://grafana.net/plugins/vertamedia-clickhouse-dat OR -Copy files to your [Grafana plugin directory](http://docs.grafana.org/plugins/installation/#grafana-plugin-directory). Restart Grafana, check datasources list at http://your.grafana.instance/datasources/new, choose ClickHouse option. +Copy files to your [Grafana plugin directory](http://docs.grafana.org/plugins/installation/#grafana-plugin-directory). Restart Grafana, check data sources list at http://your.grafana.instance/datasources/new, choose ClickHouse option. ### Features: @@ -38,7 +38,7 @@ Using of [CHProxy](https://github.com/Vertamedia/chproxy) will bring additional to provide secure access. * Limit concurrency and execution time for requests from `Grafana` as shown [here](https://github.com/Vertamedia/chproxy#spread-selects-from-reporting-apps-among-cluster-nodes) to prevent `ClickHouse` overloading from `Grafana`. -* Protection against request bursts for dashboards with numerous graphs. `CHProxy` allows to queue requests and execute them sequentially. +* Protection against request bursts for dashboards with numerous graphs. `CHProxy` allows queueing requests and execute them sequentially. To learn more - read about params `max_queue_size` and `max_queue_time` at [CHProxy](https://github.com/Vertamedia/chproxy) page. * Response caching for the most frequent queries as shown [here](https://github.com/Vertamedia/chproxy#caching). `Caching` will protect `ClickHouse` from excessive refreshes and will be optimal option for popular dashboards. @@ -51,14 +51,14 @@ Query setup interface: ![query editor image](https://user-images.githubusercontent.com/2902918/32498037-2e9df438-c3d7-11e7-90de-73957c20cf6d.png) -First row `FROM` contains two options: database and table. Table values depends on selected database. +First row `FROM` contains two options: database and table. Table values depends on a selected database. Second row contains selectors for time filtering: * Column:Date ([EventDate](https://clickhouse.yandex/reference_en.html#Date)) * Column:DateTime ([DateTime](https://clickhouse.yandex/reference_en.html#DateTime)) or Column:TimeStamp (UInt32). > Plugin will try to detect date columns automatically -> Column:DateTime or Column:TimeStamp are required for time-based macros and functions, because all analytics is based on these values +> `Column:DateTime` or `Column:TimeStamp` are required for time-based macros and functions because all analytics based on these values Button `Go to Query` is just a toggler to Raw SQL Editor @@ -69,7 +69,7 @@ Raw Editor allows custom SQL queries to be written: ![raw editor image](https://user-images.githubusercontent.com/2902918/32843338-337f2efc-ca28-11e7-9bde-ec65faa3cdc9.png) -Raw Editor allows to type queries, get info about functions and macroses, format queries as Clickhouse do. +Raw Editor allows typing queries, get info about functions and macros, format queries as Clickhouse do. Under the Editor you can find a raw query (all macros and functions have already been replaced) which will be sent directly to ClickHouse. ### Macros @@ -77,14 +77,14 @@ Under the Editor you can find a raw query (all macros and functions have already Plugin supports the following marcos: * $table - replaced with selected table name from Query Builder -* $dateCol - replaced with Date:Col value from Query Builder -* $dateTimeCol - replaced with Column:DateTime or Column:TimeStamp value from Query Builder +* $dateCol - replaced with `Column:Date` value from Query Builder +* $dateTimeCol - replaced with `Column:DateTime` or `Column:TimeStamp` value from Query Builder * $from - replaced with (timestamp with ms)/1000 value of UI selected "Time Range:From" * $to - replaced with (timestamp with ms)/1000 value of UI selected "Time Range:To" -* $interval - replaced with selected "Group by time interval" value (as a number of seconds) +* $interval - replaced with selected "Group by a time interval" value (as a number of seconds) * $timeFilter - replaced with currently selected "Time Range". - Requires Column:Date and Column:DateTime or Column:TimeStamp to be selected -* $timeFilterByColumn($column) - replaced with currently selected "Time Range" for column passed as `$column` argument. Use it in queries or query variables as `...WHERE $timeFilterColumn($column)...` or `...WHERE $timeFilterColumn(created_at)...`. + Requires Column:Date and Column:DateTime or Column:TimeStamp to be selected. +* $timeFilterByColumn($column) - replaced with currently selected "Time Range" for a column passed as `$column` argument. Use it in queries or query variables as `...WHERE $timeFilterColumn($column)...` or `...WHERE $timeFilterColumn(created_at)...`. * $timeSeries - replaced with special ClickHouse construction to convert results as time-series data. Use it as "SELECT $timeSeries...". * $unescape - unescapes variable value by removing single quotes. Used for multiple-value string variables: "SELECT $unescape($column) FROM requests WHERE $unescape($column) = 5" * $adhoc - replaced with a rendered ad-hoc filter expression, or "1" if no ad-hoc filters exist. Since ad-hoc applies automatically only to outer queries the macros can be used for filtering in inner queries. @@ -93,12 +93,12 @@ A description of macros is available by typing their names in Raw Editor ### Functions -Functions are just templates of SQL queries and you can check the final query at [Raw SQL Editor mode](https://github.com/Vertamedia/clickhouse-grafana/blob/master/README.md#raw-sql-editor). -If some additional complexity is needed - just copy raw sql into Raw Editor and make according changes. Remember that macros are still available to use. +Functions are just templates of SQL queries, and you can check the final query at [Raw SQL Editor mode](https://github.com/Vertamedia/clickhouse-grafana/blob/master/README.md#raw-sql-editor). +If you need some additional complexity - just copy raw sql into Raw Editor and make according changes. Remember that macros are still available to use. There are some limits in function use because of poor query analysis: * Column:Date and Column:DateTime or Column:TimeStamp must be set in Query Builder -* Query must begins from function name +* Query must begin from function name * Only one function can be used per query Plugin supports the following functions: @@ -125,7 +125,7 @@ FROM FROM requests WHERE ((EventDate >= toDate(1482796747)) AND (EventDate <= toDate(1482853383))) AND ((EventTime >= toDateTime(1482796747)) AND (EventTime <= toDateTime(1482853383))) GROUP BY t - ORDER BY t ASC + ORDER BY t ) ``` --- @@ -157,11 +157,11 @@ FROM t, OSName ORDER BY - t ASC, - OSName ASC + t, + OSName ) GROUP BY t -ORDER BY t ASC +ORDER BY t ``` This will help to build the next graph: @@ -298,7 +298,7 @@ To use time range dependent macros like `timeFilterByColumn($column)` in your qu SELECT event_name FROM event_log WHERE $timeFilterByColumn(time_column) ``` -Another option is a query that can create a key/value variable. The query should return two columns that are named `__text` and `__value`. The `__text` column value should be unique (if it is not unique then the first value is used). The options in the dropdown will have a text and value that allows you to have a friendly name as text and an id as the value. An example query with `hostname` as the text and `id` as the value: +Another option is a query that can create a key/value variable. The query should return two columns that are named `__text` and `__value`. The `__text` column value should be unique (if it is not unique then the first value will use). The options in the dropdown will have a text and value that allows you to have a friendly name as text and an id as the value. An example query with `hostname` as the text and `id` as the value: ```sql SELECT hostname AS __text, id AS __value FROM host @@ -312,10 +312,10 @@ SELECT hostname FROM host WHERE region IN ($region) ### Conditional Predicate -If you are using templating to feed your predicate , you will face performance degradation when everything is selected as the predicate is not necessary. It's also true for textbox when nothing is enter , you have to write specific sql code to handle that. +If you are using templating to feed your predicate, you will face performance degradation when everything will select as the predicate, and it's not necessary. It's also true for textbox when nothing is enter, you have to write specific sql code to handle that. To workaround this issue a new macro $conditionalTest(SQL Predicate,$variable) can be used to remove some part of the query. -If the variable is type query with all selected or if the variable is a textbox with nothing enter , then the SQL Predicate is not included in the generated query. +If the variable is type query with all selected or if the variable is a textbox with nothing enter, then the SQL Predicate is not include in the generated query. To give an example: with 2 variables @@ -335,7 +335,7 @@ with 2 variables ORDER BY t ``` - if the $var is all selected and the $text is empty , the query will be converted into + if the `$var` is selected as "All" value, and the `$text` variable is empty, the query will be converted into: ```sql SELECT @@ -346,7 +346,7 @@ with 2 variables GROUP BY t ORDER BY t ``` - If $var have some element selected and the $text has at least one char , the query will be converted into + If the `$var` template variable have select some elements, and the `$text` template variable has at least one char, the query will be converted into: ```sql SELECT @@ -362,9 +362,9 @@ with 2 variables ### Working with panels -#### Piechart (https://grafana.com/plugins/grafana-piechart-panel) +#### Pie Chart (https://grafana.com/plugins/grafana-piechart-panel) -Remember that piechart plugin is not welcome for using in grafana - see https://grafana.com/blog/2015/12/04/friends-dont-let-friends-abuse-pie-charts +Remember that pie chart plugin is not welcome for using in grafana - see https://grafana.com/blog/2015/12/04/friends-dont-let-friends-abuse-pie-charts ![top5things](https://cloud.githubusercontent.com/assets/2902918/25392562/9fadb202-29e1-11e7-95ca-5b0d2921c592.png) @@ -396,7 +396,7 @@ LIMIT 5,10000000000000 /* select some ridiculous number after first 5 */ #### Table (https://grafana.com/plugins/table) -There are no any tricks in displaying time-series data. To print summary data, omit time column, and format the result as "Table". +There are don't contain any tricks in displaying time-series data. To print summary data, omit time column, and format the result as "Table". ```sql SELECT @@ -413,11 +413,11 @@ ORDER BY ![vertical histogram](https://cloud.githubusercontent.com/assets/2902918/25392561/9f3777e0-29e1-11e7-8b23-2ea9ae46a029.png) -To make vertical histogram from graph panel we will need to edit some settings: +To make the vertical histogram from graph panel we will need to edit some settings: * Display -> Draw Modes -> Bars * Axes -> X-Axis -> Mode -> Series -And use next query: +You can use next query: ``` $columns( Size, @@ -454,7 +454,7 @@ If you are using [geohash](https://github.com/grafana/worldmap-panel#geohashes-a ![Format](https://user-images.githubusercontent.com/2902918/32726398-96793438-c881-11e7-84b8-26e82dbdb40c.png) -And make following query with `Table` formatting: +You can make following query with `Table` formatting: ![geohash-query](https://user-images.githubusercontent.com/2902918/32726399-96a01e86-c881-11e7-9368-61207bae72fd.png) @@ -462,11 +462,12 @@ And make following query with `Table` formatting: ### Ad-hoc filters If there is an Ad-hoc variable, plugin will fetch all columns of all tables of all databases (except system database) as tags. -So in dropdown menu will be options like `database.table.column`. If the default database is specified, it will only fetch tables and columns from that database, and the dropdown menu will have option like `table.column`. If there are ENUM columns, -plugin will fetch their options and use them as tag values. +So in dropdown menu will be options like `database.table.column`. If you specify the default database it will only fetch tables and columns from that database, and the dropdown menu will have an option like `table.column`. +If there are ENUM columns, the plugin will fetch their options and use them as tag values. +Also, plugin will fetch 300 unique values for fields with other types. Plugin will apply Ad-hoc filters to all queries on the dashboard if their settings `$database` and `$table` are the same -as Ad-hoc's `database.table`. If the ad-hoc filter doesn't specify table, it will apply to all queries regardless of the table. +as `database.table` specified in Ad-hoc control. If the ad-hoc filter doesn't specify a table, it will apply to all queries regardless of the table. This is useful if the dashboard contains queries to multiple different tables. ![ad-hoc](https://user-images.githubusercontent.com/2902918/37139531-ed67f222-22b6-11e8-8815-9268850f16fb.png) @@ -475,11 +476,11 @@ This is useful if the dashboard contains queries to multiple different tables. > There are no option to use IN operator for Ad-hoc filters due to Grafana limitations -There may be cases when CH contains too many tables and columns so their fetching could take notably amount of time. And if you need +There may be cases when CH contains too many tables and columns so their fetching could take notably amount of time. So, if you need to have multiple dashboards with different databases using of `default database` won't help. The best way to solve this will be to have parametrized -ad-hoc variable in dashboard settings. Currently it's not supported by Grafana interface (see [issue](https://github.com/grafana/grafana/issues/13109)). -As a temporary workaround, plugin will try to look for variable with name `adhoc_query_filter` and if it exists will use it's value as query to fetch columns. -To do so we recommend to create some `constant` variable with name `adhoc_query_filter` and set value similar to following: +ad-hoc variable in dashboard settings. Currently, it's not supported by Grafana interface (see [issue](https://github.com/grafana/grafana/issues/13109)). +As a temporary workaround, plugin will try to look for variable with name `adhoc_query_filter` and if it exists will use its value as query to fetch columns. +For this purpose we recommend creating some variable `constant` with the name `adhoc_query_filter` and set the value similar to the following one: ``` SELECT database, table, name, type FROM system.columns WHERE table='myTable' ORDER BY database, table ``` @@ -497,7 +498,7 @@ SELECT ClientID FROM events WHERE EventTime > toDateTime($from) AND EventTime < ### Configure the Datasource with Provisioning It’s now possible to configure datasources using config files with Grafana’s provisioning system. -You can read more about how it works and all the settings you can set for datasources on the [provisioning docs page](http://docs.grafana.org/administration/provisioning/#datasources) +You can read more about how it works and all the settings you can set for datasources on the [provisioning docs page](http://docs.grafana.org/administration/provisioning/#datasources). Here are some provisioning example: ``` @@ -529,15 +530,15 @@ datasources: defaultDatabase: ``` -Some settings and security params are the same for all datasources. You can find them [here](http://docs.grafana.org/administration/provisioning/#example-datasource-config-file) +Some settings and security params are the same for all datasources. You can find them [here](http://docs.grafana.org/administration/provisioning/#example-datasource-config-file). ### FAQ > Why time series last point is not the real last point? -Plugin extrapolates last datapoint if timerange is `last N` to avoid displaying of constantly decreasing graphs -when timestamp in table is rounded to minute or bigger. +Plugin extrapolates last datapoint if time range is `last N` to avoid displaying of constantly decreasing graphs +when timestamp in a table is rounded to minute or bigger. If it so then in 99% cases last datapoint will be much less than previous one, because last minute is not finished yet. That's why plugin checks prev datapoints and tries to predict last datapoint value just as it was already written into db. This behavior could be turned off via "Extrapolation" checkbox in query editor. @@ -572,20 +573,20 @@ ORDER BY (EventDate, EventTime, Type, OS, Protocol, UserName) PARTITION BY toYYYYMM(EventDate); ``` -> Why no alerts support? +> What about alerts support? Alerts feature requires changes in `Grafana`'s backend, which can be extended only for Grafana 6.5+. `Grafana`'s maintainers are working on this feature. -Current alerts support for `clickhouse-grafana` datasource in alpha. +Current alerts support for `clickhouse-grafana` datasource plugin in beta and support only for amd64 architecture for Linux, MacOSX, Windows. ### Development There are following scripts defined in package.json: -- `build:prod` – production-ready build -- `build:dev` - development build (no uglify etc.) -- `build:watch` - automatically rebuilds code on change (handy while developing) -- `test` - runs test suite using Jest -- `test:watch` - runs test suite using Jest in watch mode. Automatically reruns tests on source change. +- `build:prod` – production-ready build of frontend part +- `build:dev` - development build (no uglify etc.) of frontend part +- `build:watch` - automatically rebuild frontend TypeScript+HTML part of codebase on change (handy while developing) +- `test` - runs frontend test suite using Jest +- `test:watch` - runs frontend test suite using Jest in watch mode. Automatically reruns tests on source change. Each script can be run using NPM or Yarn package managers: @@ -605,11 +606,12 @@ For test examples please see `spec` folder. We strongly encourage contributors t ### Docker-compose environment for development -This is a simple demo which mounts the current `dist` directory inside the grafana container. The grafana container is connected to the docker clickhouse database container. +This is a simple environment which mounts the current `dist` directory inside the `grafana` container. The `grafana` container connects to the docker `clickhouse` database container. +Also `grafana` container contains some datasource and dashboards installed via `/etc/grafana/provisioning/` folder. -To run the development environment: +To run the development environment install Docker and docker-compose: ```sh -docker-compose up -d +docker-compose up --no-deps -d grafana clickhouse ``` after that open http://localhost:3000/ to open grafana instance with one clickhouse datasource @@ -623,7 +625,7 @@ To develop using docker, the process looks like: 3. `docker-compose restart grafana` 4. open http://localhost:3000/ -To develop without docker, the process looks like: +To develop without build inside a docker, the development process for frontend part of code looks like: 1. change source files 2. `npm run test` 3. `npm run build:dev` @@ -634,7 +636,7 @@ To develop without docker, the process looks like: The backend builder is the docker container used to compile the golang source code into the `vertamedia-clickhouse-plugin_linux_amd64` binary in the `dist` dir. This will affect the grafana service used for running queries for alerting. The entrypoint for the go code is at `plugin.go`. -To develop using docker, the process looks like: +To develop using docker, the development process for backend part of code looks like: 1. change source files 2. `docker-compose up backend_builder` 3. `docker-compose restart grafana` @@ -653,8 +655,38 @@ The resulting alerts should look like this If you have any idea for an improvement or found a bug do not hesitate to open an issue or submit a pull request. We will appreciate any help from the community which will make working with such amazing products as ClickHouse and Grafana more convenient. -Plugin creation was inspired by great [grafana-sqldb-datasource](https://github.com/sraoss/grafana-sqldb-datasource) - +Plugin creation inspired by great [grafana-sqldb-datasource](https://github.com/sraoss/grafana-sqldb-datasource) + +### Make new release + +- fork https://github.com/Vertamedia/clickhouse-grafana and make git clone, if necessary +- look at https://github.com/Vertamedia/clickhouse-grafana/commits/master and add necessary items to [CHANGELOG.md](CHANGELOG.md) +- install Python3 and run `pip3 install -U bump2version` +- read https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token to getting value for `GITHUB_TOKEN` +- create .release_env file in root of your git working copy with following content: +```bash +#!/usr/bin/env bash +set +x +export GITHUB_LOGIN="" +export GITHUB_EMAIL="" +export GITHUB_TOKEN="" +set -xeuo pipefail +``` +- run `./release.sh` with following parameters: + - `./release.sh patch` - for minor hotfix releases + - `./release.sh minor` - for minor and backward compatible improvements releases + - `./release.sh major` - for major or backward incompatible improvements releases +- this script will run `frontend` and `backend` builders via `docker-compose` and run tests and make git commit + git push if test pass + +#### Final manual steps +- after git push to your github fork, please open new pull request between your fork and `master` branch in https://github.com/Vertamedia/clickhouse-grafana + copy/paste CHANGELOG.md items for new release to Pull Request message. +- after merge pull request in https://github.com/Vertamedia/clickhouse-grafana/, + please open https://github.com/Vertamedia/clickhouse-grafana/releases create new release or request tp somebody of [contributors](https://github.com/Vertamedia/clickhouse-grafana/graphs/contributors). +- after create new release on https://github.com/Vertamedia/clickhouse-grafana/releases, + please create new pull request in https://github.com/grafana/grafana-plugin-repository, please follow `grafana-plugin-repository` pull request message styleguide, + copy/paste CHANGELOG.md items for new release to Pull Request message. + License ------- MIT License, please see [LICENSE](https://github.com/Vertamedia/clickhouse-grafana/blob/master/LICENSE) for details. diff --git a/dist/plugin.json b/dist/plugin.json index e3ac4758d..38e67664a 100644 --- a/dist/plugin.json +++ b/dist/plugin.json @@ -29,6 +29,6 @@ "url": "https://github.com/Vertamedia/clickhouse-grafana" } ], - "version": "2.0.1" + "version": "2.0.2" } } diff --git a/dist/vertamedia-clickhouse-plugin_darwin_amd64 b/dist/vertamedia-clickhouse-plugin_darwin_amd64 new file mode 100644 index 000000000..cec42beb4 Binary files /dev/null and b/dist/vertamedia-clickhouse-plugin_darwin_amd64 differ diff --git a/dist/vertamedia-clickhouse-plugin_linux_amd64 b/dist/vertamedia-clickhouse-plugin_linux_amd64 index 32b5722cd..997ccb534 100755 Binary files a/dist/vertamedia-clickhouse-plugin_linux_amd64 and b/dist/vertamedia-clickhouse-plugin_linux_amd64 differ diff --git a/dist/vertamedia-clickhouse-plugin_windows_amd64.exe b/dist/vertamedia-clickhouse-plugin_windows_amd64.exe new file mode 100644 index 000000000..2793c24dc Binary files /dev/null and b/dist/vertamedia-clickhouse-plugin_windows_amd64.exe differ diff --git a/docker-compose.yaml b/docker-compose.yaml index b90e60215..224de58cf 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -70,8 +70,10 @@ services: - ./.cache:/go-cache command: | bash -xec " - go build -gcflags=\"all=-N -l\" -o ./dist/vertamedia-clickhouse-plugin_linux_amd64 . && \ - chmod +x ./dist/vertamedia-clickhouse-plugin_linux_amd64 + GOOS=linux GOARCH=amd64 go build -o ./dist/vertamedia-clickhouse-plugin_linux_amd64 . && \ + GOOS=windows GOARCH=amd64 go build -o ./dist/vertamedia-clickhouse-plugin_windows_amd64.exe . && \ + GOOS=darwin GOARCH=amd64 go build -o ./dist/vertamedia-clickhouse-plugin_darwin_amd64 . && \ + chmod +x ./dist/vertamedia-clickhouse-plugin* " diff --git a/docker/grafana/dashboards/datetime_table_dashboard.json b/docker/grafana/dashboards/datetime_table_dashboard.json new file mode 100644 index 000000000..085b30f7c --- /dev/null +++ b/docker/grafana/dashboards/datetime_table_dashboard.json @@ -0,0 +1,131 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": 5, + "links": [], + "panels": [ + { + "datasource": "clickhouse", + "description": "", + "fieldConfig": { + "defaults": { + "custom": { + "align": null + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "s" + }, + "properties": [ + { + "id": "decimals", + "value": 3 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "t_local" + }, + "properties": [ + { + "id": "unit", + "value": "time: YYYY-MM-DD HH:mm:ss" + } + ] + } + ] + }, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 0 + }, + "id": 2, + "options": { + "frameIndex": 1, + "showHeader": true, + "sortBy": [ + { + "desc": false, + "displayName": "t" + } + ] + }, + "pluginVersion": "7.0.5", + "targets": [ + { + "database": "default", + "dateColDataType": "", + "dateLoading": false, + "dateTimeColDataType": "event_time", + "dateTimeType": "DATETIME", + "datetimeLoading": false, + "extrapolate": true, + "format": "table", + "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t", + "interval": "", + "intervalFactor": 1, + "query": "SELECT\n toUInt64(event_time)*1000 as t_local,\n event_time as t_orig,\n count() c,\n sum(too_big_value) s\nFROM $table\nWHERE $timeFilter\nGROUP BY t_local, t_orig\nORDER BY t_local", + "rawQuery": "SELECT toUInt64(event_time)*1000 as t_local, event_time as t_orig, count() c, sum(too_big_value) s FROM default.test_grafana WHERE event_time >= toDateTime(1593417149) GROUP BY t_local, t_orig ORDER BY t_local", + "refId": "A", + "round": "0s", + "table": "test_grafana", + "tableLoading": false + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Table DateTime", + "type": "table" + } + ], + "schemaVersion": 25, + "style": "dark", + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-7d", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "datetime table dashboard", + "uid": "bwewNfGGz", + "version": 2 +} \ No newline at end of file diff --git a/package.json b/package.json index 50dfc445a..2cfc83173 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vertamedia-clickhouse", - "version": "2.0.1", + "version": "2.0.2", "description": "ClickHouse datasource for Grafana", "scripts": { "build:prod": "webpack --config webpack.config.prod.js", diff --git a/release.sh b/release.sh new file mode 100644 index 000000000..3a5c3b5e2 --- /dev/null +++ b/release.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -xeuo pipefail +if [[ $# -lt 1 ]]; then + echo "release.sh [major|minor|patch]" + exit 1 +fi +if [[ $OSTYPE == *linux* ]]; then + echo 1 > /proc/sys/vm/drop_caches +fi +source .release_env +git config core.eol lf +git config core.autocrlf input +git config user.name "$GITHUB_LOGIN" +git config user.email "$GITHUB_EMAIL" +docker-compose stop +docker-compose run frontend_builder +docker-compose run backend_builder +dos2unix ./dist/* +git add . +git commit -m "prepare to new release, $(grep current_version .bumpversion.cfg)" +bump2version --verbose $1 +git push diff --git a/spec/datasource.jest.ts b/spec/datasource.jest.ts index 2cd76fb8e..7643d294b 100644 --- a/spec/datasource.jest.ts +++ b/spec/datasource.jest.ts @@ -5,7 +5,7 @@ import ResponseParser from "../src/response_parser"; describe("clickhouse sql series:", () => { describe("SELECT $timeseries response WHERE $adhoc = 1", () => { - var response = { + let response = { "meta": [ { @@ -38,12 +38,12 @@ describe("clickhouse sql series:", () => { ], }; - var sqlSeries = new SqlSeries({ + let sqlSeries = new SqlSeries({ series: response.data, meta: response.meta, table: '', }); - var timeSeries = sqlSeries.toTimeSeries(); + let timeSeries = sqlSeries.toTimeSeries(); it("expects two results", () => { expect(size(timeSeries)).toBe(2); }); @@ -55,7 +55,7 @@ describe("clickhouse sql series:", () => { }); describe("SELECT $columns response", () => { - var response = { + let response = { "meta": [ { @@ -89,12 +89,12 @@ describe("clickhouse sql series:", () => { ] }; - var sqlSeries = new SqlSeries({ + let sqlSeries = new SqlSeries({ series: response.data, meta: response.meta, table: '', }); - var timeSeries = sqlSeries.toTimeSeries(); + let timeSeries = sqlSeries.toTimeSeries(); it("expects four results", () => { expect(size(timeSeries)).toBe(4); @@ -109,7 +109,7 @@ describe("clickhouse sql series:", () => { }); describe("When performing ad-hoc query", () => { - var response = { + let response = { "meta": [ { @@ -163,7 +163,7 @@ describe("clickhouse sql series:", () => { }); let data = rp.parse("", response); - adhocCtrl.processResponse(data); + adhocCtrl.processTagKeysResponse(data); it('should return adhoc filter list', function() { let results = adhocCtrl.tagKeys; expect(results.length).toBe(6); diff --git a/src/plugin.json b/src/plugin.json index e3ac4758d..38e67664a 100644 --- a/src/plugin.json +++ b/src/plugin.json @@ -29,6 +29,6 @@ "url": "https://github.com/Vertamedia/clickhouse-grafana" } ], - "version": "2.0.1" + "version": "2.0.2" } } diff --git a/webpack.config.js b/webpack.config.js index 1bfd5f9d1..835d1f610 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -28,7 +28,7 @@ module.exports = { } ], plugins: [ - new CleanWebpackPlugin('dist', { exclude: ['vertamedia-clickhouse-plugin_linux_amd64']}), + new CleanWebpackPlugin('dist', { exclude: ['vertamedia-clickhouse-plugin_linux_amd64','vertamedia-clickhouse-plugin_darwin_amd64','vertamedia-clickhouse-plugin_windows_amd64.exe']}), new webpack.optimize.OccurrenceOrderPlugin(), new CopyWebpackPlugin([ {from: 'plugin.json', to: '.'},