Skip to content

Commit

Permalink
pass suffix differently
Browse files Browse the repository at this point in the history
  • Loading branch information
kvch committed Jul 13, 2021
1 parent a15739e commit d4182cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
19 changes: 1 addition & 18 deletions filebeat/input/filestream/prospector_creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

loginp "github.com/elastic/beats/v7/filebeat/input/filestream/internal/input-logfile"
"github.com/elastic/beats/v7/libbeat/common/cfgwarn"
"github.com/elastic/beats/v7/libbeat/reader/readjson"
)

const (
Expand Down Expand Up @@ -107,21 +106,5 @@ func newProspector(config config) (loginp.Prospector, error) {
}

func getIdentifierSuffix(config config) string {
if config.Reader.Parsers == (parsers.Config{}) {
return ""
}

for _, ns := range config.Reader.Parsers {
if ns.Name() == "container" {
var c readjson.ContainerJSONConfig
err := ns.Config().Unpack(&c)
if err != nil {
return ""
}
if c.Stream != readjson.All {
return c.Stream.String()
}
}
}
return ""
return config.Reader.Parsers.Suffix
}
7 changes: 7 additions & 0 deletions libbeat/reader/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type CommonConfig struct {
}

type Config struct {
Suffix string

pCfg CommonConfig
parsers []common.ConfigNamespace
}
Expand Down Expand Up @@ -79,6 +81,7 @@ func (c *Config) Unpack(cc *common.Config) error {
}

func NewConfig(pCfg CommonConfig, parsers []common.ConfigNamespace) (*Config, error) {
var suffix string
for _, ns := range parsers {
name := ns.Name()
switch name {
Expand All @@ -103,12 +106,16 @@ func NewConfig(pCfg CommonConfig, parsers []common.ConfigNamespace) (*Config, er
if err != nil {
return nil, fmt.Errorf("error while parsing container parser config: %+v", err)
}
if config.Stream != readjson.All {
suffix = config.Stream.String()
}
default:
return nil, fmt.Errorf("%s: %s", ErrNoSuchParser, name)
}
}

return &Config{
Suffix: suffix,
pCfg: pCfg,
parsers: parsers,
}, nil
Expand Down

0 comments on commit d4182cb

Please sign in to comment.