Giter Club home page Giter Club logo

Comments (9)

nail-sirazitdinov avatar nail-sirazitdinov commented on July 23, 2024 1

Hi @MathieuEtchepare
The trick with LUA script should work fine on a single shard deployment.

Another option is to utilize RedisGears module. RedisGears is a powerful framework for the execution of the functions. It supports Python and C API.

Here is an example of the script

gb = GB('CommandReader')
gb.flatmap(lambda x:  execute('SUNION',*x[1].split(",")))
gb.register(trigger='SUNION')

Which you can load to the database with RedisGears enabled like:
redis-cli -p 6379 RG.PYEXECUTE "$(cat sunion.py)"

To execute the trigger:

redis-cli -p 6379 RG.TRIGGER SUNION 'America,Europe'
1) "Spain"
2) "UK"
3) "France"
4) "USA"
5) "Mexico"

Use RG.TRIGGER SUNION ${<your-multi-select-variable>:csv} to display in Grafana.

Thank you
__
Nail

from grafana-redis-datasource.

mikhail-vl avatar mikhail-vl commented on July 23, 2024

Hello @MathieuEtchepare, thank you for opening the issue.

When you have multi-value variables, you should use repeat panels or rows for this variable. This feature was introduced for backend plugins in Grafana 7.1 and the latest version of Redis Data Source 1.2, please make sure that you are using the latest version.

Can you use first variable in the query or command directly instead of using 2nd variable?

You may take a look at the example dashboard, which has multi-value for Redis instances: https://github.com/RedisTimeSeries/grafana-redis-datasource/blob/master/dashboards/redis.json

Let me know if it's clear.

from grafana-redis-datasource.

MathieuEtchepare avatar MathieuEtchepare commented on July 23, 2024

Thanks for your answer.
I just noticed that the last part of my question was really unclear and I'm sorry for that.

As a matter of fact, I'm using a first variable to display geographical zones, let's say America, Europe and Asia.
For each I have a list in redis named after it with countries.
To sum up in redis I have:

  • Regions [America, Europe, Asia]
  • America [USA, Mexico, ...]
  • Asia [China, Japan, ...]
  • Europe [France, UK, Spain, ...]

If I select in the first variable America and Europe, is there a way to display the union of these two zones in a second variable?
(By the way, the dashboard, you linked is awesome, I'm going to use it a lot thank you)

from grafana-redis-datasource.

mikhail-vl avatar mikhail-vl commented on July 23, 2024

Hello @MathieuEtchepare,

There are multiple advanced variable format options for variables in Grafana which you can play with: https://grafana.com/docs/grafana/latest/variables/advanced-variable-format-options/

Do you keep countries as LIST data type or SET?

from grafana-redis-datasource.

MathieuEtchepare avatar MathieuEtchepare commented on July 23, 2024

I'm keeping them as a set, I looked at the SUNION command but it needs spaced separated values I think, which is not possible with Grafana if I read correctly the doc you just sent.

from grafana-redis-datasource.

mikhail-vl avatar mikhail-vl commented on July 23, 2024

@MathieuEtchepare, one of the possible solutions is to use EVAL command:

eval "return redis.call('sunion',${region:singlequote})" 0

Screen Shot 2020-10-14 at 12 26 11 PM

I am checking with the team for other options.

from grafana-redis-datasource.

mikhail-vl avatar mikhail-vl commented on July 23, 2024

Hello @MathieuEtchepare, please let us know if LUA or RedisGears solution works for you.

from grafana-redis-datasource.

MathieuEtchepare avatar MathieuEtchepare commented on July 23, 2024

Hi,

Sorry for the late response, I was on other subjects these days...
I am going to use the LUA solution as I only need a simple line of code for now, but I will think about RedisGears if I need a more complex solution.

Thanks for your time, I really appreciate the effort you put into helping me.

Have a nice day! 😃

from grafana-redis-datasource.

mikhail-vl avatar mikhail-vl commented on July 23, 2024

@MathieuEtchepare, thank you for the update.

Please let us know if you need anything else.

from grafana-redis-datasource.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.