Elysia Tools
Navigation mobile
Gestion des journaux
Elastic Stack avec données fictives
Les exemples Elastic Stack hors ligne expliquent les champs avec un mapping, trois événements NDJSON et une agrégation Python.
Exemples
Entrées de cette collection
Mapping explicite
card1.json : dynamic strict, quatre champs.
Étiquettes
offline, synthetic, verified-input
{
"mappings": {
"dynamic": "strict",
"properties": {
"event_id": {
"type": "keyword"
},
"level": {
"type": "keyword"
},
"duration_ms": {
"type": "integer"
},
"message": {
"type": "text"
}
}
}
}
Trois événements NDJSON
Parser card2.json ligne par ligne.
Étiquettes
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"}
Agréger hors ligne
Exécuter card3.py.
Étiquettes
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)})
Outils
Outils souvent utilisés avec cet exemple
Associé
Collections d’exemples associées
Associé