Skip to content

Commit

Permalink
Add more module metrics collection
Browse files Browse the repository at this point in the history
  • Loading branch information
nantiferov committed Sep 11, 2024
1 parent 11e813c commit 7c51e0c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
6 changes: 6 additions & 0 deletions exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ func NewRedisExporter(redisURI string, opts Options) (*Exporter, error) {
"search_bytes_collected": "search_bytes_collected",
"search_total_cycles": "search_total_cycles",
"search_total_ms_run": "search_total_ms_run",
"search_dialect_1": "search_dialect_1",
"search_dialect_2": "search_dialect_2",
"search_dialect_3": "search_dialect_3",
"search_dialect_4": "search_dialect_4",
},

metricMapCounters: map[string]string{
Expand Down Expand Up @@ -433,6 +437,8 @@ func NewRedisExporter(redisURI string, opts Options) (*Exporter, error) {
"stream_radix_tree_keys": {txt: `Radix tree keys count"`, lbls: []string{"db", "stream"}},
"stream_radix_tree_nodes": {txt: `Radix tree nodes count`, lbls: []string{"db", "stream"}},
"up": {txt: "Information about the Redis instance"},
"module_info": {txt: "Information about loaded Redis module", lbls: []string{"name", "ver", "api", "filters", "usedby", "using"}},
"search_version": {txt: "Information about the RediSearch module", lbls: []string{"version"}},
} {
e.metricDescriptions[k] = newMetricDescr(opts.Namespace, k, desc.txt, desc.lbls)
}
Expand Down
17 changes: 16 additions & 1 deletion exporter/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,24 @@ func (e *Exporter) extractModuleMetrics(ch chan<- prometheus.Metric, c redis.Con
log.Debugf("info: %s", line)

split := strings.Split(line, ":")
if len(split) != 2 {
switch {
case split[0] == "module":
module := strings.Split(split[1], ",")
e.registerConstMetricGauge(ch, "module_info", 1,
// response format: 'module:name=search,ver=21005,api=1,filters=0,usedby=[],using=[ReJSON],options=[handle-io-errors]'
strings.Split(module[0], "=")[1],
strings.Split(module[1], "=")[1],
strings.Split(module[2], "=")[1],
strings.Split(module[3], "=")[1],
strings.Split(module[4], "=")[1],
strings.Split(module[5], "=")[1],
)
case split[0] == "search_version":
e.registerConstMetricGauge(ch, "search_version", 1, split[1])
case len(split) != 2:
continue
}

fieldKey := split[0]
fieldValue := split[1]

Expand Down
6 changes: 6 additions & 0 deletions exporter/modules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ func TestModules(t *testing.T) {
}()

wantedMetrics := map[string]bool{
"module_info": false,
"search_version": false,
"search_number_of_indexes": false,
"search_used_memory_indexes": false,
"search_total_indexing_time": false,
Expand All @@ -42,6 +44,10 @@ func TestModules(t *testing.T) {
"search_bytes_collected": false,
"search_total_cycles": false,
"search_total_ms_run": false,
"search_dialect_1": false,
"search_dialect_2": false,
"search_dialect_3": false,
"search_dialect_4": false,
}

for m := range chM {
Expand Down

0 comments on commit 7c51e0c

Please sign in to comment.