About the principle of error.grouping_key

When service.name, url_path, and type are the same, why sometimes the id is the same, sometimes not the same id
I want to know the error_group_id calculated according to what formula?



Is the same event generated at two time points an error_group_id?
for example:

2021.9.6 01:01:01 
Lonsid_IOT_Web_Host	/api/iot/iOTDevice/getLSDIOTDeviceByNo	Abp.UI.UserFriendlyException	设备数据不存在!

2021.9.8 01:01:01 
Lonsid_IOT_Web_Host	/api/iot/iOTDevice/getLSDIOTDeviceByNo	Abp.UI.UserFriendlyException	设备数据不存在!

@wajika the error grouping key is used for grouping multiple instances of similar errors, using a hash of the stack trace and other properties. You can find the specific details of the algorithm at https://github.com/elastic/apm-server/blob/master/model/modelprocessor/groupingkey.go

We use this in the APM UI, on the service errors page:

Each row corresponds to a unique error.grouping_key value. Occurrences counts how many errors have the same grouping key value, and Last occurrence shows the time since the most recent error with that grouping key value.

Thank you for your reply, what you mean is similar to what I expected, but why in the third picture, the same service.name, url_path, type, message will generate multiple error_group_id?

The grouping key will change if the exception stack trace is different, even if the message and exception type are the same. Maybe the exception is being thrown in two different code locations?

I am a little bit understanding
Maybe the exception is being thrown in two different code locations?
If an exception is thrown in two code locations, why is the same error? For example, A function calls B function and C function calls B function. If an error occurs, is APM recorded as the code location of B function?
Sorry, I may not be able to describe it clearly.

If an exception is thrown in two code locations, why is the same error? For example, A function calls B function and C function calls B function. If an error occurs, is APM recorded as the code location of B function?

They should have different grouping keys in this case. The grouping key calculates a hash of the full stack trace: e.g. if A calls B, then the grouping key will include details of both A and B.

Example:

func a() {
    c()
}

func b() {
    c()
}

func c() {
    panic("an error occurred")
}
  • If a is called, it will call c and panic. The grouping key is a hash of "a" and "c"
  • If b is called, it will call c and panic. The grouping key is a hash of "b" and "c"

So they will be different, because even though the error occurs in c, the stack trace is different -- the code took a different path to get there. But each time a is called, it will have the same grouping key as every other time a is called.

1 Like

Sorry for my late reply, because something was delayed.

As you said, in the following code, the error group id of a() and b() are the same, right?

func a() {
    c()
}

func b() {
    c()
}

func c() {
    d()
}

func d() {
    panic("an error occurred")
}

We plan to use the error group id to determine whether a function has been repaired. I think we can use this id. Now it should be possible.

No, they will have two different grouping IDs.

  • a(): hash(a+c+d)
  • b(): hash(b+c+d)

OK, thank you for your patience.


To interrupt, I would like to once again ask for your help, you can explain the situation again at this image?

I can only guess that the same exception is occurring in several different stack traces. You can confirm this by selecting error documents with different error.grouping_key values, and comparing their error.exception.stacktrace fields. If they are different, then that would explain why they have different grouping key values.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.