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

Idimmachukwu Okoro

01/20/2023, 12:31 PM
Hi team! I have installed signoz and configured alerting channel, But I am struggling with how to write trace notifications query using clickhouse Are there resources I can read to be able to understand how to use clickhouse with signoz?
s

Srikanth Chekuri

01/20/2023, 2:25 PM
This guide is written to help you https://signoz.io/docs/tutorial/writing-clickhouse-queries-in-dashboard/. Let us know if you more help with this, @Vishal Sharma will be able to help you more with the traces.
i

Idimmachukwu Okoro

01/20/2023, 2:26 PM
thanks so much @Srikanth Chekuri Let me check it out now.
I have read this @Srikanth Chekuri I can't seem to figure out how to apply it to my use case. Use Case 1: I have instrumented a python app, Now I want to send an alert to slack whenever a link returns anything with status code other than 2xx, but with a message explaining why. Use case 2: I need to alert when a route takes more than 5s to respond with a neat message containing the route and Use case 3: I need to send an alert when there is an error/exception with the error log info to slack. Thanks so much for your help
s

Srikanth Chekuri

01/22/2023, 10:45 PM
There are two parts 1. Writing a query for each of them 2. Setting up alerts
I have instrumented a python app, Now I want to send an alert to slack whenever a link returns anything with status code other than 2xx, but with a message explaining why.
Where does this explanation come from? I am not sure I fully understand the part “a link returns anything with status code other than 2xx”. I hope the link you are here referring to is the endpoint because python wouldn’t know the “links”; the fronted knows the links. Here is the query that gives the number of times there were non 2xx codes for a minute interval
Copy code
SELECT
    toStartOfInterval(timestamp, toIntervalMinute(1)) AS interval,
    httpCode,
    toFloat64(count()) AS num_times
FROM signoz_traces.distributed_signoz_index_v2
WHERE (httpCode != '') AND (httpCode NOT LIKE '2%%') AND (timestamp > (now() - toIntervalMinute(30)))
GROUP BY (httpCode, interval)
ORDER BY (httpCode, interval) ASC
when a route takes more than 5s to respond with a neat message containing the route
Copy code
SELECT
    toStartOfInterval(timestamp, toIntervalMinute(1)) AS interval,
    httpRoute,
    toFloat64(count()) AS num_times
FROM signoz_traces.distributed_signoz_index_v2
WHERE (httpRoute != '') AND ((durationNano / 1000000000) > 5) AND (timestamp > (now() - toIntervalMinute(30)))
GROUP BY (httpRoute, interval)
ORDER BY (httpRoute, interval) ASC
when there is an error/exception with the error log info to slack
Copy code
SELECT toFloat64(count()) AS value, toStartOfInterval(timestamp, INTERVAL 5 MINUTE) AS interval, serviceName, exceptionType, exceptionMessage
FROM signoz_traces.distributed_signoz_error_index_v2 
WHERE timestamp > now() - INTERVAL 30 MINUTE  
GROUP BY interval, serviceName, exceptionType, exceptionMessage
The exception message can be used in alert description
i

Idimmachukwu Okoro

01/23/2023, 7:27 AM
Thanks @Srikanth Chekuri, This is exactly what I needed. Thanks so much boss
8 Views