Hi AllRegarding global variables, specifically string/array types, do they need to use/compare against values from an event, or can they maintain a static value from the definition of the global variable itself?Our use case:We have the three Redis hosts in our Sentinel config.We want to implement the Cribl Redis function across multiple sources in the environment, but to manage the host list/credentials in all of those separate Redis functions would be a nightmare.Can we use global variables to store the host list (either multiple string variables or an array that can be accessed based on index value), and then reference it in the Redis function's host fields using something akin to the below?`C.vars.prod_list[0] <-- first host value``C.vars.prod_list[1] <-- second host value``C.vars.prod_list[2] <-- third host value`Example in Redis (doesn't work, even with all the types of access I tried, in this example the array global variable type):
Global Variable definition:
Try wrapping the expression in backticks and ${} around the variable:
Thanks <@ULBGHDPNY>Let me test it
``${C.vars.redis_sentinels_prod[1]}``
<@ULBGHDPNY>Testing this, using an Eval to see what the returned value might be, I get undefined.Running this in the Redis function causes no errors to appear when using non-zero based array (ie, 1-3), but using but when using zero-based notation (0-2) I get errors.1. Are the arrays (global variables) zero-index based or non-zero based?2. Is there a way I can test what the return value would be outside of the Redis function, if Eval is not the right way to do so?
arrays are absolutely 0-basedMake sure you're in the correct worker groupAre you using the pop-out to check?
Using the pop-out I also get "undefined".I'm definitely in the correct worker group.I'm assuming testing this in standalone vs sentinel should not make a difference?
the choice of deployment type would only impact the actual connection, not the variable parsing
This is what I meant above with undefined.
I'm assuming this should've returned the first value in the array referenced above, with/without the quotes?
i'm unable to repro
0
did you commit/deploy after adding the variable?
the variable def needs to also be in the pack
you're in a pack
in the popout, if you remove the `[0]`do you get anything?
Ah ok
So it can't inherit from outside of the pack?
no, Packs are isolated
different knowledge area for Pack-specific settings
I see.That resolved it immediately, thanks!
excellent!
Is there a better way to centrally manage global variables like this, including packs?
not currently
100%Thanks again for the help
Reply
Login to the community
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.