RedisGrafana / grafana-redis-datasource

Redis Data Source for @Grafana allows connecting to any @Redis database On-Premises and in the Cloud.
https://redisgrafana.github.io
Apache License 2.0
147 stars 38 forks source link

Add support for FT.SEARCH and FT.AGGREGATE #292

Open kefahi opened 1 year ago

kefahi commented 1 year ago

Is your enhancement related to a problem? Please describe.

RediSearch is a major source of information. In the current grafana plugin we only see support for FT.INFO which provides some statistics about the redisearch index. But the user is unable to extract actual data from the redisearch index and use it in grafana. this is a major limitation.

Describe the solution you'd like

Add two more options to Grafana redis under redisearch: FT.SEARCH and FT.AGGREGATE. Where the result of those calls will simply be formatted as a simple json to be then processed by grafana. e.g. FT.SEARCH retuns document id and body; the result can be rendered as[{id: doc_id, body: doc_body}, ...]. Similar approach can be used with FT.AGGREGATE as well; but the keys and their values can be constructed dynamically from the response provided by redis.

I inspected the PR that added FT.INFO support ...

We need to extend the code in this file :pkg/redis-search.go And introduce the description for the new redisearch commands in those files : pkg/query.go andsrc/redis/command.ts

Describe alternatives you've considered

I tried running redis commnand line to achieve the goal, but due to how redis returns the data (a single sequential array for name,value,name,value,name,value) it is not possible -as per my understanding- to format the results in a way that can be further consumed by a grafana transformer.

slorello89 commented 1 year ago

Hey @kefahi - Adding FT.SEARCH in #297 - Aggregate might be a bit more complicated because of how dynamic the arguments are but I'm pretty sure we'll be able to do it.