Skip to content

Commit dbf5b5b

Browse files
jovezhongye11ow
andauthored
2.1.0 (#15)
* set version to 2.1.0-beta.1 * feat: supported query variable, better default settings (#8) * feat: supported query variable * supported value and label * lint * better error * feat: better default config values * updated carsharing * default user, default dashboard * Update CHANGELOG.md * upgrade sdk (#9) * Update Magefile to only build 4 platform,not LinuxARM. Close #10 * feat: basic support for annotations (#11) * 2.1.0-beta.2,update readme * add Linux build for x64 * change version number, require Grafana 11.3 * Update README.md * fix: query editor height and width (#14) --------- Co-authored-by: Calvin Zhang <[email protected]>
1 parent bfce979 commit dbf5b5b

25 files changed

+1597
-1105
lines changed

.config/.cprc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "5.5.3"
2+
"version": "5.12.4"
33
}

.config/.eslintrc

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
"parserOptions": {
2121
"project": "./tsconfig.json"
2222
}
23+
},
24+
{
25+
"files": ["./tests/**/*"],
26+
"rules": {
27+
"react-hooks/rules-of-hooks": "off"
28+
}
2329
}
2430
]
2531
}

.config/Dockerfile

+8-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ ARG grafana_image=grafana-enterprise
33

44
FROM grafana/${grafana_image}:${grafana_version}
55

6+
ARG anonymous_auth_enabled=true
67
ARG development=false
78
ARG TARGETARCH
89

