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

Pass raw_index through to the ES indexer #248

Merged
merged 2 commits into from
Feb 16, 2023
Merged
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
7 changes: 7 additions & 0 deletions output/elasticsearch/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,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 {
leehinman marked this conversation as resolved.
Show resolved Hide resolved
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