0

I'm using variables in Grafana queries with ClickHouse, but the variable ${var_name:raw} isn't recognized in the results. The query runs without errors, but no data shows up in the graph.

Here’s the query:

SELECT
  predictiondate,
  '${var_name:raw}' as "ANN01: 48H"
FROM
  aidb.${plant_name:raw}_table;
  • The parameter is passed as WT01 (uppercase).

  • The column name in the table is lowercase (wt01), and even when using LOWER('${var_name:raw}'), I still don't get any results in the graph.

  • Replacing the variable with the hardcoded value wt01 works fine.

Any suggestions on why the variable isn't working in the query results?

7
  • In SQL single quotes denotes string constant. This probably means that you get results with date and constant 'WT01'. Check raw results of query with: on top of the panel in edit mode "Table view", or using Inspect option of context menu on panel. Commented Apr 29 at 14:02
  • Yes, you're right. The values corresponding to the timestamp are coming as the string 'wt01'. I don't understand why it's not being recognized as a column name. Commented Apr 30 at 6:27
  • you wan't to show different columns from different tables or just want to show string constant '${var_name:raw}' ? try to use doble quotes "${var_name:raw}" Commented Apr 30 at 7:18
  • I want to fetch numeric values from the WT01 column. My variable name is ${var_name:raw}, which I receive as the uppercase WT01, and I'm trying to convert it to lowercase in the query and fetch the corresponding values, but I encountered this issue. I've already tried your suggestion, but unfortunately, I couldn't get any results. Commented Apr 30 at 7:53
  • 1
    If that doesn't work, you might need to modify variable befrlore putting it into query. Ideally, in the source where it is coming from. If not possible, you can create hidden variable based on the current one, and manipulate its value as needed. stackoverflow.com/questions/76385994/… Commented Apr 30 at 9:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.