Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add redis search module metrics #953

Merged

Conversation

nantiferov
Copy link
Contributor

@nantiferov nantiferov commented Sep 10, 2024

fixes: #942

Found that redis returns all related information to modules with info modules and added collection of all metrics that looks useful so far.

Parsing of module:name=RedisCompat,ver=1,api=1,filters=0,usedby=[],using=[],options=[] is not ideal, but works fine with current Redis 7.4 / Redis search module 2.10

exporter/exporter.go Outdated Show resolved Hide resolved
@nantiferov nantiferov force-pushed the Feature--Add-redis-search-module-metrics branch 3 times, most recently from b6959b0 to 3f02f94 Compare September 11, 2024 11:03
Copy link

codecov bot commented Sep 11, 2024

Codecov Report

Attention: Patch coverage is 84.78261% with 7 lines in your changes missing coverage. Please review.

Project coverage is 80.35%. Comparing base (827e6b5) to head (9e7822e).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
exporter/modules.go 82.75% 3 Missing and 2 partials ⚠️
main.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #953      +/-   ##
==========================================
+ Coverage   80.25%   80.35%   +0.10%     
==========================================
  Files          17       18       +1     
  Lines        1980     2026      +46     
==========================================
+ Hits         1589     1628      +39     
- Misses        306      311       +5     
- Partials       85       87       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@coveralls
Copy link

coveralls commented Sep 11, 2024

Pull Request Test Coverage Report for Build 11101178781

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 48 of 54 (88.89%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 84.219%

Changes Missing Coverage Covered Lines Changed/Added Lines %
main.go 0 2 0.0%
exporter/modules.go 29 33 87.88%
Totals Coverage Status
Change from base Build 10969721321: 0.1%
Covered Lines: 2060
Relevant Lines: 2446

💛 - Coveralls

@nantiferov nantiferov force-pushed the Feature--Add-redis-search-module-metrics branch 2 times, most recently from 402bacd to 7c51e0c Compare September 11, 2024 15:01
@nantiferov nantiferov marked this pull request as ready for review September 11, 2024 15:01
@nantiferov nantiferov force-pushed the Feature--Add-redis-search-module-metrics branch from 7c51e0c to 081482b Compare September 11, 2024 15:13
@oliver006
Copy link
Owner

Sorry about the delay - looking at the PR now.

@nantiferov
Copy link
Contributor Author

No problem, thank you!

Copy link
Owner

@oliver006 oliver006 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General approach looks good - just a couple of minor questions

// Redis Modules metrics
// RediSearch module
"search_number_of_indexes": "search_number_of_indexes",
"search_used_memory_indexes": "search_used_memory_indexes",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

search_used_memory_indexes

I think this could use the unit this is in. Add _bytes ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed

"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"}},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we bake this into the module_info metric? Add a version label? seems tightly related to the module but I don't know if they keep different versions for the two.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already exists there, just in different format. Here it's search_version:2.10.5, but there it's module:name=search,ver=21005,api=1,filters=0,usedby=[],using=[ReJSON],options=[handle-io-errors], i.e. ver=21005

In theory we can drop this metric and keep only module_info, but it looks nicer with dots as separators here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added also now continue after registering metrics to avoid unneeded parsing of metrics after registerConstMetricGauge

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory we can drop this metric and keep only module_info, but it looks nicer with dots as separators here. - in that case, if the versions match, then I'd prefer to just capture one metric - the formatting is just eye candy.
But if the module version could differ from the search engine version then it'd make sense to capture both.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if the module version could differ from the search engine version then it'd make sense to capture both.

Nope, that afaik shouldn't happen, removed search_version and let's keep version in module_info as is.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

exporter/http_test.go Show resolved Hide resolved
@nantiferov nantiferov force-pushed the Feature--Add-redis-search-module-metrics branch from 17b1ee1 to d97d711 Compare September 19, 2024 14:22
@@ -83,3 +83,8 @@ services:
image: tile38/tile38:latest
ports:
- "19851:9851"

redis-stack:
image: redis/redis-stack-server:7.4.0-v0
Copy link
Contributor Author

@nantiferov nantiferov Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context, 7.4.0-v0 is current version of redis-stack-server and it includes redis 7.4 + modules with recent versions.

exporter/exporter.go Show resolved Hide resolved
"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"}},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory we can drop this metric and keep only module_info, but it looks nicer with dots as separators here. - in that case, if the versions match, then I'd prefer to just capture one metric - the formatting is just eye candy.
But if the module version could differ from the search engine version then it'd make sense to capture both.

exporter/modules.go Show resolved Hide resolved
exporter/modules.go Show resolved Hide resolved
Copy link
Owner

@oliver006 oliver006 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, looks good!

Will merge later today or tomorrow and cut a new release.

@oliver006
Copy link
Owner

Apologies for the delay - I was busy this past week. I'll get back to this in the next few days.

Copy link
Owner

@oliver006 oliver006 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work - thanks for your patience and for pushing this all the way to completion!

@oliver006 oliver006 merged commit 1f06f2f into oliver006:master Oct 5, 2024
10 checks passed
@nantiferov nantiferov deleted the Feature--Add-redis-search-module-metrics branch October 7, 2024 06:55
@nantiferov
Copy link
Contributor Author

Thank you for review.
Would be great to release new version this week if you have time.

@oliver006
Copy link
Owner

Yeah, let me cut a release and get this out, sorry for the delay.

// RediSearch module
"search_number_of_indexes": "search_number_of_indexes",
"search_used_memory_indexes": "search_used_memory_indexes_bytes",
"search_total_indexing_time": "search_total_indexing_time_ms",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

search_total_indexing_time is apparently a counter, will prepare PR with renaming it to search_indexing_time_ms_total

nantiferov added a commit to nantiferov/redis_exporter that referenced this pull request Oct 29, 2024
Initially added in oliver006#953 as gauges, but usage shows that they're counters.

Related: oliver006#942
oliver006 pushed a commit that referenced this pull request Oct 31, 2024
#962)

Initially added in #953 as gauges, but usage shows that they're counters.

Related: #942
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RediSearch module metrics collection
3 participants