Skip to content

Commit

Permalink
overwrite event.ingested field when present
Browse files Browse the repository at this point in the history
Signed-off-by: inge4pres <[email protected]>
  • Loading branch information
inge4pres committed Dec 10, 2024
1 parent 6c7cae8 commit 0b6c58b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ processors:
ctx.event = [:];
}
ctx.event.ingested = metadata().now.withNano(0).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
ctx.event.ingested = metadata().now.withNano(0).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ setup:
- match: { hits.hits.0.fields: { "log.level": ["error"] } }
- match: { hits.hits.1.fields: { "log.level": ["warn"] } }
---
"Test traces-apm-* setting event.ingested via ingest pipeline":
"Test logs-apm.error-* setting event.ingested via ingest pipeline":
- requires:
test_runner_features: [is_after]
- do:
bulk:
index: logs-apm.error-event-ingested-testing
Expand All @@ -37,9 +39,9 @@ setup:
- create: {}
- '{"@timestamp": "2017-06-22", "log": {"level": "error"}, "error": {"log": {"message": "loglevel"}, "exception": [{"message": "exception_used"}]}}'

# event.ingested populated, it gets overwritten
# event.ingested populated, it is overwritten with current timestamp
- create: {}
- '{"@timestamp": "2017-06-22", "log": {"level": "warn"}, "error": {"log": {"message": "loglevel"}, "exception": [{"message": "exception_used"}]}, "event": {"ingested": "2017-06-22 22:00:00.000Z"}}'
- '{"@timestamp": "2017-06-22", "log": {"level": "warn"}, "error": {"log": {"message": "loglevel"}, "exception": [{"message": "exception_used"}]}, "event": {"ingested": "2017-06-22T12:34:56.789123Z"}}'

- is_false: errors

Expand All @@ -49,3 +51,4 @@ setup:
body:
fields: ["event.ingested"]
- length: { hits.hits: 2 }
- is_after: { hits.hits.1.fields.event\.ingested.0: "2017-06-22T12:34:56.789Z" }
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ setup:
- match: { hits.hits.3.fields: {"event.success_count": [0]} }
---
"Test traces-apm-* setting event.ingested via ingest pipeline":
- requires:
test_runner_features: [is_after]
- do:
bulk:
index: traces-apm-testing
Expand All @@ -108,7 +110,7 @@ setup:
- create: {}
- '{"@timestamp": "2017-06-22"}'

# event.ingested populated, it gets overwritten
# event.ingested populated, it is preserved
- create: {}
- '{"@timestamp": "2017-06-22", "event": {"ingested": "2017-06-22T00:00:00.123456Z"}}'

Expand All @@ -120,4 +122,5 @@ setup:
body:
fields: ["event.ingested"]
- length: { hits.hits: 2 }
- is_after: { hits.hits.1.fields.event\.ingested.0: "2017-06-22T00:00:00.000Z" }

0 comments on commit 0b6c58b

Please sign in to comment.