Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

fix(perf): record the payload bytes the producer actually sent, closing 17 days of scheduled harness failures (#1444)

Beenu Aroraac0a7c919894
diff --git a/scripts/perf/load_harness.py b/scripts/perf/load_harness.py
index 3347f7908..b6b67037a 100644
--- a/scripts/perf/load_harness.py
+++ b/scripts/perf/load_harness.py
@@ -347,6 +347,20 @@ class ProducerSummary:
def alert_every(self) -> int:
return int(self.raw.get("alert_every") or 1)
+ @property
+ def payload_bytes_per_event(self) -> float | None:
+ """Mean request-body bytes per attempted event, measured at the wire.
+
+ ``None`` for a summary written by a producer from before the counter
+ existed — the honest answer, exactly like ``alerting_sent`` above,
+ rather than a default that looks like a measurement.
+ """
+ value = self.raw.get("payload_bytes_per_event")
+ if value is None:
+ return None
+ parsed = float(value)
+ return parsed if parsed > 0 else None
+
@dataclass
class AlertRow:
@@ -867,6 +881,17 @@ def main(argv: list[str] | None = None) -> int:
}
if args.target == "compose":
shape["hosts"] = 1
+ # `throughput_claims.py` requires `payload_bytes` beside `ingest_eps` —
+ # wired as a gate in depth 5.8, after which the job failed every
+ # scheduled run for seventeen days because nothing ever recorded the
+ # key (the fan-out half of the same gap was fixed in #1218; this is the
+ # payload half). Read from what the producer actually sent — it counts
+ # request-body bytes at the marshal — and omitted, not defaulted, when
+ # an older producer summary lacks the counter, so the grader says
+ # "unreproducible" instead of publishing a guess.
+ payload_bytes = summary.payload_bytes_per_event
+ if payload_bytes is not None:
+ shape["payload_bytes"] = round(payload_bytes)
# `throughput_claims.py` requires both of these beside an alert-path rate,
# and it is right to: that rate is the one a reader uses to decide whether
# a deployment keeps up, and it means nothing without the fan-out it was
diff --git a/services/demo-producer/main.go b/services/demo-producer/main.go
index 838529590..357eb01c0 100644
--- a/services/demo-producer/main.go
+++ b/services/demo-producer/main.go
@@ -236,6 +236,7 @@ type stats struct {
rejected atomic.Int64 // events ingest parsed and refused
refused atomic.Int64 // events in batches answered with a non-2xx
transport atomic.Int64 // events in batches that never got an answer
+ bodyBytes atomic.Int64 // request-body bytes actually marshalled and sent
mu sync.Mutex
statuses map[int]int64
@@ -277,6 +278,11 @@ func postBatch(ctx context.Context, client *http.Client, opts options, payload i
if err != nil {
return fmt.Errorf("marshal: %w", err)
}
+ // Counted at the marshal, not estimated afterwards: `payload_bytes` is
+ // required reproduction context for the published ingest rate
+ // (scripts/perf/throughput_claims.py), and a size written down anywhere
+ // else would be a guess that looks like a measurement.
+ st.bodyBytes.Add(int64(len(body)))
req, err := http.NewRequestWithContext(ctx, "POST", opts.ingestURL, bytes.NewReader(body))
if err != nil {
return fmt.Errorf("%w for %q: %v", errFatalRequest, opts.ingestURL, err)
@@ -581,6 +587,12 @@ type loadSummary struct {
StatusCounts map[string]int64 `json:"http_status_counts"`
SeqLow int64 `json:"seq_low"`
SeqHigh int64 `json:"seq_high"`
+ // The load's byte shape, so a published events/s figure carries the
+ // payload size it was measured at. Total request-body bytes sent, and
+ // the per-event mean over attempted events (batch envelope included,
+ // deliberately: it is what the wire carried).
+ PayloadBytesTotal int64 `json:"payload_bytes_total"`
+ PayloadBytesPerEvent float64 `json:"payload_bytes_per_event"`
}
// runLoad saturates or paces ingest with `total` attributable events and
@@ -685,31 +697,39 @@ func runLoad(ctx context.Context, opts options) loadSummary {
high = 0
}
return loadSummary{
- RunID: opts.runID,
- Mode: "load",
- MarkerPrefix: MarkerPrefix,
- BenignPrefix: BenignMarkerPrefix,
- AlertEvery: opts.alertEvery,
- AlertingSent: alertingSent.Load(),
- BenignSent: benignSent.Load(),
- IngestURL: opts.ingestURL,
- Tenant: opts.tenant,
- StartedAt: started.UTC().Format(time.RFC3339Nano),
- EndedAt: started.Add(elapsed).UTC().Format(time.RFC3339Nano),
- WallSeconds: elapsed.Seconds(),
- Workers: opts.workers,
- BatchSize: opts.batch,
- TargetEPS: opts.targetEPS,
- Requested: opts.total,
- Attempted: st.attempted.Load(),
- Accepted: accepted,
- Rejected: st.rejected.Load(),
- Refused: st.refused.Load(),
- TransportErrors: st.transport.Load(),
- AcceptedEPS: eps,
- StatusCounts: st.statusCounts(),
- SeqLow: 0,
- SeqHigh: high,
+ RunID: opts.runID,
+ Mode: "load",
+ MarkerPrefix: MarkerPrefix,
+ BenignPrefix: BenignMarkerPrefix,
+ AlertEvery: opts.alertEvery,
+ AlertingSent: alertingSent.Load(),
+ BenignSent: benignSent.Load(),
+ IngestURL: opts.ingestURL,
+ Tenant: opts.tenant,
+ StartedAt: started.UTC().Format(time.RFC3339Nano),
+ EndedAt: started.Add(elapsed).UTC().Format(time.RFC3339Nano),
+ WallSeconds: elapsed.Seconds(),
+ Workers: opts.workers,
+ BatchSize: opts.batch,
+ TargetEPS: opts.targetEPS,
+ Requested: opts.total,
+ Attempted: st.attempted.Load(),
+ Accepted: accepted,
+ Rejected: st.rejected.Load(),
+ Refused: st.refused.Load(),
+ TransportErrors: st.transport.Load(),
+ AcceptedEPS: eps,
+ StatusCounts: st.statusCounts(),
+ SeqLow: 0,
+ SeqHigh: high,
+ PayloadBytesTotal: st.bodyBytes.Load(),
+ PayloadBytesPerEvent: func() float64 {
+ attempted := st.attempted.Load()
+ if attempted <= 0 {
+ return 0
+ }
+ return float64(st.bodyBytes.Load()) / float64(attempted)
+ }(),
}
}