MCPcopy
hub / github.com/crowdsecurity/crowdsec / cwLogToEvent

Function cwLogToEvent

pkg/acquisition/modules/cloudwatch/run.go:448–474  ·  view source on GitHub ↗
(log cwTypes.OutputLogEvent, cfg *LogStreamTailConfig)

Source from the content-addressed store, hash-verified

446}
447
448func cwLogToEvent(log cwTypes.OutputLogEvent, cfg *LogStreamTailConfig) (pipeline.Event, error) {
449 evt := pipeline.MakeEvent(cfg.ExpectMode == pipeline.TIMEMACHINE, pipeline.LOG, true)
450
451 if log.Message == nil {
452 return evt, errors.New("nil message")
453 }
454
455 msg := *log.Message
456 if cfg.PrependCloudwatchTimestamp != nil && *cfg.PrependCloudwatchTimestamp {
457 eventTimestamp := time.Unix(0, *log.Timestamp*int64(time.Millisecond))
458 msg = eventTimestamp.String() + " " + msg
459 }
460
461 l := pipeline.Line{
462 Raw: msg,
463 Labels: cfg.Labels,
464 Time: time.Now().UTC(),
465 Src: cfg.GroupName + "/" + cfg.StreamName,
466 Process: true,
467 Module: ModuleName,
468 }
469
470 evt.Line = l
471 cfg.logger.Debugf("returned event labels : %+v", evt.Line.Labels)
472
473 return evt, nil
474}

Callers 2

TailLogStreamMethod · 0.85
CatLogStreamMethod · 0.85

Calls 2

MakeEventFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…