Dashboards & Visualizations

Using a token to dynamically set the window parameter in streamstats

klim
Path Finder

I can't seem to be able to set a variable or a token to the window parameter in the streamstats command. 

 

| streamstats avg(count) as avg_count window=$window_token$
| eval c = 2
| streamstats avg(count) as avg_count window=c

 

I get the error saying the option value is not an integer. Seems it doesn't take the value of the variable/token. Is there any way to change the parameter dynamically?

"Invalid option value. Expecting a 'non-negative integer' for option 'window'. Instead got 'c'."

Labels (3)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

These are two different issues. Tokens in dashboard get filled before the search is dispatched so if you have error in such case, there is probably something wrong with your token.  Post your xml so we can see.

The other thing - it doesn't work like that. Eval sets a value for processed results. It's not a "variable" that can be passed to another part of the pipeline. There are some dynamic searching techniques in splunk but this is not it and it's not your main problem here I think.

0 Karma

klim
Path Finder

Looking at it again the token is working. The search was waiting for other tokens to be populated. 

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...

Introduction to Splunk AI

How are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. Lucky for ...