Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions filebeat/autodiscover/builder/hints/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/elastic/beats/v7/filebeat/fileset"
"github.com/elastic/beats/v7/filebeat/harvester"
"github.com/elastic/beats/v7/libbeat/autodiscover"
"github.com/elastic/beats/v7/libbeat/autodiscover/providers/kubernetes"
"github.com/elastic/beats/v7/libbeat/autodiscover/template"
"github.com/elastic/beats/v7/libbeat/beat"
conf "github.com/elastic/elastic-agent-libs/config"
Expand Down Expand Up @@ -126,38 +125,38 @@ func (l *logHints) CreateConfig(event bus.Event, options ...ucfg.Option) []*conf
// multiline options should be under multiline parser in filestream input
parsersTempCfg := []mapstr.M{}
mlineTempCfg := mapstr.M{}
kubernetes.ShouldPut(mlineTempCfg, multiline, mline, l.log)
shouldPut(mlineTempCfg, multiline, mline, l.log)
parsersTempCfg = append(parsersTempCfg, mlineTempCfg)
kubernetes.ShouldPut(tempCfg, parsers, parsersTempCfg, l.log)
shouldPut(tempCfg, parsers, parsersTempCfg, l.log)
} else {
kubernetes.ShouldPut(tempCfg, multiline, mline, l.log)
shouldPut(tempCfg, multiline, mline, l.log)
}
}
if ilines := l.getIncludeLines(h); len(ilines) != 0 {
kubernetes.ShouldPut(tempCfg, includeLines, ilines, l.log)
shouldPut(tempCfg, includeLines, ilines, l.log)
}
if elines := l.getExcludeLines(h); len(elines) != 0 {
kubernetes.ShouldPut(tempCfg, excludeLines, elines, l.log)
shouldPut(tempCfg, excludeLines, elines, l.log)
}

if procs := l.getProcessors(h); len(procs) != 0 {
kubernetes.ShouldPut(tempCfg, processors, procs, l.log)
shouldPut(tempCfg, processors, procs, l.log)
}

if pip := l.getPipeline(h); len(pip) != 0 {
kubernetes.ShouldPut(tempCfg, pipeline, pip, l.log)
shouldPut(tempCfg, pipeline, pip, l.log)
}

if jsonOpts := l.getJSONOptions(h); len(jsonOpts) != 0 {
if inputType == harvester.FilestreamType {
// json options should be under ndjson parser in filestream input
parsersTempCfg := []mapstr.M{}
ndjsonTempCfg := mapstr.M{}
kubernetes.ShouldPut(ndjsonTempCfg, ndjson, jsonOpts, l.log)
shouldPut(ndjsonTempCfg, ndjson, jsonOpts, l.log)
parsersTempCfg = append(parsersTempCfg, ndjsonTempCfg)
kubernetes.ShouldPut(tempCfg, parsers, parsersTempCfg, l.log)
shouldPut(tempCfg, parsers, parsersTempCfg, l.log)
} else {
kubernetes.ShouldPut(tempCfg, json, jsonOpts, l.log)
shouldPut(tempCfg, json, jsonOpts, l.log)
}

}
Expand Down Expand Up @@ -309,3 +308,10 @@ func (l *logHints) getInputs(hints mapstr.M) []mapstr.M {

return output
}

func shouldPut(event mapstr.M, field string, value interface{}, logger *logp.Logger) {
_, err := event.Put(field, value)
if err != nil {
logger.Debugf("Failed to put field '%s' with value '%s': %s", field, value, err)
}
}
2 changes: 1 addition & 1 deletion filebeat/autodiscover/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

//go:build !aix
//go:build linux || darwin || windows

package autodiscover

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
// specific language governing permissions and limitations
// under the License.

//go:build aix
//go:build !(linux || darwin || windows)

package autodiscover

// InitializeModule initializes this module.
func InitializeModule() {
// does nothing on aix
// does nothing if kubernetes and docker are not supported
}