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
Add MySQL/MariaDB transport #708
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, this is pretty amazing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the transport looks amazing, just one nit in the markdown
side note for the transport readme: as a general rule I'd avoid encouraging use of |
Co-Authored-By: David Mark Clements <david.mark.clements@gmail.com>
Co-Authored-By: David Mark Clements <david.mark.clements@gmail.com>
Agreed @davidmarkclements - have accepted your changes |
Ah - that didn't strike me. I've updated my README - thanks @davidmarkclements |
Wouldn't you at least want to suggest this schema? create table logs (
id int(10) unsigned not null auto_increment primary key,
created timestamp default current_timestamp,
log json,
index created (created)
) And maybe an index on JSON? Maybe also show some generated columns to index specific values in JSON. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
once @jsumners feedback is addressed and resolved we're good to merge 👍 |
I've provided a couple of minimal DB schema's in the README and it also contains some examples of extracting fields from the log. |
There is no blockage from me on this PR. I'll just point out that you can save cycles in your transport by defining a column like: req_url varchar generated always as ( json_unquote(json_extract(log, '$.req.url')) ) stored Basically, let the database engine take care of extracting the field if it exists. |
@jsumners I didn't know MySQL could do that. Thanks! That's very cool. I've added your suggestion to the README as well. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Hi - I've added a transport for MySQL/MariaDB which can extract fields from anywhere in the log stream and map them to database columns. It can also save the entire stream as a JSON field in MySQL. I found this useful for my latest project using the wonderful pino logger.
You can check the release here: https://www.npmjs.com/package/pino-mysql