Elysia Tools
Navigation
Log Management
Elastic Stack synthetic data examples
Elastic Stack offline samples explain log fields through an explicit mapping, three NDJSON events and Python aggregation.
Samples
Entries inside this sample collection
Explicit field mapping
Read card1.json with dynamic strict and four properties.
Tags
offline, synthetic, verified-input
{
"mappings": {
"dynamic": "strict",
"properties": {
"event_id": {
"type": "keyword"
},
"level": {
"type": "keyword"
},
"duration_ms": {
"type": "integer"
},
"message": {
"type": "text"
}
}
}
}
Three NDJSON events
Parse each line of card2.json separately, not the whole file as one JSON object.
Tags
offline, synthetic, verified-input
{"event_id":"demo-1","level":"info","duration_ms":10,"message":"Synthetic pass"}
{"event_id":"demo-2","level":"error","duration_ms":30,"message":"Synthetic failure"}
{"event_id":"demo-3","level":"info","duration_ms":20,"message":"Synthetic pass"}
Aggregate offline
Run card3.py with standard Python.
Tags
offline, synthetic, verified-input
# Synthetic offline aggregation, not an Elasticsearch query or benchmark.
from collections import Counter
rows = [{"level":"info","duration_ms":10},
{"level":"error","duration_ms":30},
{"level":"info","duration_ms":20}]
counts = dict(Counter(r["level"] for r in rows))
mean_ms = sum(r["duration_ms"] for r in rows) / len(rows)
errors = [r for r in rows if r["level"] == "error"]
assert counts == {"info":2,"error":1}
assert mean_ms == 20 and len(errors) == 1
print({"counts":counts,"mean_ms":mean_ms,"errors":len(errors)})
Tools
Tools frequently paired with this sample
Related
Related sample collections
Related