#openobserve

Accessing Variable in openobserve SQL Query

TLDR Shashank was having trouble accessing a variable in a custom SQL query. Hengfei offered a solution, which was shown to work with Shashank's acknowledgement.

Powered by Struct AI

1

7
1mo
Solved
Join the chat
Oct 20, 2023 (1 month ago)
Shashank
Photo of md5-a830a209ddc7244eb2f35531dcf20752
Shashank
12:18 PM
Hi Team, In my openobserve instance under dashboard settings I have created a variable name: test. I want to access this in my customSQL query. Using $test is not working for me. Can someone pls suggest the workaround !!
Hengfei
Photo of md5-c30bb074b7d997d2cd6e689678b65dc1
Hengfei
12:22 PM
SQL or PromQL?
Shashank
Photo of md5-a830a209ddc7244eb2f35531dcf20752
Shashank
12:23 PM
SQL
Hengfei
Photo of md5-c30bb074b7d997d2cd6e689678b65dc1
Hengfei
12:27 PM
SELECT histogram(_timestamp) as "x_axis_1", count(_timestamp) as "y_axis_1"  FROM "production-eks" where kubernetes_namespace_name='$namespace'  GROUP BY x_axis_1 ORDER BY x_axis_1
12:28
Hengfei
12:28 PM
just $test
12:28
Hengfei
12:28 PM
you need to use Custom SQL
Shashank
Photo of md5-a830a209ddc7244eb2f35531dcf20752
Shashank
12:29 PM
Thanks it worked I used '$test' in my case.

1