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

[receiver/filelog] Add settings to annotate file owner and group names #30776

Merged
merged 9 commits into from
Mar 27, 2024

Conversation

tprelle
Copy link
Contributor

@tprelle tprelle commented Jan 25, 2024

Description: When you want to filter log on a shared host with multiple user, you want to be able to add owner and group of the file log. Currenly this lookup it's not possible so it's hard to filter after.
If include_file_infos is true when reading a file on filelogreceiver, it will add the file owner as the attribute log.file.owner and the file group as the attribute log.file.group.
Link to tracking Issue: #30775

Testing: Add unity test

Documentation: Add documentation on file_input and file log receiver.

@tprelle tprelle requested a review from a team January 25, 2024 14:22
Copy link

linux-foundation-easycla bot commented Jan 25, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link
Contributor

github-actions bot commented Feb 9, 2024

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Feb 9, 2024
Copy link
Member

@djaglowski djaglowski left a comment

Choose a reason for hiding this comment

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

I thought I had reviewed this earlier but must not have clicked submit. Sorry about that.

pkg/stanza/fileconsumer/attrs/attrs.go Outdated Show resolved Hide resolved
receiver/otlpjsonfilereceiver/testdata/config.yaml Outdated Show resolved Hide resolved
@github-actions github-actions bot removed the Stale label Feb 10, 2024
@djaglowski djaglowski added the enhancement New feature or request label Feb 13, 2024
@tprelle tprelle force-pushed the add_include_file_infos branch 4 times, most recently from 776951b to cbc1cb9 Compare February 22, 2024 12:04
@djaglowski djaglowski added the Run Windows Enable running windows test on a PR label Feb 22, 2024
pkg/stanza/fileconsumer/attrs/attrs.go Outdated Show resolved Hide resolved
pkg/stanza/fileconsumer/attrs/attrs.go Outdated Show resolved Hide resolved
pkg/stanza/fileconsumer/attrs/attrs.go Outdated Show resolved Hide resolved
receiver/filelogreceiver/README.md Outdated Show resolved Hide resolved
@tprelle tprelle force-pushed the add_include_file_infos branch 2 times, most recently from 1550dbb to bacf104 Compare February 23, 2024 19:39
@djaglowski djaglowski changed the title add include_file_infos on file log consumer [receiver/filelog] Add settings to annotate file owner and group names Feb 26, 2024
@tprelle
Copy link
Contributor Author

tprelle commented Feb 26, 2024

Hi @djaglowski,
A windows test it's failling on var fileStat = fileInfo.Sys().(*syscall.Stat_t) (normal it's a linux call) but i never did this in go. Do you know a way to make it work both on linux and windows ?

@djaglowski
Copy link
Member

A windows test it's failling on var fileStat = fileInfo.Sys().(*syscall.Stat_t) (normal it's a linux call) but i never did this in go. Do you know a way to make it work both on linux and windows ?

I don't know much about windows. If it doesn't work on windows, then I think it's ok to keep exclude the operating system:

  1. When validating the config, error if either new flag is enabled and runtime.GOOS == "windows".
  2. Skip the call to addOwnerInfo if runtime.GOOS == "windows"
  3. Update the documentation for the new settings to indicate that it doesn't work on windows.

@tprelle tprelle force-pushed the add_include_file_infos branch 2 times, most recently from 0980e76 to 084209d Compare February 29, 2024 12:04
pkg/stanza/fileconsumer/attrs/ownerInfo_linux.go Outdated Show resolved Hide resolved
pkg/stanza/fileconsumer/attrs/ownerInfo_other.go Outdated Show resolved Hide resolved
pkg/stanza/fileconsumer/config.go Outdated Show resolved Hide resolved
receiver/filelogreceiver/README.md Outdated Show resolved Hide resolved
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Mar 16, 2024
@tprelle
Copy link
Contributor Author

tprelle commented Mar 17, 2024

thanks @djaglowski for the review.
Sorry i was in 2 weeks vacation. I just push the changes.

@tprelle tprelle force-pushed the add_include_file_infos branch 4 times, most recently from a990ab2 to 52eb76d Compare March 17, 2024 08:04
@github-actions github-actions bot removed the Stale label Mar 18, 2024
pkg/stanza/fileconsumer/attrs/owner_windows.go Outdated Show resolved Hide resolved
pkg/stanza/fileconsumer/config.go Outdated Show resolved Hide resolved
pkg/stanza/fileconsumer/attrs/owner_other.go Outdated Show resolved Hide resolved
pkg/stanza/fileconsumer/attrs/owner_other.go Outdated Show resolved Hide resolved
pkg/stanza/fileconsumer/attrs/owner_other.go Outdated Show resolved Hide resolved
pkg/stanza/fileconsumer/attrs/owner_other.go Outdated Show resolved Hide resolved
pkg/stanza/fileconsumer/attrs/owner_other.go Outdated Show resolved Hide resolved
pkg/stanza/fileconsumer/attrs/owner_other.go Outdated Show resolved Hide resolved
@tprelle tprelle force-pushed the add_include_file_infos branch from 5da3b43 to b81b876 Compare March 25, 2024 14:42
@tprelle tprelle force-pushed the add_include_file_infos branch from b81b876 to 7f26aa4 Compare March 27, 2024 12:49
@tprelle tprelle force-pushed the add_include_file_infos branch from bd8f20f to b575c05 Compare March 27, 2024 14:59
Copy link
Member

@djaglowski djaglowski left a comment

Choose a reason for hiding this comment

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

Thanks @tprelle

@djaglowski djaglowski merged commit fdaca38 into open-telemetry:main Mar 27, 2024
150 checks passed
@github-actions github-actions bot added this to the next release milestone Mar 27, 2024
ghost pushed a commit to opsramp/opentelemetry-collector-contrib that referenced this pull request May 5, 2024
open-telemetry#30776)

**Description:** When you want to filter log on a shared host with
multiple user, you want to be able to add owner and group of the file
log. Currenly this lookup it's not possible so it's hard to filter
after.
If include_file_infos is true when reading a file on filelogreceiver, it
will add the file owner as the attribute `log.file.owner` and the file
group as the attribute `log.file.group`.
**Link to tracking Issue:** open-telemetry#30775

**Testing:** Add unity test 

**Documentation:** Add documentation on file_input and file log
receiver.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pkg/stanza receiver/filelog receiver/otlpjsonfile Run Windows Enable running windows test on a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants