hertzbeat icon indicating copy to clipboard operation
hertzbeat copied to clipboard

[BUG] In Inhibit rules, Target Labels cannot be assigned labels with the same name but different values.

Open Kylin-Guo opened this issue 3 months ago • 8 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Current Behavior

I tried to assign two labels with same name but different values in the target labels, but the system only retained the last value entered.

Image Image

Expected Behavior

No response

Steps To Reproduce

No response

Environment

HertzBeat version(s):v1.7.2

Debug logs

No response

Anything else?

No response

Kylin-Guo avatar Sep 01 '25 08:09 Kylin-Guo

I noticed that the same phenomenon occurs in notification policies as well, where it is impossible to add labels with the same name but different values. This issue might appear across all label assignment fields in the system.

Kylin-Guo avatar Sep 01 '25 08:09 Kylin-Guo

Hi, @Kylin-Guo Thank you for your feedback. Within the system's label management functionality, does a label with an empty value exist?

delei avatar Sep 01 '25 09:09 delei

Hi, @Kylin-Guo Thank you for your feedback. Within the system's label management functionality, does a label with an empty value exist?

Hi @delei Regardless of whether it is in the system's Labels page or the labels bound in Threshold Rules, I have assigned values to all labels.

Kylin-Guo avatar Sep 01 '25 09:09 Kylin-Guo

This does appear to be an issue, and we will reproduce it in the latest version.

delei avatar Sep 01 '25 09:09 delei

The issue has been reproduced and confirmed to be a issue. and the same issue does indeed occur on other pages.

Steps To Reproduce

  1. add a new inhibit rule
Image
  1. submit this form data
Image

delei avatar Sep 02 '25 14:09 delei

As there are many pages involved, and I'm not a professional front-end developer, I will make a preliminary attempt and assess this issue.

My preliminary assessment suggests this relates to the front-end label selector component. We should employ the web-app/src/app/shared/components/label-selector component to address this issue, and investigate whether modifications to the back-end API logic are required.

delei avatar Sep 02 '25 14:09 delei

I raised a PR to improve the experience of selecting tags, but it did not resolve this issue.

delei avatar Sep 10 '25 17:09 delei

I believe that selecting the same key is currently not permitted.

Based on my understanding of the code logic, the frontend use a Record<String, String> type to store the selected tag values, while the backend use a Map<String, String> object to receive this parameter value. Neither of these types permits duplicate keys.

We require further suggestions. Should my understanding be incorrect or should there be a better solution, Please feel free to comment and provide a detailed description of your implementation approach.

delei avatar Sep 10 '25 17:09 delei