Skip to content

Commit 3fd518e

Browse files
authored
Update READM to update packages (#18)
1 parent 6893fec commit 3fd518e

File tree

5 files changed

+46
-15
lines changed

5 files changed

+46
-15
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/
22
.DS_Store
3+
data/

README.md

+31-1
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,42 @@ docker run -p 6379:6379 --name=redis-jsg ghcr.io/redisgrafana/redis-jsg:latest
3838

3939
## Collect statistics
4040

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.
4242

4343
```bash
4444
node src/stats.ts
4545
```
4646

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+
4777
## Visualize data
4878

4979
To visualize the collected data start Docker containers:

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"author": "Volkov Labs",
33
"dependencies": {
44
"axios": "^0.24.0",
5-
"ioredis": "^4.28.0"
5+
"ioredis": "^4.28.2"
66
},
77
"description": "How many times Redis Data Source for Grafana was downloaded?",
88
"devDependencies": {
9-
"@types/node": "^16.11.9"
9+
"@types/node": "^16.11.12"
1010
},
1111
"license": "Apache-2.0",
1212
"name": "grafana-plugin-stats",

provisioning/datasources/redis.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ datasources:
99
version: 1
1010
url: redis://host.docker.internal:6379
1111
editable: true
12-
- name: RedisMod
12+
- name: RedisJSG
1313
type: redis-datasource
1414
access: proxy
1515
orgId: 1

yarn.lock

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# yarn lockfile v1
33

44

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==
99

1010
axios@^0.24.0:
1111
version "0.24.0"
@@ -20,9 +20,9 @@ cluster-key-slot@^1.1.0:
2020
integrity sha512-2Nii8p3RwAPiFwsnZvukotvow2rIHM+yQ6ZcBXGHdniadkYGZYiGmkHJIbZPIV9nfv7m/U1IPMVVcAhoWFeklw==
2121

2222
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==
2626
dependencies:
2727
ms "2.1.2"
2828

@@ -36,10 +36,10 @@ follow-redirects@^1.14.4:
3636
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.5.tgz#f09a5848981d3c772b5392309778523f8d85c381"
3737
integrity sha512-wtphSXy7d4/OR+MvIFbCVBDzZ5520qV8XfPklSN5QtxuMUJZ+b0Wnst1e1lCDocfzuCkHqj8k0FpZqO+UIaKNA==
3838

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==
4343
dependencies:
4444
cluster-key-slot "^1.1.0"
4545
debug "^4.3.1"

0 commit comments

Comments
 (0)