@@ -14,7 +15,7 @@ ENV DEV "${development}"
1415
# Make it as simple as possible to access the grafana instance for development purposes
1516
# Do NOT enable these settings in a public facing / production grafana instance
1617
ENV GF_AUTH_ANONYMOUS_ORG_ROLE "Admin"
17-
ENV GF_AUTH_ANONYMOUS_ENABLED "true"
18+
ENV GF_AUTH_ANONYMOUS_ENABLED "${anonymous_auth_enabled}"
1819
ENV GF_AUTH_BASIC_ENABLED "false"
1920
# Set development mode so plugins can be loaded without the need to sign
2021
ENV GF_DEFAULT_APP_MODE "development"
@@ -30,14 +31,14 @@ USER root
3031
# Installing supervisor and inotify-tools
3132
RUN if [ "${development}" = "true" ]; then \
3233
if grep -i -q alpine /etc/issue; then \
33-
apk add supervisor inotify-tools git; \
34+
apk add supervisor inotify-tools git; \
3435
elif grep -i -q ubuntu /etc/issue; then \
35-
DEBIAN_FRONTEND=noninteractive && \
36-
apt-get update && \
37-
apt-get install -y supervisor inotify-tools git && \
38-
rm -rf /var/lib/apt/lists/*; \
36+
DEBIAN_FRONTEND=noninteractive && \
37+
apt-get update && \
38+
apt-get install -y supervisor inotify-tools git && \
39+
rm -rf /var/lib/apt/lists/*; \
3940
else \
40-
echo 'ERROR: Unsupported base image' && /bin/false; \
41+
echo 'ERROR: Unsupported base image' && /bin/false; \
4142
fi \
4243
fi
4344

.config/supervisord/supervisord.conf

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ user=root
55
[program:grafana]
66
user=root
77
directory=/var/lib/grafana
8-
command=bash -c 'while [ ! -f /root/timeplus-timeplus-datasource/dist/gpx_timeplus* ]; do sleep 1; done; /run.sh'
8+
command=bash -c 'while [ ! -f /root/timeplus-proton-datasource/dist/gpx_timeplus* ]; do sleep 1; done; /run.sh'
99
stdout_logfile=/dev/fd/1
1010
stdout_logfile_maxbytes=0
1111
redirect_stderr=true
@@ -26,7 +26,7 @@ autorestart=true
2626

2727
[program:build-watcher]
2828
user=root
29-
command=/bin/bash -c 'while inotifywait -e modify,create,delete -r /var/lib/grafana/plugins/timeplus-timeplus-datasource; do echo "Change detected, restarting delve...";supervisorctl restart delve; done'
29+
command=/bin/bash -c 'while inotifywait -e modify,create,delete -r /var/lib/grafana/plugins/timeplus-proton-datasource; do echo "Change detected, restarting delve...";supervisorctl restart delve; done'
3030
stdout_logfile=/dev/fd/1
3131
stdout_logfile_maxbytes=0
3232
redirect_stderr=true
@@ -37,8 +37,8 @@ autostart=true
3737
[program:mage-watcher]
3838
user=root
3939
environment=PATH="/usr/local/go/bin:/root/go/bin:%(ENV_PATH)s"
40-
directory=/root/timeplus-timeplus-datasource
41-
command=/bin/bash -c 'git config --global --add safe.directory /root/timeplus-timeplus-datasource && mage -v watch'
40+
directory=/root/timeplus-proton-datasource
41+
command=/bin/bash -c 'git config --global --add safe.directory /root/timeplus-proton-datasource && mage -v watch'
4242
stdout_logfile=/dev/fd/1
4343
stdout_logfile_maxbytes=0
4444
redirect_stderr=true
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import * as webpack from 'webpack';
2+
3+
const PLUGIN_NAME = 'BuildModeWebpack';
4+
5+
export class BuildModeWebpackPlugin {
6+
apply(compiler: webpack.Compiler) {
7+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
8+
compilation.hooks.processAssets.tap(
9+
{
10+
name: PLUGIN_NAME,
11+
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
12+
},
13+
async () => {
14+
const assets = compilation.getAssets();
15+
for (const asset of assets) {
16+
if (asset.name.endsWith('plugin.json')) {
17+
const pluginJsonString = asset.source.source().toString();
18+
const pluginJsonWithBuildMode = JSON.stringify(
19+
{
20+
...JSON.parse(pluginJsonString),
21+
buildMode: compilation.options.mode,
22+
},
23+
null,
24+
4
25+
);
26+
compilation.updateAsset(asset.name, new webpack.sources.RawSource(pluginJsonWithBuildMode));
27+
}
28+
}
29+
}
30+
);
31+
});
32+
}
33+
}

.config/webpack/webpack.config.ts

+11-8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { type Configuration, BannerPlugin } from 'webpack';
1616
import LiveReloadPlugin from 'webpack-livereload-plugin';
1717
import VirtualModulesPlugin from 'webpack-virtual-modules';
1818

19+
import { BuildModeWebpackPlugin } from './BuildModeWebpackPlugin';
1920
import { DIST_DIR, SOURCE_DIR } from './constants';
2021
import { getCPConfigVersion, getEntries, getPackageJson, getPluginJson, hasReadme, isWSL } from './utils';
2122

@@ -175,6 +176,7 @@ const config = async (env): Promise<Configuration> => {
175176
keep: new RegExp(`(.*?_(amd64|arm(64)?)(.exe)?|go_plugin_build_manifest)`),
176177
},
177178
filename: '[name].js',
179+
chunkFilename: env.production ? '[name].js?_cache=[contenthash]' : '[name].js',
178180
library: {
179181
type: 'amd',
180182
},
@@ -185,6 +187,7 @@ const config = async (env): Promise<Configuration> => {
185187
},
186188

187189
plugins: [
190+
new BuildModeWebpackPlugin(),
188191
virtualPublicPath,
189192
// Insert create plugin version information into the bundle
190193
new BannerPlugin({
@@ -200,14 +203,14 @@ const config = async (env): Promise<Configuration> => {
200203
{ from: 'plugin.json', to: '.' },
201204
{ from: '../LICENSE', to: '.' },
202205
{ from: '../CHANGELOG.md', to: '.', force: true },
203-
{ from: '**/*.json', to: '.' }, // TODO<Add an error for checking the basic structure of the repo>
204-
{ from: '**/*.svg', to: '.', noErrorOnMissing: true }, // Optional
205-
{ from: '**/*.png', to: '.', noErrorOnMissing: true }, // Optional
206-
{ from: '**/*.html', to: '.', noErrorOnMissing: true }, // Optional
207-
{ from: 'img/**/*', to: '.', noErrorOnMissing: true }, // Optional
208-
{ from: 'libs/**/*', to: '.', noErrorOnMissing: true }, // Optional
209-
{ from: 'static/**/*', to: '.', noErrorOnMissing: true }, // Optional
210-
{ from: '**/query_help.md', to: '.', noErrorOnMissing: true }, // Optional
206+
{ from: '**/*.json', to: '.' },
207+
{ from: '**/*.svg', to: '.', noErrorOnMissing: true },
208+
{ from: '**/*.png', to: '.', noErrorOnMissing: true },
209+
{ from: '**/*.html', to: '.', noErrorOnMissing: true },
210+
{ from: 'img/**/*', to: '.', noErrorOnMissing: true },
211+
{ from: 'libs/**/*', to: '.', noErrorOnMissing: true },
212+
{ from: 'static/**/*', to: '.', noErrorOnMissing: true },
213+
{ from: '**/query_help.md', to: '.', noErrorOnMissing: true },
211214
],
212215
}),
213216
// Replace certain template-variables in the README and plugin.json

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 2.1.0
4+
5+
Key changes:
6+
7+
* Able to define dashboard variables with this data source. Please make sure turning off the streaming query mode in the SQL to populate the variable values, and only return 1 or 2 columns. You can also refer to `__from` and `__to` variables in the SQL to get the time range of the dashboard.
8+
* Able to define annotations with this data source
9+
* Use default values for HTTP/TCP ports and username if they are not set in the data source configuration
10+
311
## 2.0.0
412

513
Key changes:

Magefile.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ package main
66
import (
77
// mage:import
88
build "github.com/grafana/grafana-plugin-sdk-go/build"
9+
"github.com/magefile/mage/mg"
910
)
1011

12+
func Build4() { //revive:disable-line
13+
b := build.Build{}
14+
mg.Deps(b.Windows, b.Darwin, b.DarwinARM64, b.Linux, b.LinuxARM64, b.GenerateManifestFile)
15+
}
16+
1117
// Default configures the default target.
12-
var Default = build.BuildAll
18+
var Default = Build4

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ID = timeplus-proton-datasource
2-
Version = 2.0.0
2+
Version = 2.1.0
33

44
init:
55
npm install

README.md

+34-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ As the core engine of [Timeplus Enterprise](https://timeplus.com), [Proton](http
77

88
## Requirements
99

10-
Grafana v10.0.3 or above
10+
Grafana v11.3 or above (older versions may work but not verified)
1111

1212
A running Timeplus Proton or Timeplus Enterprise instance with TCP port 8463 (for database connection) and HTTP port 3218 (for query analazyer REST API).
1313

@@ -22,16 +22,47 @@ A data source for Timeplus is created automatically.
2222

2323
### Use your own Grafana deployment
2424

25+
Download the latest version from https://d.timeplus.com/grafana/timeplus-proton-datasource-2.1.0.zip
26+
27+
Unzip the file and copy the folder to the Grafana plugin directory, usually `/var/lib/grafana/plugins/`.
28+
29+
For example, on a Linux machine, you can run the following commands:
30+
31+
```bash
32+
cd /var/lib/grafana
33+
mkdir plugins
34+
cd plugins
35+
wget d.timeplus.com/grafana/timeplus-proton-datasource-2.1.0.zip
36+
unzip timeplus-proton-datasource-2.1.0.zip
37+
/bin/systemctl start grafana-server.service
38+
```
39+
40+
For macOS, you can run the following commands:
41+
42+
```bash
43+
cd /opt/homebrew/var/lib/grafana
44+
mkdir plugins
45+
cd plugins
46+
wget d.timeplus.com/grafana/timeplus-proton-datasource-2.1.0.zip
47+
unzip timeplus-proton-datasource-2.1.0.zip
48+
brew services restart grafana
49+
```
50+
2551
In the navigation menu, choose Connections -> Add new connection.
2652

27-
Search for Timeplus and accept the default settings (localhost,port 8463 and 3218 as proton connection). This plugin is expected to run in localhost or trusted network. Username and password for Timeplus will be added later. This tool supports self-hosted Timeplus Enterprise, but not for Timeplus Cloud.
53+
Search for Timeplus and accept the default settings (localhost,port 8463 and 3218 as proton connection). For Timeplus Enterprise deployment, also set the username and password.
2854

2955
Create a new dashboard or explore data with this Timeplus data source.
3056

31-
There are unbounded streaming query and bounded historical query in proton, all queries like `select count(*) from stream_name` are streaming queries, and adding `table` function to the stream name will turn the query into bounded query, e.g. `select count(*) from table(stream_name)`.
57+
There are unbounded streaming query and bounded historical query in Timeplus, all queries like `select count(*) from stream_name` are streaming queries, and adding `table` function to the stream name will turn the query into bounded query, e.g. `select count(*) from table(stream_name)`.
3258

3359
![query editor](src/img/query.png)
3460

61+
### Query Variables
62+
You can define dashboard variables with this data source. Please make sure turning off the streaming query mode in the SQL to populate the variable values, and only return 1 or 2 columns. When there is 1 column returned, it will be set as both value and label. If there are 2 columns, the first column will be set as value and the second column as the label. You can also refer to `__from` and `__to` variables in the SQL to get the time range of the dashboard, e.g.:
63+
```sql
64+
SELECT distinct product_id FROM table(coinbase) where _tp_time < to_datetime($__to/1000) and _tp_time > to_datetime($__from/1000)
65+
```
3566

3667
## Development
3768

docker-compose.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
context: ./.config
88
args:
99
grafana_image: ${GRAFANA_IMAGE:-grafana-enterprise}
10-
grafana_version: ${GRAFANA_VERSION:-11.2.2}
10+
grafana_version: ${GRAFANA_VERSION:-11.3.1}
1111
development: ${DEVELOPMENT:-false}
1212
ports:
1313
- 3000:3000/tcp
@@ -35,7 +35,7 @@ services:
3535
ports:
3636
- 3218:3218 # HTTP Streaming
3737
- 8463:8463 # TCP Streaming
38-
38+
3939
carsharing_datagen:
4040
image: timeplus/cardemo:latest
4141
pull_policy: always
@@ -49,4 +49,4 @@ services:
4949
interval: 200
5050
host: proton
5151
depends_on:
52-
- proton
52+
- proton

0 commit comments

Comments
 (0)