feat(ingest): label er_ingest_events_total skipped_noise by rule_id
Break down noise filter counters per noise policy rule for Prometheus observability. Paperclip-Agent: David Santos (urlKey david-santos; id 0b1fcf92-5fe3-4ac0-9f29-df4ab72f5376) Paperclip-Issue: BIT-26791 Paperclip-Run: cea24469-2886-457d-9f6f-09d83aaf9e4a
This commit is contained in:
1 parent
caeb37ff0a
commit
23704d2e59
7 files changed
+43
-11
No files matched your search
@@ -239,16 +239,20 @@ export async function buildApp(input: { env: IngestEnv; pool: Pool }): Promise<F
|
||||
idempotencyKey: _idempotencyKey,
|
||||
bodyHash: _bodyHash,
|
||||
});
|
||||
// Track event outcomes
|
||||
// Track event outcomes (rule_id on skipped_noise for BIT-26791)
|
||||
if (_out.body && typeof _out.body === "object" && "results" in _out.body) {
|
||||
const results = (_out.body as { results: Array<{ skipped?: boolean }> }).results;
|
||||
const results = (
|
||||
_out.body as { results: Array<{ skipped?: boolean; rule_id?: string }> }
|
||||
).results;
|
||||
let stored = 0;
|
||||
let skipped = 0;
|
||||
let _maxOccurredSec = 0;
|
||||
const skippedByRule = new Map<string, number>();
|
||||
for (let _i = 0; _i < results.length; _i++) {
|
||||
const r = results[_i]!;
|
||||
if (r.skipped) {
|
||||
skipped++;
|
||||
const _ruleId =
|
||||
typeof r.rule_id === "string" && r.rule_id !== "" ? r.rule_id : "unknown";
|
||||
skippedByRule.set(_ruleId, (skippedByRule.get(_ruleId) ?? 0) + 1);
|
||||
continue;
|
||||
}
|
||||
stored++;
|
||||
@@ -262,8 +266,12 @@ export async function buildApp(input: { env: IngestEnv; pool: Pool }): Promise<F
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stored > 0) ingestEventsTotal.inc({ outcome: "stored" }, stored);
|
||||
if (skipped > 0) ingestEventsTotal.inc({ outcome: "skipped_noise" }, skipped);
|
||||
if (stored > 0) {
|
||||
ingestEventsTotal.inc({ outcome: "stored", rule_id: "" }, stored);
|
||||
}
|
||||
for (const [_ruleId, _n] of skippedByRule) {
|
||||
ingestEventsTotal.inc({ outcome: "skipped_noise", rule_id: _ruleId }, _n);
|
||||
}
|
||||
const _slug = request.ingestAuth.projectSlug;
|
||||
if (_slug !== "" && _maxOccurredSec > 0) {
|
||||
errorHubLastEventTimestamp.set({ project_slug: _slug }, _maxOccurredSec);
|
||||
@@ -284,7 +292,7 @@ export async function buildApp(input: { env: IngestEnv; pool: Pool }): Promise<F
|
||||
message: "occurred_at must be a valid ISO-8601 timestamp.",
|
||||
});
|
||||
}
|
||||
ingestEventsTotal.inc({ outcome: "error" }, _body.events.length);
|
||||
ingestEventsTotal.inc({ outcome: "error", rule_id: "" }, _body.events.length);
|
||||
const _slugErr = request.ingestAuth?.projectSlug ?? "";
|
||||
if (_slugErr !== "") {
|
||||
errorHubIngestFailuresTotal.inc({ project_slug: _slugErr }, _body.events.length);
|
||||
|
||||
Reference in new issue
Block a user