-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[conmon] pass custom --log-opt
#10694
Comments
would you be interested in submitting a patch :) |
Trust me, you really don't want me to mess around in GO. But I can give it a try. |
Okay, here we go... WIP https://github.com/containers/podman/blob/master/pkg/bindings/containers/types.go#L13 type LogOptions struct {
Follow *bool
PrefixMsg *string // new, to prefix a string (e.g. a name, an ID or anything else) to the message
Since *string
Stderr *bool
Stdout *bool
Tail *string
Timestamps *bool
Until *string
} https://github.com/containers/podman/blob/master/cmd/podman/common/specgen.go#L593 logOpts := make(map[string]string)
for _, o := range c.LogOptions {
split := strings.SplitN(o, "=", 2)
if len(split) < 2 {
return errors.Errorf("invalid log option %q", o)
}
switch strings.ToLower(split[0]) {
case "driver":
s.LogConfiguration.Driver = split[1]
case "path":
s.LogConfiguration.Path = split[1]
case "prefixmsg":
s.LogConfiguration.PrefixMsg = split[1]
case "max-size":
logSize, err := units.FromHumanSize(split[1])
if err != nil {
return err
}
s.LogConfiguration.Size = logSize
default:
logOpts[split[0]] = split[1]
}
} https://github.com/containers/podman/blob/master/pkg/specgen/specgen.go#L13 // LogConfig describes the logging characteristics for a container
type LogConfig struct
// LogDriver is the container's log driver.
// Optional.
Driver string `json:"driver,omitempty"`
// LogPath is the path the container's logs will be stored at.
// Only available if LogDriver is set to "json-file" or "k8s-file".
// Optional.
Path string `json:"path,omitempty"`
// Prefix a string (e.g. a name, an ID or anything else) to the message
// Optional.
PrefixMsg string `json:"prefixmsg,omitempty"`
// Size is the maximum size of the log file
// Optional.
Size int64 `json:"size,omitempty"`
// A set of options to accompany the log driver.
// Optional.
Options map[string]string `json:"options,omitempty"`
} @haircommander PTAL |
Sorry, I'm stuck here. Maybe I'll make it an environment variable for conmon or just apply the changes to my own builds. |
Isn't this what tag does?
|
No, see my report on conmon. The tag ends up in a journald variable, which is pretty costly to extract (see rsyslog docs on their journald module for example). My approach just prefixes the important stuff to the syslog message, which is processed by default and at high performance. But I am making use of the tag, of course. All that is missing is a switch to change the behavior to not break default logging (see the PR in conmon). |
Passing new log options is pretty cheap on the Podman side, so long as Conmon is capable of interpreting them correctly (that would be a @haircommander question) |
Pretty cheap for someone who's into it :-) I'd extent Conmon of course. But I wanted to check if it's possible to get a podmon switch at all. Without it, I would only patch it for my own use (because nobody else would be able to access it). |
@mheon |
Implementation is too complicated and the audience is too little. Closing. |
/kind feature
Description
It would be nice to pass custom
--log-opt
to conmon. That way, I could finish containers/conmon#273Example
to get
The text was updated successfully, but these errors were encountered: