Skip to content

Commit

Permalink
feat: include read_bytes_limit_per_second as parameter (vmware#397)
Browse files Browse the repository at this point in the history
Include read_bytes_limit_per_second as parameter for in_tail plugin

Signed-off-by: jcriadomarco <jcriadomarco@vmware.com>
  • Loading branch information
javiercri authored and lynn-e committed Jun 27, 2023
1 parent 835624a commit 638572e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config-reloader/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type Config struct {
ParsedMetaValues map[string]string
ParsedLabelSelector labels.Set
ExecTimeoutSeconds int
ReadBytesLimit int
}

var defaultConfig = &Config{
Expand All @@ -78,6 +79,7 @@ var defaultConfig = &Config{
MetricsPort: 9000,
AdminNamespace: "kube-system",
ExecTimeoutSeconds: 30,
ReadBytesLimit: 51200,
}

var reValidID = regexp.MustCompile("([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]")
Expand Down Expand Up @@ -251,6 +253,9 @@ func (cfg *Config) ParseFlags(args []string) error {
app.Flag("admin-namespace", "Configurations defined in this namespace are copied as is, without further processing. Virtual plugins can also be defined in this namespace").Default(defaultConfig.AdminNamespace).StringVar(&cfg.AdminNamespace)

app.Flag("exec-timeout", "Timeout duration (in seconds) for exec command during validation").Default(strconv.Itoa(defaultConfig.ExecTimeoutSeconds)).IntVar(&cfg.ExecTimeoutSeconds)

app.Flag("container-bytes-limit", "read_bytes_limit_per_second parameter for tail plugin per container file. Default 2MB/min").Default(strconv.Itoa(defaultConfig.ReadBytesLimit)).IntVar(&cfg.ReadBytesLimit)

_, err := app.Parse(args)

if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions config-reloader/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,11 @@ func (g *generatorInstance) renderIncludableFile(templateFile string, dest strin
model := struct {
ID string
PrometheusEnabled bool
ReadBytesLimit int
}{
ID: util.MakeFluentdSafeName(g.cfg.ID),
PrometheusEnabled: g.cfg.PrometheusEnabled,
ReadBytesLimit: g.cfg.ReadBytesLimit,
}

err = util.TemplateAndWriteFile(tmpl, model, dest)
Expand Down
2 changes: 1 addition & 1 deletion config-reloader/templates/kubernetes.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
skip_refresh_on_startup true
tag kubernetes.*
read_from_head true
read_bytes_limit_per_second 8192
read_bytes_limit_per_second {{.ReadBytesLimit}}
multiline_flush_interval 5s
<parse>
@type multiline
Expand Down

0 comments on commit 638572e

Please sign in to comment.