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

Salman

02/01/2023, 5:16 PM
Hello, when creating alerts from exceptions, is it possible to create labels that have a link to source exception and error message?
p

Pranay

02/01/2023, 5:43 PM
@Amol Umbark Do you have more insights here?
a

Amol Umbark

02/02/2023, 5:00 AM
@Salman Alert labels allows dynamic links to be created from columns that you select in the query. But let me check on exceptions page and get back. Currently, we add a top level link "/exceptions" as source link in the alert.
@Salman You can use labels to form the alert query. We support the following options to dynamically create labels. example: {{.Labels.serviceName}} or {{$labels.serviceName}} The error details page has the following format. so you can select the params groupId, timestamp and errorId in the query and pass it in the label. https://<<signoz-url>>/error-detail?&groupId=0fa408c2591sdfsdfds3r2d2&timestamp=71654055292&errorId=23f3r3f434f34r4 eventually, the label in alert would look like this: source: https//&lt;&lt;enter signoz hostport>>/error-detail?&groupId={{$labels.groupid}}&timestamp={{$labels.errTimestamp}}&errorId={{$labels.errorId}} for above to work your query should have columns groupId, errTimestamp and errorId If you need help with query @Vishal Sharma can help
s

Salman

02/02/2023, 12:34 PM
Thank you Amol!@Vishal Sharma could you please help me writing the query that would give more info about the exception/error?
a

Amol Umbark

02/02/2023, 2:13 PM
@Salman can you pls share your existing query for the alert
s

Salman

02/03/2023, 4:12 AM
I have figured it out by connecting to clickhouse and looking at db schema. This is the query:
Copy code
SELECT 
	count() over(partition by serviceName) as value,
	toStartOfInterval(timestamp, toIntervalMinute(1)) AS interval,
	serviceName,
  groupID groupId,
  errorID errorId,
  traceID traceId,
  spanID spanId,
  exceptionMessage message,
  exceptionStacktrace stacktrace,
	timestamp
FROM signoz_traces.distributed_signoz_error_index_v2
WHERE exceptionType = 'error'
-- WHERE exceptionType = 'warning'
AND timestamp BETWEEN {{.start_datetime}} AND {{.end_datetime}};
hopefully, this could help someone else
Exception urls are in this format:
/error-detail?groupId=${groupId}&timestamp=${timestamp}
where
${timestamp}
is go nanoseconds. Timestamp stored in db is in this format:
2023-02-03 02:03:08.279049
By default, the value of
timestamp
in alert payload drops milliseconds. For example,
2023-02-03 02:03:08.279049
becomes
2023-02-03 02:03:08
. I suppose, you need to convert
{{.Labels.timestamp}}
to go nanoseconds. I am not sure if there is a function that you could apply in go template to get that value.
43 Views