Add tx_id field for correlating alerts and events per tx.
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));
+
/* alert */
json_object_set_new(js, "alert", ajs);
MemBuffer *buffer;
} LogDnsLogThread;
-static void LogQuery(LogDnsLogThread *aft, json_t *js, DNSTransaction *tx, DNSQueryEntry *entry) {
+static void LogQuery(LogDnsLogThread *aft, json_t *js, DNSTransaction *tx,
+ uint64_t tx_id, DNSQueryEntry *entry)
+{
MemBuffer *buffer = (MemBuffer *)aft->buffer;
SCLogDebug("got a DNS request and now logging !!");
DNSCreateTypeString(entry->type, record, sizeof(record));
json_object_set_new(djs, "rrtype", json_string(record));
+ /* tx id (tx counter) */
+ json_object_set_new(djs, "tx_id", json_integer(tx_id));
+
/* dns */
json_object_set_new(js, "dns", djs);
OutputJSONBuffer(js, aft->dnslog_ctx->file_ctx, buffer);
return;
}
-static void LogAnswers(LogDnsLogThread *aft, json_t *js, DNSTransaction *tx) {
+static void LogAnswers(LogDnsLogThread *aft, json_t *js, DNSTransaction *tx, uint64_t tx_id) {
SCLogDebug("got a DNS response and now logging !!");
if (unlikely(js == NULL))
return TM_ECODE_OK;
- LogQuery(td, js, tx, query);
+ LogQuery(td, js, tx, tx_id, query);
json_decref(js);
}
if (unlikely(js == NULL))
return TM_ECODE_OK;
- LogAnswers(td, js, tx);
+ LogAnswers(td, js, tx, tx_id);
json_decref(js);
json_object_set_new(fjs, "stored",
(ff->flags & FILE_STORED) ? json_true() : json_false());
json_object_set_new(fjs, "size", json_integer(ff->size));
+ json_object_set_new(fjs, "tx_id", json_integer(ff->txid));
/* originally just 'file', but due to bug 1127 naming it fileinfo */
json_object_set_new(js, "fileinfo", fjs);
/* JSON format logging */
-static void JsonHttpLogJSON(JsonHttpLogThread *aft, json_t *js, htp_tx_t *tx)
+static void JsonHttpLogJSON(JsonHttpLogThread *aft, json_t *js, htp_tx_t *tx, uint64_t tx_id)
{
LogHttpFileCtx *http_ctx = aft->httplog_ctx;
json_t *hjs = json_object();
json_object_set_new(hjs, "length", json_integer(tx->response_message_len));
}
+ /* tx id for correlation with alerts */
+ json_object_set_new(hjs, "tx_id", json_integer(tx_id));
+
json_object_set_new(js, "http", hjs);
}
/* reset */
MemBufferReset(buffer);
- JsonHttpLogJSON(jhl, js, tx);
+ JsonHttpLogJSON(jhl, js, tx, tx_id);
OutputJSONBuffer(js, jhl->httplog_ctx->file_ctx, buffer);
json_object_del(js, "http");