Hey team, how do I change the dashboard details wh...
# support
h
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
@Harshith.R.S Do you want to use timestamp variables in clickhouse queries?
a
@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
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
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
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
panel values need to change based on time dropdown, sorry for not being specific
s
Panel values change based on the global time filter.
h
When I'm using query builder or promql yes but not with clickhouse query
s
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
One of the queries I'm using is
Select avg(durationNano)/1000000 from signoz_traces.signoz_index_v2
s
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
Thank you