-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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 journald receiver #5160
Add journald receiver #5160
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.
The new module looks fine, with a few comments to address.
However, I am not clear on the implications of adding journalctl to the dockerfile. Is this best approach? Is it wise to manage such a large set of specific files in this way? Are we sure this is the right set of files? Will this be a fragile pattern? At a minimum, I think we need a test that will fail if journald cannot run due to changes in the set of files that must be copied into the image.
We also have a challenge with the windows tests failing. opentelemetry-log-collection
only builds the journald operator for linux builds. I would think we want a way to include this receiver only in linux builds, but I don't think we have such a mechanism in place for the collector. Any ideas on the best approach here?
@djaglowski Thanks. PR is updated per your comments. We'll look into it a bit more and share our thoughts. Thanks! |
I like the global idea of this receiver I was searching for it some weeks ago and I fallbacked on syslog. Moreover reuse the sideproject for logs collection seems perfect for the consistency. Maybe an alternative could be to propose install systemd-journal-remote to the user like we need to install rsyslog to use syslog receiver ? |
First, I would like to know how to not include journald receiver when building it for non-linux OS because it will only work for linux. Please let me know if you have a preferred way for it. |
@rockb1017 I think we may want to do the following to the log-collection library: https://github.com/open-telemetry/opentelemetry-log-collection/pull/267/files This should allow all operating systems to compile and pass tests, while still omitting the journald operator from non-linux builds. The result, in theory, is that users who try to use the journald receiver will get an error from the log-collection library, along the lines of "unknown operator 'journald'". (If we go this route, we may want to capture the error and wrap it in something clearer to the user.) |
@djaglowski Thanks for replying. I tried something along that approach but build still fails with this. |
@rockb1017 I have opened an issue to discuss excluding components such as this, based on OS. If this is not implemented, or not soon enough, I think the next best option may be to write a full "dummy" implementation for non-linux builds. Something like: // build !linux
package journaldreceiver
import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
)
const typeStr = "journald"
// NewFactory creates a dummy factory.
func NewFactory() component.ReceiverFactory {
return receiverhelper.NewFactory(
typeStr,
createDefaultConfig,
receiverhelper.WithLogs(createLogsReceiver))
}
func createDefaultConfig() config.Receiver {
return nil // or whatever dummy is necessary
func createLogsReceiver(
_ context.Context,
_ component.ReceiverCreateSettings,
_ config.Receiver,
_ consumer.Metrics,
) (component.MetricsReceiver, error) {
return nil, fmt.Errorf("'journald' only supported on linux")
} EDIT: This would seem to be the best current approach for "excluding" a component from a specific OS. It does not look like the builder will be changed to handle this. |
Hello again. My idea is :
receiver:
journald:
gateway:
endpoint: http://journald-gateway:19531/
units: # can be used to filter the /entries http route
# directory and files parameters can be passed to the journald-gateway container at startup but not at otel-collector level All documentation here https://www.freedesktop.org/software/systemd/man/systemd-journal-gatewayd.service.html#Supported%20URLs Probably, this change a lot the actual code but not the goal, and don't disturb otel-collector. |
cmd/otelcontribcol/Dockerfile
Outdated
# This is required by the podmanreceiver. | ||
RUN mkdir -p /rundir | ||
RUN mkdir -p /tmp | ||
RUN chown -R ${USER_UID}:${USER_UID} /rundir |
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.
As already said, work on Dockerfile and introduce kind of complexity will probably introduce issues between containers runtimes and OS.
If tomorrow we provide an image for windows container (PR already exists) as an exemple, these steps will not be compatible, while just copying otelcontribcol is.
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 dockerfile for windows would be a separate file yea? so it wouldn't affect the image for windows.
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.
Hey @gillg thanks. Just to clarify are you referring line 8-11 in the Dockerfile or changes related to journalctl?
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.
Not 100% sure if windows will be a different file. The image can be just an ARG and buildkit can create all flavors.
And my comment is pretty general but just trigger here last changes related to adaptations made in podman context.
@gillg |
Good point, you can use Range query parameter to start to a specific offset, you can put a cursor reference in a file or shared parameter. How do you deal it with journalctl ? Parameters are pretty the same. |
@gillg oh there is no checkpoint mechanism with journald input operator. I assumed there is. |
@djaglowski Awesome! yes it does have it. i missed that part. so we just need to enable storage extension just like filelog, yea? |
Yes, it should work exactly the same. |
32d794a
to
c606e03
Compare
Please see comment here about using a stub receiver for non-linux OS. |
Also, the |
bcbca7c
to
c06d751
Compare
cmd/otelcontribcol/Dockerfile
Outdated
COPY --from=prep /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||
COPY otelcontribcol / | ||
EXPOSE 4317 55680 55679 | ||
ENTRYPOINT ["/otelcontribcol"] | ||
CMD ["--config", "/etc/otel/config.yaml"] | ||
CMD ["--config", "/etc/otel/config.yaml"] |
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.
Please add a newline
receiver/journaldreceiver/README.md
Outdated
@@ -0,0 +1,26 @@ | |||
## `Journald Receiver` | |||
|
|||
Parses Journald events using using the [opentelemetry-log-collection](https://github.com/open-telemetry/opentelemetry-log-collection) library. |
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.
Please rephrase as a complete sentence and remove the duplicate word.
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.
Done. Let me know if anything specific needs to be added. Thanks!
receiver/journaldreceiver/README.md
Outdated
|
||
| Field | Default | Description | | ||
| --- | --- | --- | | ||
| `directory` | /run/log/journal | A directory containing journal files to read entries from | |
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 underlying operator will by default read from either /run/log/journal
or /run/journal
, whichever is present. Can you please note both here?
@@ -0,0 +1 @@ | |||
mode: atomic |
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.
I think this file is supposed to be excluded?
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.
Yes, thank you for pointing this. Removed it
logs: | ||
receivers: [journald] | ||
processors: [nop] | ||
exporters: [nop] |
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.
Newline please
Co-authored-by: Daniel Jaglowski <jaglows3@gmail.com>
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 receiver code looks good to me, but there are two open questions in my mind:
- Are the changes to the Dockerfile acceptable? Should we consider adding a dedicated Dockerfile that enables this receiver? I'm not sure the if the implementation of that approach would be reasonable either. @tigrannajaryan, do you have an opinion on this?
- Can we have an integration test, and/or test(s) in the testbed? Perhaps take inspiration from the containerized integration tests in other receivers.
I would suggest if we can remove dockerfile changes from this PR and make it clear in the docs that this receiver depends on journald to be available on the system. We can handle containerized environments later -- I would lean towards having a dedicated Dockerfile. That part can probably go to https://github.com/open-telemetry/opentelemetry-collector-releases. If this is an acceptable solution, I think we also need to add a graceful handling of journald absence, similar to how we handle Windows now. |
+1, I don't think journald is even recommended to exist in containers... |
+1. @dmitryax I assume for the use case we have for journald (to be added to Helm Chart) this is not a problem? (I don't know, just want to make sure). |
@tigrannajaryan @jpkrohling see my summarized proposal at the end of related issue. |
@tigrannajaryan for now we can enhance docker image in our own distro since we do want to use journald by default |
Incorporating the conversation above, this is my understanding of what needs to be done on this PR:
|
Thanks @djaglowski.
|
Thanks for the review and the discussions. |
I think graceful handling of a missing journalctl primarily means that receiver fails in an expected manner, and that it returns an error message that sufficiently conveys the cause of the failure to the user. The current the error message appears sufficient for this purpose, though perhaps could be improved upon in the future:
|
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
Co-authored-by: Daniel Jaglowski <jaglows3@gmail.com>
…5160) * change feature registry as a prototype to make test friendly Signed-off-by: Kay Yan <kay.yan@daocloud.io> * Change colTelemetry to work with a custom Registry, improve tests Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com> * Fix tests, windows, deprecate old API Co-authored-by: Alex Boten <aboten@lightstep.com>
Description: Add Journald receiver
Link to tracking Issue: #2332
Testing: Unit tests are included
Documentation: Journald receiver README.md is included