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

Implementing structured logs #10

Merged
merged 5 commits into from
Feb 10, 2021
Merged

Conversation

dannykopping
Copy link

@dannykopping dannykopping commented Feb 9, 2021

fixes #3

Signed-off-by: Danny Kopping <danny.kopping@grafana.com>
Signed-off-by: Danny Kopping <danny.kopping@grafana.com>
Signed-off-by: Danny Kopping <danny.kopping@grafana.com>
logger.go Show resolved Hide resolved
smtprelay.ini Show resolved Hide resolved
main.go Show resolved Hide resolved

log.WithField("err_code", err.Code).
WithField("err_msg", err.Msg).
WithField("uuid", uniqueID).
Copy link
Member

Choose a reason for hiding this comment

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

like the idea of uuid to tie together the logs for a request.

questions:

  • will it be indexed by loki?
  • if yes, how do we tell loki to not index it?

seems like loki doesn't like high cardinality labels grafana/loki#91

Copy link
Author

@dannykopping dannykopping Feb 9, 2021

Choose a reason for hiding this comment

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

Yeah, I'm assuming the logs will get shipped to Loki.

The UUID won't be indexed because of the issue you correctly pointed out.
However, I've included the UUID in all log entries related to the mail send path, so if an error occurs in any step we can correlate all logs from that request by doing something like {app="smtprelay"} | json | uuid="..." to find all the additional details

main.go Show resolved Hide resolved
Danny Kopping added 2 commits February 10, 2021 12:20
Defaulting to stdout

Signed-off-by: Danny Kopping <danny.kopping@grafana.com>
Refactoring

Signed-off-by: Danny Kopping <danny.kopping@grafana.com>
Copy link
Member

@electron0zero electron0zero left a comment

Choose a reason for hiding this comment

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

lgtm 👍 :shipit:

@electron0zero electron0zero merged commit 002d3d3 into master Feb 10, 2021
@electron0zero electron0zero deleted the dannykopping/structured_logs branch February 10, 2021 14:18
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.

Add structured logging
2 participants