Skip to content
This repository has been archived by the owner on Sep 21, 2023. It is now read-only.

Commit

Permalink
Pass raw_index through to the ES indexer (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
faec authored Feb 16, 2023
1 parent 4d8899c commit b5bdbfe
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions output/elasticsearch/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,17 @@ func (es *ElasticSearchOutput) Start() error {
es.logger.Errorf("failed to serialize event: %v", err)
continue
}
var rawIndex string
// If the event metadata contains a raw_index field, attach
// that to the indexer item to override the global default.
if indexField := event.GetMetadata().GetData()["raw_index"]; indexField != nil {
rawIndex = indexField.GetStringValue()
}
err = bi.Add(
context.Background(),
esutil.BulkIndexerItem{
Action: "index",
Index: rawIndex,
Body: bytes.NewReader(serialized),
OnSuccess: func(ctx context.Context, item esutil.BulkIndexerItem, res esutil.BulkIndexerResponseItem) {
// TODO: update metrics
Expand Down

0 comments on commit b5bdbfe

Please sign in to comment.