output-json: add tx_id to events

This patch updates alert, stmp and http JSON logging to have a
tx_id in the root of the JSON log message.
pull/1671/head
Eric Leblond 11 years ago
parent 113d6a3950
commit 6f04988ba1

@ -146,6 +146,11 @@ void AlertJsonHeader(const Packet *p, const PacketAlert *pa, json_t *js)
action = "blocked";
}
/* Add tx_id to root element for correlation with other events. */
json_object_del(js, "tx_id");
if (pa->flags & PACKET_ALERT_FLAG_TX)
json_object_set_new(js, "tx_id", json_integer(pa->tx_id));
json_t *ajs = json_object();
if (ajs == NULL) {
json_decref(js);
@ -162,9 +167,6 @@ void AlertJsonHeader(const Packet *p, const PacketAlert *pa, json_t *js)
json_string((pa->s->class_msg) ? pa->s->class_msg : ""));
json_object_set_new(ajs, "severity", json_integer(pa->s->prio));
if (pa->flags & PACKET_ALERT_FLAG_TX)
json_object_set_new(ajs, "tx_id", json_integer(pa->tx_id));
if (p->tenant_id > 0)
json_object_set_new(ajs, "tenant_id", json_integer(p->tenant_id));

@ -362,9 +362,6 @@ static void JsonHttpLogJSON(JsonHttpLogThread *aft, json_t *js, htp_tx_t *tx, ui
if (http_ctx->flags & LOG_HTTP_EXTENDED)
JsonHttpLogJSONExtended(hjs, tx);
/* tx id for correlation with alerts */
json_object_set_new(hjs, "tx_id", json_integer(tx_id));
json_object_set_new(js, "http", hjs);
}
@ -376,7 +373,7 @@ static int JsonHttpLogger(ThreadVars *tv, void *thread_data, const Packet *p, Fl
JsonHttpLogThread *jhl = (JsonHttpLogThread *)thread_data;
MemBuffer *buffer = (MemBuffer *)jhl->buffer;
json_t *js = CreateJSONHeader((Packet *)p, 1, "http"); //TODO const
json_t *js = CreateJSONHeaderWithTxId((Packet *)p, 1, "http", tx_id); //TODO const
if (unlikely(js == NULL))
return TM_ECODE_OK;

@ -90,7 +90,7 @@ static int JsonSmtpLogger(ThreadVars *tv, void *thread_data, const Packet *p, Fl
MemBuffer *buffer = (MemBuffer *)jhl->buffer;
json_t *sjs;
json_t *js = CreateJSONHeader((Packet *)p, 1, "smtp");
json_t *js = CreateJSONHeaderWithTxId((Packet *)p, 1, "smtp", tx_id);
if (unlikely(js == NULL))
return TM_ECODE_OK;

Loading…
Cancel
Save