Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(logs): match severity_level filter key in drop rules (#63354)

Daniel Visca185911d7320d
diff --git a/nodejs/src/logs-ingestion/sampling/filter-group-match.test.ts b/nodejs/src/logs-ingestion/sampling/filter-group-match.test.ts
index 28a8e2950d56..b7f6aa2ab579 100644
--- a/nodejs/src/logs-ingestion/sampling/filter-group-match.test.ts
+++ b/nodejs/src/logs-ingestion/sampling/filter-group-match.test.ts
@@ -102,6 +102,19 @@ describe('matchFilterGroup', () => {
expect(matchFilterGroup(g, baseRecord({ severity_text: 'error' }))).toBe(true)
expect(matchFilterGroup(g, baseRecord({ severity_text: 'info' }))).toBe(false)
})
+ it('severity_level is an alias for severity_text (the key the drop-rule UI writes)', () => {
+ // Regression guard: the drop-rule builder persists severity filters as
+ // `{key: 'severity_level', type: 'log'}`. Before the alias existed this
+ // fell through to the `type: 'log'` body fallback and compared the log
+ // BODY against e.g. "info" — so UI-created severity rules never matched.
+ const g = group({
+ values: [{ key: 'severity_level', type: 'log', operator: 'exact', value: ['info'] }],
+ })
+ expect(matchFilterGroup(g, baseRecord({ severity_text: 'info' }))).toBe(true)
+ expect(matchFilterGroup(g, baseRecord({ severity_text: 'error' }))).toBe(false)
+ // Must not match via the body fallback.
+ expect(matchFilterGroup(g, baseRecord({ severity_text: 'error', body: 'info' }))).toBe(false)
+ })
it('level is an alias for severity_text (UI surfaces it this way)', () => {
const g = group({
values: [{ key: 'level', type: 'log_attribute', operator: 'exact', value: ['info', 'INFO'] }],
diff --git a/nodejs/src/logs-ingestion/sampling/filter-group-match.ts b/nodejs/src/logs-ingestion/sampling/filter-group-match.ts
index e20e7476160c..9f7641655565 100644
--- a/nodejs/src/logs-ingestion/sampling/filter-group-match.ts
+++ b/nodejs/src/logs-ingestion/sampling/filter-group-match.ts
@@ -80,14 +80,16 @@ function lookupRecordValue(filter: PropertyFilterLeaf, record: LogRecord): strin
// would silently miss real data.
return record.service_name ?? record.resource_attributes?.['service.name']
}
- if (key === 'severity_text' || key === 'level') {
+ if (key === 'severity_text' || key === 'level' || key === 'severity_level') {
// First-class column wins. Otherwise fall back to attribute storage,
// trying the SDK convention (`level` — Winston/Pino/Bunyan/log4j2) first
// and the OTel-style `severity_text` second. The fallback chain does not
// depend on which key the filter used, so `level: info` and
// `severity_text: info` always resolve to the same value for the same
// record (otherwise we'd silently disagree when only one of the two
- // attribute names is populated).
+ // attribute names is populated). `severity_level` is the logs UI / HogQL
+ // alias and the key the drop-rule builder writes; without this branch it
+ // falls through to the `type: 'log'` body fallback and never matches.
return record.severity_text ?? record.attributes?.['level'] ?? record.attributes?.['severity_text']
}
if (key === 'message' || filter.type === PROPERTY_FILTER_TYPE_LOG) {