File tree 5 files changed +46
-15
lines changed
5 files changed +46
-15
lines changed Original file line number Diff line number Diff line change 1
1
node_modules /
2
2
.DS_Store
3
+ data /
Original file line number Diff line number Diff line change @@ -38,12 +38,42 @@ docker run -p 6379:6379 --name=redis-jsg ghcr.io/redisgrafana/redis-jsg:latest
38
38
39
39
## Collect statistics
40
40
41
- Collect and store statistics for all Grafana plugins using [ RedisTimeSeries] ( https://oss.redis.com/redistimeseries/ ) .
41
+ Collect and store statistics for all Grafana plugins using [ RedisTimeSeries] ( https://oss.redis.com/redistimeseries/ ) and RedisJSON modules .
42
42
43
43
``` bash
44
44
node src/stats.ts
45
45
```
46
46
47
+ ## Create RediSearch index to search plugins
48
+
49
+ RediSearch does not support JSON array, which means that JSON with all plugins should be separated to individial JSON keys and the easiest way to do it is using RedisGears.
50
+
51
+ ```
52
+ import json
53
+
54
+
55
+ def update(x):
56
+ """
57
+ Update plugins
58
+ """
59
+ j = json.loads(execute('json.get', x['key'], '.items'))
60
+ for i in j:
61
+ execute('SADD', 'set:plugins', i['slug'])
62
+ execute("JSON.SET", "plugin:" + i['slug'], ".", json.dumps(i))
63
+
64
+
65
+ gb = GearsBuilder('KeysReader')
66
+ gb.map(update)
67
+ gb.register(prefix='plugins')
68
+ ```
69
+
70
+ This RedisGears script automatically parse and updates indivial plugins keys when ` plugins ` key updated every hour.
71
+ To create RediSearch schema:
72
+
73
+ ```
74
+ FT.CREATE pluginIdx ON JSON SCHEMA $.name AS name TEXT $.description AS description TEXT
75
+ ```
76
+
47
77
## Visualize data
48
78
49
79
To visualize the collected data start Docker containers:
Original file line number Diff line number Diff line change 2
2
"author" : " Volkov Labs" ,
3
3
"dependencies" : {
4
4
"axios" : " ^0.24.0" ,
5
- "ioredis" : " ^4.28.0 "
5
+ "ioredis" : " ^4.28.2 "
6
6
},
7
7
"description" : " How many times Redis Data Source for Grafana was downloaded?" ,
8
8
"devDependencies" : {
9
- "@types/node" : " ^16.11.9 "
9
+ "@types/node" : " ^16.11.12 "
10
10
},
11
11
"license" : " Apache-2.0" ,
12
12
"name" : " grafana-plugin-stats" ,
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ datasources:
9
9
version : 1
10
10
url : redis://host.docker.internal:6379
11
11
editable : true
12
- - name : RedisMod
12
+ - name : RedisJSG
13
13
type : redis-datasource
14
14
access : proxy
15
15
orgId : 1
Original file line number Diff line number Diff line change 2
2
# yarn lockfile v1
3
3
4
4
5
- " @types/node@^16.11.9 " :
6
- version "16.11.9 "
7
- resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.9 .tgz#879be3ad7af29f4c1a5c433421bf99fab7047185 "
8
- integrity sha512-MKmdASMf3LtPzwLyRrFjtFFZ48cMf8jmX5VRYrDQiJa8Ybu5VAmkqBWqKU8fdCwD8ysw4mQ9nrEHvzg6gunR7A ==
5
+ " @types/node@^16.11.12 " :
6
+ version "16.11.12 "
7
+ resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.12 .tgz#ac7fb693ac587ee182c3780c26eb65546a1a3c10 "
8
+ integrity sha512-+2Iggwg7PxoO5Kyhvsq9VarmPbIelXP070HMImEpbtGCoyWNINQj4wzjbQCXzdHTRXnqufutJb5KAURZANNBAw ==
9
9
10
10
axios@^0.24.0 :
11
11
version "0.24.0"
@@ -20,9 +20,9 @@ cluster-key-slot@^1.1.0:
20
20
integrity sha512-2Nii8p3RwAPiFwsnZvukotvow2rIHM+yQ6ZcBXGHdniadkYGZYiGmkHJIbZPIV9nfv7m/U1IPMVVcAhoWFeklw==
21
21
22
22
debug@^4.3.1 :
23
- version "4.3.2 "
24
- resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2 .tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b "
25
- integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw ==
23
+ version "4.3.3 "
24
+ resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.3 .tgz#04266e0b70a98d4462e6e288e38259213332b664 "
25
+ integrity sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q ==
26
26
dependencies :
27
27
ms "2.1.2"
28
28
@@ -36,10 +36,10 @@ follow-redirects@^1.14.4:
36
36
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.5.tgz#f09a5848981d3c772b5392309778523f8d85c381"
37
37
integrity sha512-wtphSXy7d4/OR+MvIFbCVBDzZ5520qV8XfPklSN5QtxuMUJZ+b0Wnst1e1lCDocfzuCkHqj8k0FpZqO+UIaKNA==
38
38
39
- ioredis@^4.28.0 :
40
- version "4.28.0 "
41
- resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-4.28.0 .tgz#5a2be3f37ff2075e2332f280eaeb02ab4d9ff0d3 "
42
- integrity sha512-I+zkeeWp3XFgPT2CtJKxvaF5FjGBGt4yGYljRjQecdQKteThuAsKqffeF1lgHVlYnuNeozRbPOCDNZ7tDWPeig ==
39
+ ioredis@^4.28.2 :
40
+ version "4.28.2 "
41
+ resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-4.28.2 .tgz#493ccd5d869fd0ec86c96498192718171f6c9203 "
42
+ integrity sha512-kQ+Iv7+c6HsDdPP2XUHaMv8DhnSeAeKEwMbaoqsXYbO+03dItXt7+5jGQDRyjdRUV2rFJbzg7P4Qt1iX2tqkOg ==
43
43
dependencies :
44
44
cluster-key-slot "^1.1.0"
45
45
debug "^4.3.1"
You can’t perform that action at this time.
0 commit comments