-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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 journalparser plugin #2569
add journalparser plugin #2569
Conversation
@@ -281,7 +278,7 @@ func (p *Parser) ParseLine(line string) (telegraf.Metric, error) { | |||
} | |||
} | |||
|
|||
return metric.New(p.Measurement, tags, fields, p.tsModder.tsMod(timestamp)) |
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.
This line is the reason for all the grok and logparser changes.
metric.New()
will return error if there are no fields present. In the journalparser plugin this may happen as the user may have configured the plugin to parse multiple journal fields. The journalparser plugin calls ParseLine
for each journal field and then merges all the results together. And so one of the calls might not extract any fields.
Looks like build is failing because it needs the systemd development headers. I'm not familiar with CircleCI and how to make sure these are installed. |
AFAIK In the past we haven't accepted plugins that require C libraries, perhaps we can add this to the extras plugin repo once it is ready. |
If the requirement is just not having external libraries so that users don't have to install them to compile telegraf, what about including the header file in the telegraf repo? Since the libs are dynamically loaded, they don't need to be present when building, or even running (as long as you don't try to use a plugin which requires them). |
I don't want to copy in code from other projects, and it really ought to use the machines systemd headers. I wonder if there is a way we can make this plugin optional without making our build system totally non standard. In my mind the ideal setup would be that if you have the header then it builds and otherwise it doesn't. |
Well to play devils advocate, copying code is kinda what the go vendoring thing is about. An alternative would be to do this: https://godoc.org/github.com/rainycape/dl#example-Open--Snprintf. We wouldn't need the header files at all this way. As for a way to make the plugin optional. You can accomplish anything with |
1.3 will utilize modules from go 1.8, we will have to wait until then to get this in do to the dependency on external c libs. |
@nhaugo I thought that was on hold. #2373 (comment) Anyway, I just pushed an alternate implementation for consideration. It uses the So in a more descriptive nutshell, what it does:
This has barely been tested (though it does have a test suite which is passing). And I think I'd like to clean up the unit tests a bit. But it should be functional. |
I would be okay with the version requiring the headers so long as they are not needed by default, and we add something to the build to make sure we build support for it. Maybe we just add a Automatically enabling features would be cool but I don't want to roll my own solution for this. Plugin thing is paused, probably will try to do a gRPC solution. The subprocess version sounds fine as well. Which implementation do you prefer? |
I'm not sure which I prefer. |
@phemmer Any chance of resurrecting this? I'd love to have this input merge and I can help if needed. |
I think we should probably close this issue out for now. We haven't gotten any closer to solving the issue of optional C library dependencies since this issue was last updated and no real tooling has emerged that could help. Would still be willing to accept a native Go solution however I'm not sure journald provides an API outside of the C library. It is also now possible to forward syslog messages into Telegraf in a performant and reliable way, and I think this is a very good method for handling log messages both when using journald. |
Just FYI, the code that was up was a go native solution.
However I no longer use telegraf, so closing is the right action. But it could be revived by someone else.
…On August 27, 2019 11:13:53 PM EDT, Daniel Nelson ***@***.***> wrote:
I think we should probably close this issue out for now. We haven't
gotten any closer to solving the issue of optional C library
dependencies since this issue was last updated and no real tooling has
emerged that could help. Would still be willing to accept a native Go
solution however I'm not sure journald provides an API outside of the C
library.
It is also now possible to forward syslog messages into Telegraf in a
performant and reliable way, and I think this is a very good method for
handling log messages both when using journald.
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#2569 (comment)
|
Thanks for the clarification, that's right we had a CGO implementation but this is an fork/exec version of it. @DSpeichert I would still recommend trying the syslog plugin to see if it will work for you first, but if you are still interested in finishing up this plugin let me know, there has been some changes in Telegraf that would affect how we should go about it. |
syslog transport would loose the structured data that's in the journal |
@danielnelson I explored the option of forwarding journald log to telegraf via syslog protocol.
I don't think that the telegraf plugin supports that, it seems to list support for TCP, UDP and TLS only. It isn't any harder in Go to listen on a Unix socket, but I haven't tried this and I'm not sure if journald is creating that socket or expecting e.g. telegraf to create that. It also requires telegraf to start early in the boot process and immediately read everything or risk losing it, vs a tailing approach that can catch up for a longer time. |
That must have been a documentation oversight, as unix sockets are supported by the syslog input. |
I'll update the documentation for that. Right now the chain needs to be
This is true, you could try using imjournal in rsyslog to bring this to over. If we wanted to take rsyslog out and have structured data, then I believe we are essentially back to this PR. |
Hey, why is this closed? |
In other words; what is required to get this code in? |
Adds a journalparser plugin. The plugin tries to be as similar to configuration of the logparser plugin as possible, and shares the grok parser code.
This plugin does have the unfortunate result of breaking cross-compilation. This is because it uses CGO for the systemd journal libs. You can get cross compilation working again, but you need a cross-compilation toolchain on the build host.
Required for all PRs:
Closes #2109