Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for unknown ALERT{} label length #79

Merged
merged 9 commits into from
Mar 10, 2021

Conversation

erdii
Copy link
Member

@erdii erdii commented Mar 2, 2021

Heyo 👋

I'm currently working on incorporating jiralert in our alerting-pipeline and have repeatedly run into a problem: JIRA has a length limit of 255 chars for a single issue label

Since the ALERT{...} label is not intended for human consumption, I would like to propose using a computed hash value instead:

ALERT{ + sha512sum(groupLabels) + }

this way, it is ensured, that jiralert will never pass an invalid label because the length is fixed.


What do you think? Do you think this breaking change is acceptable?

@erdii erdii force-pushed the hash-issue-label branch 2 times, most recently from 3a52b80 to e166f5a Compare March 3, 2021 09:32
@erdii
Copy link
Member Author

erdii commented Mar 4, 2021

I've prepared a commit that by default disables the hashing behavior and add a flag --hash-jira-label that toggles this behavior on: erdii@709239d

@bwplotka
Copy link
Member

bwplotka commented Mar 4, 2021

Nice! I will look at it, feel free to DM me offline as well 🤗

@bwplotka bwplotka self-requested a review March 4, 2021 22:06
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

That will work, just wonder if that statement is true:

Since the ALERT{...} label is not intended for human consumption, I would like to propose using a computed hash value instead:

🤗 Such label will scare people... but maybe there is no better choice. We could put something like this in Ticket description e.g, and do filtering on our side. I think I am find with this for now (:

LGTM!

buf.WriteString(p.Name)
buf.WriteString(fmt.Sprintf("=%q,", p.Value))
kvString := fmt.Sprintf("%s=%q,", p.Name, p.Value)
hash.Write([]byte(kvString)) // nolint:errcheck // hash.Write can never return an error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done on nolint and comment 🤗

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, there might better way! (:

Suggested change
hash.Write([]byte(kvString)) // nolint:errcheck // hash.Write can never return an error
_ = hash.Write([]byte(kvString))

@erdii
Copy link
Member Author

erdii commented Mar 5, 2021

will hide new behavior behind flag and in the long term deprecate the old behavior and the flag

@erdii erdii force-pushed the hash-issue-label branch 2 times, most recently from 1d93af7 to f46fb82 Compare March 5, 2021 16:07
@erdii
Copy link
Member Author

erdii commented Mar 5, 2021

I added the flag -hash-jira-label added a doc blurb to README.md and changed ALERT{...} to JIRALERT{...} to clarify the origin of this label on a jira issue.

This is ready for another review @bwplotka :)

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Let's put one thing to changelog instead and then LGTM!

README.md Outdated
@@ -52,6 +52,9 @@ $ curl -H "Content-type: application/json" -X POST \

## Configuration

Attention: We have introduced a new behavior in [#79](https://github.com/prometheus-community/jiralert/pull/79) for building the string that is used as an issue label in jira so jiralert can find an issue it opened. The new behavior ensures that at all times the string is a legal issue label in the jira api. **This change is opt-in** to avoid breaking users upgrading from older releases, but we will remove the old behavior + flag in a future release.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should probably go to CHANGELOG.md instead 🤗

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a rebase needed 🤗

Signed-off-by: Josh Gwosdz <jgwosdz@redhat.com>
and disable errcheck linting for hash.Write call

Signed-off-by: Josh Gwosdz <jgwosdz@redhat.com>
Signed-off-by: Josh Gwosdz <jgwosdz@redhat.com>
Signed-off-by: Josh Gwosdz <jgwosdz@redhat.com>
Signed-off-by: Josh Gwosdz <jgwosdz@redhat.com>
Signed-off-by: Josh Gwosdz <jgwosdz@redhat.com>
Signed-off-by: Josh Gwosdz <jgwosdz@redhat.com>
Signed-off-by: Josh Gwosdz <jgwosdz@redhat.com>
Signed-off-by: Josh Gwosdz <jgwosdz@redhat.com>
@erdii erdii merged commit c50de63 into prometheus-community:master Mar 10, 2021
@erdii
Copy link
Member Author

erdii commented Mar 10, 2021

🎉 thank you for your reviews and guidance @bwplotka <3

@erdii erdii deleted the hash-issue-label branch March 10, 2021 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants