https://signoz.io logo
#support
Title
# support
h

Harshith.R.S

02/16/2023, 12:14 PM
Hey team, how do I change the dashboard details which is done through clickhouse query, based on the dropdown for time that is provide( it seems to not change value based on the time dropdown)
v

Vishal Sharma

02/16/2023, 2:33 PM
@Harshith.R.S Do you want to use timestamp variables in clickhouse queries?
a

Ankit Nayan

02/16/2023, 4:33 PM
@Harshith.R.S the clickhouse query needs to have below templates to use datetime from the dropdown. https://signoz.io/docs/tutorial/writing-clickhouse-queries-in-dashboard/#building-alert-queries-with-clickhouse-data
@Amol Umbark @Srikanth Chekuri Does the above datetime templates work only for alerts or will they work in dashboards also?
@Harshith.R.S if you share the query that you are trying out, we can help you write a correct one
s

Srikanth Chekuri

02/16/2023, 4:37 PM
One can use
{{.SIGNOZ_START_TIME}}
and
{{.SIGNOZ_END_TIME}}
for dashboards. This is in millis so you need to make sure the types match by transforming it. We haven’t documented this because there is no consistent way to work with time values in the system.
h

Harshith.R.S

02/17/2023, 7:34 AM
for example I want these values to change based on the time dropdown but it does not. all these values are obtained from clickhouse queries what do I need to add in the query to update the data ased on the time dropdown
s

Srikanth Chekuri

02/17/2023, 8:02 AM
example I want these values to change based on the time dropdown
Which values are you referring to? There are dropdown values and panel values, all are coming from the ClickHouse. It’s not obvious which ones are you talking about.
h

Harshith.R.S

02/17/2023, 8:13 AM
panel values need to change based on time dropdown, sorry for not being specific
s

Srikanth Chekuri

02/17/2023, 10:14 AM
Panel values change based on the global time filter.
h

Harshith.R.S

02/17/2023, 10:22 AM
When I'm using query builder or promql yes but not with clickhouse query
s

Srikanth Chekuri

02/17/2023, 10:25 AM
What is your query? Did you hardcode the timestamps for in query? As I mentioned you could use the time template variable to get them substituted with global filter values.
h

Harshith.R.S

02/17/2023, 10:38 AM
One of the queries I'm using is
Select avg(durationNano)/1000000 from signoz_traces.signoz_index_v2
s

Srikanth Chekuri

02/17/2023, 11:49 AM
This is querying the whole table. You need to filter on the timestamp column.
Copy code
SELECT
    avg(durationNano) / 1000000
FROM signoz_traces.signoz_index_v2
WHERE timestamp >= toDateTime({{.SIGNOZ_START_TIME}} / 1e3) AND timestamp <= toDateTime({{.SIGNOZ_END_TIME}} / 1e3)
The
/ 1e3
exists because the global filter timestamp is in millis precision in the request.
h

Harshith.R.S

02/17/2023, 11:50 AM
Thank you
4 Views