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

Switch logging from glog to go-kit/log #31

Merged
merged 17 commits into from
May 8, 2019
Merged

Switch logging from glog to go-kit/log #31

merged 17 commits into from
May 8, 2019

Conversation

tdabasinskas
Copy link
Contributor

As described under #30, glog package does not support outputting logs as JSON, making it quite difficult to capture logs of JIRAlert in cloud-native deployments.

The PR replaces glog with go-kit/kit/log package, which is used both by Prometheus and Thanos. This change introduces additional command line options: --log.level and --log.format that allow configuring logging verbosity and output format. In addition, all log messages were updated to use structured logging.

@tdabasinskas
Copy link
Contributor Author

Hi, @free / @bwplotka
Could you look into this when you have some time?

Copy link
Member

@free free left a comment

Choose a reason for hiding this comment

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

With apologies for the number of comments. I'm very particular about code reviews, as you will see. (o:

cmd/jiralert/main.go Outdated Show resolved Hide resolved
cmd/jiralert/main.go Outdated Show resolved Hide resolved
cmd/jiralert/main.go Show resolved Hide resolved
cmd/jiralert/main.go Show resolved Hide resolved
cmd/jiralert/main.go Outdated Show resolved Hide resolved
pkg/notify/notify.go Outdated Show resolved Hide resolved
pkg/notify/notify.go Outdated Show resolved Hide resolved
pkg/notify/notify.go Outdated Show resolved Hide resolved
pkg/notify/notify.go Outdated Show resolved Hide resolved
pkg/template/template.go Outdated Show resolved Hide resolved
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.

Thank for this @tdabasinskas and LGTM modulo my and @free comments.

There are some things we need to agree on within project I think:

  • Os exit status. Why 255?
  • Lower case or upper case log messages. I think lower case is the standard, we keep it like that in every Prometheus-based project. It's easier to read and since it is JSON at the end it does not matter much? I would vote for keeping this, but let's discuss (:

cmd/jiralert/main.go Show resolved Hide resolved
cmd/jiralert/main.go Show resolved Hide resolved
pkg/notify/notify.go Outdated Show resolved Hide resolved
@tdabasinskas
Copy link
Contributor Author

Thanks for the comments. I've tried addressing all of them, but let me know if I've missed something or if further changes are required.

Copy link
Member

@free free left a comment

Choose a reason for hiding this comment

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

Almost there, down to a few nits.

cmd/jiralert/main.go Show resolved Hide resolved
cmd/jiralert/main.go Show resolved Hide resolved
@@ -56,45 +57,45 @@ func (r *Receiver) Notify(data *alertmanager.Data) (bool, error) {
// The set of JIRA status categories is fixed, this is a safe check to make.
if issue.Fields.Status.StatusCategory.Key != "done" {
// Issue is in a "to do" or "in progress" state, all done here.
log.V(1).Infof("Issue %s for %s is unresolved, nothing to do", issue.Key, issueLabel)
level.Info(logger).Log("msg", "nothing to do as issue is unresolved", "issue", issue.Key, "label", issueLabel)
Copy link
Member

Choose a reason for hiding this comment

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

With apologies for walking back my request, I think stating the cause before the outcome makes more sense. I also find the new log messages somewhat verbose. I'm normally quite careful with grammar, but log files should be free of fluff.

return false, nil
}

resolutionTime := time.Time(issue.Fields.Resolutiondate)
if resolutionTime.Add(time.Duration(*r.conf.ReopenDuration)).After(time.Now()) {
log.Infof("Issue %s for %s was resolved on %s, reopening", issue.Key, issueLabel, resolutionTime.Format(time.RFC3339))
return r.reopen(issue.Key)
level.Info(logger).Log("msg", "issue was resolved after reopen duration, reopening", "issue", issue.Key, "label", issueLabel, "reopenDuration", *r.conf.ReopenDuration, "resolutionTime", resolutionTime)
Copy link
Member

Choose a reason for hiding this comment

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

Ping.

pkg/notify/notify.go Outdated Show resolved Hide resolved
pkg/notify/notify.go Outdated Show resolved Hide resolved
pkg/notify/notify.go Outdated Show resolved Hide resolved
free and others added 2 commits May 8, 2019 08:46
Co-Authored-By: tdabasinskas <tomas@dabasinskas.net>
Co-Authored-By: tdabasinskas <tomas@dabasinskas.net>
@tdabasinskas
Copy link
Contributor Author

Hello, @free ,

Sorry for the delay. Could you please let me know if any further changes are still required? I've committed your suggestions and the only two remaining comments, according to GitHub, are on outdated files.

Copy link
Member

@free free left a comment

Choose a reason for hiding this comment

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

Last round of comments, promise. Just a couple more debug message indentations and some rewording of messages to consistently match the "status is XXX, doing YYY" format.

pkg/template/template.go Outdated Show resolved Hide resolved
pkg/template/template.go Outdated Show resolved Hide resolved
pkg/notify/notify.go Outdated Show resolved Hide resolved
cmd/jiralert/main.go Outdated Show resolved Hide resolved
pkg/config/config.go Outdated Show resolved Hide resolved
pkg/notify/notify.go Outdated Show resolved Hide resolved
pkg/notify/notify.go Outdated Show resolved Hide resolved
pkg/notify/notify.go Outdated Show resolved Hide resolved
free and others added 4 commits May 8, 2019 12:33
Co-Authored-By: tdabasinskas <tomas@dabasinskas.net>
Co-Authored-By: tdabasinskas <tomas@dabasinskas.net>
Co-Authored-By: tdabasinskas <tomas@dabasinskas.net>
Co-Authored-By: tdabasinskas <tomas@dabasinskas.net>
Copy link
Member

@free free left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for putting up with me and still going through with it.

@tdabasinskas
Copy link
Contributor Author

Thanks for approving it!

When can we have this merged and have a new release containing these changes?

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!

@bwplotka bwplotka merged commit 88fb628 into prometheus-community:master May 8, 2019
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.

3 participants