Skip to content

Commit 7cd7e86

Browse files
committed
Use grafana's format
1 parent ac87171 commit 7cd7e86

3 files changed

Lines changed: 117 additions & 1 deletion

File tree

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Build and Release Plugin
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
branch:
7+
description: Branch to build from
8+
default: main
9+
version:
10+
description: Version tag (e.g., v1.0.0). Leave empty to use run number
11+
required: false
12+
type: string
13+
create-release:
14+
description: Create a GitHub release
15+
default: true
16+
type: boolean
17+
18+
permissions:
19+
contents: write
20+
21+
jobs:
22+
build:
23+
name: Build Plugin
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
with:
29+
ref: ${{ github.event.inputs.branch || 'main' }}
30+
fetch-depth: 0
31+
32+
- name: Set up Node.js
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: '20'
36+
cache: 'npm'
37+
38+
- name: Set up Go
39+
uses: actions/setup-go@v5
40+
with:
41+
go-version: '1.24'
42+
cache-dependency-path: go.sum
43+
44+
- name: Install dependencies
45+
run: npm ci
46+
47+
- name: Build frontend
48+
run: npm run build
49+
50+
- name: Install Mage
51+
run: |
52+
go install github.com/magefile/mage@latest
53+
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
54+
55+
- name: Build backend
56+
run: mage build:backend
57+
58+
- name: Verify build artifacts
59+
run: |
60+
echo "Checking dist folder contents:"
61+
ls -lah dist/
62+
echo ""
63+
echo "Checking for required files:"
64+
test -f dist/plugin.json && echo "✓ plugin.json exists" || echo "✗ plugin.json missing"
65+
test -f dist/module.js && echo "✓ module.js exists" || echo "✗ module.js missing"
66+
test -f dist/gpx_clickhouse_linux_amd64 && echo "✓ Linux AMD64 binary exists" || echo "✗ Linux AMD64 binary missing"
67+
68+
- name: Create release archive
69+
run: |
70+
cd dist
71+
zip -r ../grafana-clickhouse-datasource.zip .
72+
cd ..
73+
ls -lh grafana-clickhouse-datasource.zip
74+
75+
- name: Upload build artifacts
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: plugin-dist
79+
path: |
80+
dist/
81+
grafana-clickhouse-datasource.zip
82+
retention-days: 30
83+
84+
- name: Create GitHub Release
85+
if: ${{ github.event.inputs.create-release == 'true' }}
86+
uses: softprops/action-gh-release@v1
87+
with:
88+
files: grafana-clickhouse-datasource.zip
89+
tag_name: ${{ github.event.inputs.version || format('v{0}-build-{1}', github.event.inputs.branch || 'main', github.run_number) }}
90+
name: Release ${{ github.event.inputs.version || format('{0}-build-{1}', github.event.inputs.branch || 'main', github.run_number) }}
91+
body: |
92+
## ClickHouse Datasource Plugin Build
93+
94+
**Branch:** ${{ github.event.inputs.branch || 'main' }}
95+
**Commit:** ${{ github.sha }}
96+
**Build Number:** ${{ github.run_number }}
97+
98+
### Installation Instructions
99+
100+
1. Download the `grafana-clickhouse-datasource.zip` file
101+
2. Extract it to your Grafana plugins directory:
102+
```bash
103+
unzip grafana-clickhouse-datasource.zip -d /var/lib/grafana/plugins/grafana-clickhouse-datasource/
104+
```
105+
3. Restart Grafana
106+
107+
**Note:** You may need to allow unsigned plugins in your `grafana.ini`:
108+
```ini
109+
[plugins]
110+
allow_loading_unsigned_plugins = grafana-clickhouse-datasource
111+
```
112+
draft: false
113+
prerelease: false
114+

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ work/
2626
ci/
2727
e2e-results/
2828
test_summary.json
29+
grafana-clickhouse-datasource.zip
2930

3031
# Editor
3132
.idea
@@ -39,3 +40,4 @@ pkg/__debug_bin
3940
/blob-report/
4041
/playwright/.cache/
4142
/playwright/.auth/
43+

src/data/sqlGenerator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ export const getAttributesSelectSql = (columnIdentifier: string, columnType: str
687687
if (isJsonType) {
688688
// For native JSON columns (ClickHouse 25.x+), convert to string first then extract keys/values.
689689
// Native JSON can be used directly in Grafana.
690-
return `toString(${columnIdentifier}) as ${alias}`;
690+
return `arrayMap(tuple -> map('key', tuple.1, 'value', toString(tuple.2)), JSONExtractKeysAndValuesRaw(toString(${columnIdentifier}))) as ${alias}`;
691691
}
692692

693693
// Default: Map type - convert to array of {key, value} maps for Grafana trace panel

0 commit comments

Comments
 (0)