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

Logger: Support write to json file as the same time in fluent logger #1470

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Zheaoli
Copy link
Member

@Zheaoli Zheaoli commented Oct 30, 2022

No description provided.

@Zheaoli Zheaoli marked this pull request as draft October 30, 2022 11:42
@Zheaoli Zheaoli force-pushed the manjusaka/support-1374 branch from 7889165 to 2d7c0ec Compare October 30, 2022 13:19
@@ -247,7 +247,7 @@ func TestRunWithFluentdLogDriverWithLogOpt(t *testing.T) {
time.Sleep(3 * time.Second)

testContainerName := containerName + "test"
base.Cmd("run", "-d", "--log-driver", "fluentd", "--log-opt", "fluentd-address=127.0.0.1:24225",
base.Cmd("run", "-d", "--log-driver", "fluentd", "--log-opt", "fluentd-address=127.0.0.1:24225", "--log-opt", "fluentd-log-to-json=true",
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the change. I am not sure why this feature is required:

  1. It is already supported by fluentd as form of multiple outputs (https://docs.fluentd.org/output/secondary_file, https://docs.fluentd.org/output/file). Is there a use-case?
  2. It is not supported in docker.
  3. Even stdout is supported by fluentd (https://docs.fluentd.org/output/stdout) whichis what this test is doing.

if you want to still merge the change and maintainers are fine, can you update the readme.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry for replying late

  1. Help people to use nerdctl logs to get the container log(quickly debug, not need to go to the fluent backend server to get the log)
  2. Yep, this is a nerdctl-only feature
  3. Yep, but in common use case, the people cannot decide whether the fluentd use stdout or not

Copy link
Contributor

Choose a reason for hiding this comment

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

Could this PR be more generic then (i.e for all loggers except default and json)? There would be other remote log forwarders that can make use of this functionality.

Copy link
Member Author

Choose a reason for hiding this comment

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

emmmm, I want to split it into different PR,#1374

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm! Would you copy the same code in every logger then? Is it possible to make the code generic for any logger and have it in a single place so that when new loggers are added; they automatically inherit this logic rather than have more changes in the code base.

@@ -110,21 +117,52 @@ func (f *FluentdLogger) Process(_ string, config *logging.Config) error {
if err != nil {
return fmt.Errorf("failed to create fluent client: %w", err)
}
var jsonLogger *logrotate.Logger
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity: Is it not possible to exec the nerdctl log driver or call the go routine for json driver run directl.

@Zheaoli Zheaoli force-pushed the manjusaka/support-1374 branch from 5efcf53 to 3071a69 Compare December 1, 2022 17:52
@apostasie
Copy link
Contributor

@yankay are you still interested in carrying this through?

@yankay
Copy link
Contributor

yankay commented Dec 6, 2024

@yankay are you still interested in carrying this through?

Let me investigate it :-)

@yankay
Copy link
Contributor

yankay commented Dec 16, 2024

The feature is not supported by docker https://docs.docker.com/engine/logging/drivers/fluentd/.
I think the nerdctl does not must to need it.
So, keep it open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants