ingest: filter BIT-SMOKE- intentional probe events
Reserved BIT-SMOKE- messages (e.g. wdmi-store /smoke/wdmi.js direct-ingest checks) are skipped at every ingest level so they do not open incidents or trigger BIT-309 loops. Bump noise ruleset to 1.0.2; extend unit and integration tests and ingest hardening runbook. Paperclip-Issue: BIT-942 Made-with: Cursor
This commit is contained in:
1 parent
a720e9486d
commit
82f549adbc
4 files changed
+74
-3
No files matched your search
@@ -32,7 +32,7 @@ Per-key overrides: set `rate_limit_max` and/or `rate_limit_window_ms` on the key
|
||||
|
||||
- Rules live in `ingest-api/src/lib/noisePolicy.ts`; ruleset id: `noise_ruleset_version` in the ingest response.
|
||||
- **Check:** send a known-noise payload (for example ResizeObserver message at non-fatal level); expect `skipped: true`, `noise_filtered_count` incremented, and no new `er_incidents` row.
|
||||
- **Check:** send the same pattern at `fatal` / `critical` level; expect **not** skipped (noise rules do not hide critical).
|
||||
- **Check:** send the same pattern at `fatal` / `critical` level; expect **not** skipped (noise rules do not hide critical), **except** messages containing reserved substring `BIT-SMOKE-` (intentional reporter smoke, e.g. wdmi-store `/smoke/wdmi.js`) — those are skipped at every level (`rule_id`: `bitreport_smoke_marker`).
|
||||
|
||||
## Rate limits
|
||||
|
||||
|
||||
@@ -222,6 +222,42 @@ describe.skipIf(!_testUrl)("two-project passive ingest (BIT-179)", () => {
|
||||
expect(Number((after[0] as { c: number }).c)).toBe(_nBefore);
|
||||
});
|
||||
|
||||
it("skips BIT-SMOKE- intentional probe events without inserting rows", async () => {
|
||||
const [before] = await _pool.execute<RowDataPacket[]>(
|
||||
`SELECT COUNT(*) AS c FROM er_incidents WHERE project_id = ?`,
|
||||
[_projectIdA],
|
||||
);
|
||||
const _nBefore = Number((before[0] as { c: number }).c);
|
||||
const _res = await _app.inject({
|
||||
method: "POST",
|
||||
url: "/v1/ingest/events",
|
||||
headers: { authorization: `Bearer ${_tokenA}` },
|
||||
payload: {
|
||||
events: [
|
||||
{
|
||||
schema_version: 1,
|
||||
occurred_at: "2026-04-05T10:00:00.000Z",
|
||||
level: "error",
|
||||
message: "Error: BIT-SMOKE-WDMI-DIRECT-INGEST",
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
expect(_res.statusCode).toBe(200);
|
||||
const _body = JSON.parse(_res.body) as {
|
||||
noise_filtered_count: number;
|
||||
results: Array<{ skipped?: boolean; rule_id?: string }>;
|
||||
};
|
||||
expect(_body.noise_filtered_count).toBe(1);
|
||||
expect(_body.results[0]?.skipped).toBe(true);
|
||||
expect(_body.results[0]?.rule_id).toBe("bitreport_smoke_marker");
|
||||
const [after] = await _pool.execute<RowDataPacket[]>(
|
||||
`SELECT COUNT(*) AS c FROM er_incidents WHERE project_id = ?`,
|
||||
[_projectIdA],
|
||||
);
|
||||
expect(Number((after[0] as { c: number }).c)).toBe(_nBefore);
|
||||
});
|
||||
|
||||
it("replays identical idempotent requests", async () => {
|
||||
const _payload = {
|
||||
events: [
|
||||
|
||||
@@ -75,4 +75,30 @@ describe("evaluateNoise", () => {
|
||||
});
|
||||
expect(_r).toEqual({ matched: false });
|
||||
});
|
||||
|
||||
it("matches reserved BIT-SMOKE- probe messages (wdmi direct ingest smoke)", () => {
|
||||
const _r = evaluateNoise({
|
||||
level: "error",
|
||||
message: "Error: BIT-SMOKE-WDMI-DIRECT-INGEST",
|
||||
filePathHint: "/smoke/wdmi.js",
|
||||
});
|
||||
expect(_r).toEqual({
|
||||
matched: true,
|
||||
ruleId: "bitreport_smoke_marker",
|
||||
reason: "filtered_intentional_smoke_event",
|
||||
});
|
||||
});
|
||||
|
||||
it("suppresses BIT-SMOKE- even at critical ingest level", () => {
|
||||
const _r = evaluateNoise({
|
||||
level: "critical",
|
||||
message: "BIT-SMOKE-WDMI-DIRECT-INGEST",
|
||||
filePathHint: "",
|
||||
});
|
||||
expect(_r).toEqual({
|
||||
matched: true,
|
||||
ruleId: "bitreport_smoke_marker",
|
||||
reason: "filtered_intentional_smoke_event",
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -4,7 +4,7 @@ import { normalizeLevelToSeverity } from "./normalize.js";
|
||||
* Versioned ruleset id (document in release notes when rules change).
|
||||
* Rule inventory and validation steps: `docs/operations/ingest-hardening-runbook.md`.
|
||||
*/
|
||||
export const NOISE_RULESET_VERSION = "1.0.1";
|
||||
export const NOISE_RULESET_VERSION = "1.0.2";
|
||||
|
||||
export type NoiseEvaluation =
|
||||
| { matched: false }
|
||||
@@ -127,6 +127,8 @@ const _RULES: NoiseRule[] = [
|
||||
|
||||
/**
|
||||
* Conservative: never classify fatal/critical ingest levels as noise (avoid hiding real outages).
|
||||
* Exception: reserved `BIT-SMOKE-` messages are intentional end-to-end probes (e.g. wdmi-store
|
||||
* `/smoke/wdmi.js`) and are filtered at every ingest level so they do not open incidents.
|
||||
*/
|
||||
export function evaluateNoise(input: {
|
||||
level: string;
|
||||
@@ -134,11 +136,18 @@ export function evaluateNoise(input: {
|
||||
context?: Record<string, unknown>;
|
||||
filePathHint: string;
|
||||
}): NoiseEvaluation {
|
||||
const _msg = input.message.trim();
|
||||
if (_msg.includes("BIT-SMOKE-")) {
|
||||
return {
|
||||
matched: true,
|
||||
ruleId: "bitreport_smoke_marker",
|
||||
reason: "filtered_intentional_smoke_event",
|
||||
};
|
||||
}
|
||||
const _sev = normalizeLevelToSeverity(input.level);
|
||||
if (_sev === "critical") {
|
||||
return { matched: false };
|
||||
}
|
||||
const _msg = input.message;
|
||||
const _msgLower = _msg.toLowerCase();
|
||||
const _file = input.filePathHint;
|
||||
const _fileLower = _file.toLowerCase();
|
||||
|
||||
Reference in new issue
Block a user