https://signoz.io logo
a

Allan Li

11/01/2022, 5:20 PM
Hi, I'm building a timeseries panel in the signoz dashboard, how do I access the time range macro? Thanks
s

Srikanth Chekuri

11/01/2022, 5:21 PM
Did you mean time range from the top left ? You can use
{{SIGNOZ_START_TIME}}
and
{{SIGNOZ_END_TIME}}
.
a

Allan Li

11/01/2022, 5:22 PM
alright thanks
do you have a link to the doc for the macros?
s

Srikanth Chekuri

11/01/2022, 5:23 PM
These two are special variable but you can create custom variable following this https://signoz.io/docs/userguide/manage-variables/
a

Allan Li

11/01/2022, 5:23 PM
ah great, thanks
A follow up question, can I display a string in the value panel?
While using clickhouse query, do we have to rename the column name? Thanks
s

Srikanth Chekuri

11/01/2022, 5:25 PM
No, there should be datetime column for x axis, float column for y axis and optional string attribute columns for different aggregation.
can I display a string in the value panel?
What’s the use case? Where do you get the string from?
a

Allan Li

11/01/2022, 5:27 PM
I'm trying to display a tag from tagMap, I will group by that tag, sort by durationNano, and display that tag that is taking the most time on average.
By the way @Srikanth Chekuri I am getting
Error: API responded with 400 - template: clickhouse-query:13: function "SIGNOZ_START_TIME" not defined
s

Srikanth Chekuri

11/01/2022, 5:46 PM
How are you using it in query?
a

Allan Li

11/01/2022, 6:00 PM
WHERE
date_exec >= {{SIGNOZ_START_TIME}}
AND date_exec <= {{SIGNOZ_END_TIME}}
date_exec is datetime
s

Srikanth Chekuri

11/01/2022, 6:01 PM
Ah sorry it should be
{{.SIGNOZ_START_TIME}}
and
{{.SIGNOZ_END_TIME}}
basically the go templating format.
a

Allan Li

11/01/2022, 6:09 PM
sorry, it is still is not working
Error: API responded with 400 - encountered multiple errors: error in query-A: code: 62, message: Syntax error: failed at position 359 ('<') (line 13, col 22): <no value> AND date_exec <= <no value>. Expected one of: ANY, ALL, BETWEEN expression, string concatenation expression, list, delimited by operator of variable arity, additive expression, list, delimited by binary operators, INTERVAL operator expression, INTERVAL, TIMESTAMP operator expression, TIMESTAMP, DATE operator expression, DATE, multiplicative expression, unary expression...
s

Srikanth Chekuri

11/01/2022, 6:19 PM
Share the full query
a

Allan Li

11/01/2022, 6:20 PM
SELECT
toStartOfMinute(date_exec) AS time,
avg(duration)
FROM
(
SELECT
toTimeZone(timestamp, 'America/Toronto') AS date_exec,
ROUND(durationNano / 1000000, 2) AS duration,
serviceName AS serviceName,
tagMap['graphql.operation.name'] AS op_name
FROM signoz_traces.durationSort ds
WHERE
date_exec >= {{.SIGNOZ_START_TIME}}
AND date_exec <= {{.SIGNOZ_END_TIME}}
AND name = 'graphql.execute'
AND op_name != ''
AND op_name != 'IntrospectionQuery'
AND serviceName = 'stage'
)
GROUP BY
time
ORDER BY time ASC WITH FILL STEP 60
s

Srikanth Chekuri

11/01/2022, 6:30 PM
Can you confirm if the request payload has these values
SIGNOZ_START_TIME
and
SIGNOZ_END_TIME
?
a

Allan Li

11/01/2022, 6:32 PM
Sorry but how would I confirm that? I tried setting panel time preference to both global time and custom
s

Srikanth Chekuri

11/01/2022, 6:34 PM
quick huddle?
a

Allan Li

11/01/2022, 6:34 PM
sure
s

Srikanth Chekuri

11/01/2022, 6:53 PM
You probably need to convert the epoch to datetime type.
a

Allan Li

11/01/2022, 7:19 PM
yes, also I had to divide by 1000 first to convert it to epoch seconds first
a

Ankit Nayan

11/02/2022, 3:46 AM
@Allan Li Is this solved? Are you able to group by tag and sort by duration?
a

Allan Li

11/02/2022, 3:08 PM
Yes it is good, thank you
Although there is one more question, can I display a string in the value panel?
a

Ankit Nayan

11/02/2022, 5:01 PM
@Srikanth Chekuri possible using promql? Or the query-builder also support this?
s

Srikanth Chekuri

11/02/2022, 5:11 PM
Query builder requires float values and promql can’t be used on traces tables, so I don’t think this can be done now.
a

Allan Li

11/02/2022, 5:26 PM
Okay I see
Thanks though