: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(logs): explain-changes pivot from the logs view (#69712)
Jon McCallumaab665f72bd1
diff --git a/products/logs/frontend/components/LogsPatterns/logsPatternsLogic.test.ts b/products/logs/frontend/components/LogsPatterns/logsPatternsLogic.test.tsindex 829508a2a3bc..a92ed7e3a8d1 100644--- a/products/logs/frontend/components/LogsPatterns/logsPatternsLogic.test.ts+++ b/products/logs/frontend/components/LogsPatterns/logsPatternsLogic.test.ts@@ -232,6 +232,24 @@ describe('logsPatternsLogic', () => {)})+ it('openPatternsComparison before mount arms compare so mounting loads the diff', async () => {+ // The "explain changes" button lives in the Logs view and fires before this logic+ // exists: it arms compare state on the config logic, then the view switch mounts+ // Patterns. If afterMount ignored that state and ran the plain mine, the button+ // would silently answer the wrong question.+ mockDiffCreate.mockResolvedValue(DIFF_RESPONSE)+ const configLogic = logsViewerConfigLogic({ id: ID })+ configLogic.mount()++ configLogic.actions.openPatternsComparison('preceding')+ expect(configLogic.values.viewMode).toBe('patterns')++ logic.mount()+ await expectLogic(logic).toDispatchActions(['loadDiff', 'loadDiffSuccess'])+ expect(mockCreate).not.toHaveBeenCalled()+ expect(logic.values.baselineMode).toBe('preceding')+ })+it('surfaces a load failure as patternsError and clears it on the next success', async () => {silenceKeaLoadersErrors()// A failed mine (e.g. sampling query over budget) must not render as "no patterns".@@ -247,6 +265,24 @@ describe('logsPatternsLogic', () => {expect(logic.values.patternsError).toBeNull()})+ it('a diff failure does not surface as an error once compare is toggled off', async () => {+ silenceKeaLoadersErrors()+ // The two loaders run independently: toggling compare off fires a plain mine without+ // cancelling an in-flight diff. If that stale diff fails afterwards, its error must not+ // clobber the successful plain-mine table's "no patterns" empty state.+ mockDiffCreate.mockRejectedValueOnce(new Error('estimated query execution time is too long'))+ logic.mount()+ await expectLogic(logic).toDispatchActions(['loadPatternsSuccess'])++ logic.actions.setCompareEnabled(true)+ await expectLogic(logic).toDispatchActions(['loadDiff', 'loadDiffFailure'])+ expect(logic.values.patternsError).toBeTruthy()++ logic.actions.setCompareEnabled(false)+ await expectLogic(logic).toDispatchActions(['loadPatterns', 'loadPatternsSuccess'])+ expect(logic.values.patternsError).toBeNull()+ })+it('reloads when a shared filter changes', async () => {// Mining only re-runs while Patterns is the active view (the logic is mounted only then).const configLogic = logsViewerConfigLogic({ id: ID })diff --git a/products/logs/frontend/components/LogsPatterns/logsPatternsLogic.ts b/products/logs/frontend/components/LogsPatterns/logsPatternsLogic.tsindex e2be104634ba..a2d1dc55b92b 100644--- a/products/logs/frontend/components/LogsPatterns/logsPatternsLogic.ts+++ b/products/logs/frontend/components/LogsPatterns/logsPatternsLogic.ts@@ -30,11 +30,6 @@ export interface LogsPatternsLogicProps {id: string}-// 'lastWeek' omits baselineDateRange so the backend defaults to the same window one week-// earlier (absorbs daily/weekly cycles); 'preceding' compares against the window immediately-// before the current one (the post-deploy / incident-onset comparison).-export type PatternsBaselineMode = 'lastWeek' | 'preceding'-// The severity filter is an exact match on these six buckets; a sampled severity outside them// (e.g. "notice") can't be expressed, so applying the filter would silently exclude those lines.const CANONICAL_SEVERITIES = ['trace', 'debug', 'info', 'warn', 'error', 'fatal']@@ -86,7 +81,7 @@ export const logsPatternsLogic = kea<logsPatternsLogicType>([logsViewerFiltersLogic({ id: props.id }),['filters', 'utcDateRange', 'queryFilterGroup'],logsViewerConfigLogic({ id: props.id }),- ['viewMode'],+ ['viewMode', 'compareEnabled', 'baselineMode'],],actions: [logsViewerFiltersLogic({ id: props.id }),@@ -101,14 +96,12 @@ export const logsPatternsLogic = kea<logsPatternsLogicType>(['setPinnedFilters',],logsViewerConfigLogic({ id: props.id }),- ['setViewMode'],+ ['setViewMode', 'setCompareEnabled', 'setBaselineMode'],],})),actions({viewMatchingLogs: (pattern: _LogPatternApi) => ({ pattern }),- setCompareEnabled: (enabled: boolean) => ({ enabled }),- setBaselineMode: (mode: PatternsBaselineMode) => ({ mode }),}),loaders(({ values }) => ({@@ -144,34 +137,38 @@ export const logsPatternsLogic = kea<logsPatternsLogicType>([})),// A failed mine (e.g. the sampling query exceeding its execution budget) must surface as- // an error, not render as "no patterns found" — that would misrepresent the data.+ // an error, not render as "no patterns found" — that would misrepresent the data. The two+ // modes track their own error: the loaders run independently (toggling compare off fires a+ // plain mine without cancelling an in-flight diff), so a shared error would let a stale diff+ // failure clobber a successful plain-mine table's empty state.reducers({- patternsError: [+ mineError: [null as string | null,{loadPatterns: () => null,loadPatternsSuccess: () => null,loadPatternsFailure: (_, { error }) => error ?? 'Pattern analysis failed',- loadDiff: () => null,- loadDiffSuccess: () => null,- loadDiffFailure: (_, { error }) => error ?? 'Pattern comparison failed',- },- ],- compareEnabled: [- false,- {- setCompareEnabled: (_, { enabled }) => enabled,},],- baselineMode: [- 'lastWeek' as PatternsBaselineMode,+ diffError: [+ null as string | null,{- setBaselineMode: (_, { mode }) => mode,+ loadDiff: () => null,+ loadDiffSuccess: () => null,+ loadDiffFailure: (_, { error }) => error ?? 'Pattern comparison failed',},],}),selectors({+ // Surface only the active mode's error. The loaders run independently, so a stale diff+ // failure landing after the user toggled compare off must not overwrite the successful+ // plain-mine table's empty state (and vice versa).+ patternsError: [+ (s) => [s.compareEnabled, s.mineError, s.diffError],+ (compareEnabled: boolean, mineError: string | null, diffError: string | null): string | null =>+ compareEnabled ? diffError : mineError,+ ],// The shared query body for both the mine and the diff — the diff must scope its two// windows with exactly the filters a plain mine would use, or compare mode would// silently answer a different question than the table next to it.@@ -310,7 +307,14 @@ export const logsPatternsLogic = kea<logsPatternsLogicType>([}}),- afterMount(({ actions }) => {- actions.loadPatterns()+ afterMount(({ actions, values }) => {+ // Compare may already be armed before this logic mounts — e.g. "explain changes" in the+ // Logs view dispatches openPatternsComparison on the config logic, then the view switch+ // mounts Patterns. Loading the plain mine here would answer the wrong question.+ if (values.compareEnabled) {+ actions.loadDiff()+ } else {+ actions.loadPatterns()+ }}),])diff --git a/products/logs/frontend/components/LogsViewer/LogsDisplayBar.tsx b/products/logs/frontend/components/LogsViewer/LogsDisplayBar.tsxindex aabb6d119dae..ed70cf500f86 100644--- a/products/logs/frontend/components/LogsViewer/LogsDisplayBar.tsx+++ b/products/logs/frontend/components/LogsViewer/LogsDisplayBar.tsx@@ -40,7 +40,7 @@ export const LogsDisplayBar = ({totalLogsCount,}: LogsDisplayBarProps): JSX.Element => {const { facetRailCollapsed, viewMode, groupBy } = useValues(logsViewerConfigLogic)- const { setFacetRailCollapsed, setViewMode, setGroupBy } = useActions(logsViewerConfigLogic)+ const { setFacetRailCollapsed, setViewMode, setGroupBy, openPatternsComparison } = useActions(logsViewerConfigLogic)const showPatternsView = useFeatureFlag('LOGS_PATTERNS_VIEW')const showGroupBy = useFeatureFlag('LOGS_GROUP_BY')@@ -124,6 +124,16 @@ export const LogsDisplayBar = ({<span className="text-muted text-xs">{humanFriendlyNumber(totalLogsCount)} logs</span>))}+ {showPatternsView && !inPatternsMode && !inGroupByMode && (+ <LemonButton+ size="small"+ onClick={() => openPatternsComparison('preceding')}+ tooltip="Mine this window's log patterns and compare them against the period just before it — new and shifted message templates first. Drag-select a spike on the chart first to explain exactly that range."+ data-attr="logs-explain-changes"+ >+ Explain changes+ </LemonButton>+ )}</div>{!inPatternsMode && !inGroupByMode && <LogsViewerToolbar totalLogsCount={totalLogsCount} />}</div>diff --git a/products/logs/frontend/components/LogsViewer/config/logsViewerConfigLogic.ts b/products/logs/frontend/components/LogsViewer/config/logsViewerConfigLogic.tsindex 9387ec0ccc04..17aa26917e1d 100644--- a/products/logs/frontend/components/LogsViewer/config/logsViewerConfigLogic.ts+++ b/products/logs/frontend/components/LogsViewer/config/logsViewerConfigLogic.ts@@ -33,6 +33,11 @@ export const DEFAULT_ORDER_BY: LogsOrderBy = 'latest'export type LogsViewerViewMode = 'logs' | 'patterns' | 'group'export const DEFAULT_VIEW_MODE: LogsViewerViewMode = 'logs'+// Patterns compare-mode baseline: 'lastWeek' omits the explicit range so the backend defaults+// to the same window one week earlier (absorbs daily/weekly cycles); 'preceding' compares+// against the window immediately before the current one (the post-deploy / spike comparison).+export type PatternsBaselineMode = 'lastWeek' | 'preceding'+export interface LogsViewerGroupBy {key: string// Where the key lives, in the group-by endpoint's vocabulary: "log" / "resource"@@ -61,6 +66,12 @@ export const logsViewerConfigLogic = kea<logsViewerConfigLogicType>([setFacetRailCollapsed: (facetRailCollapsed: boolean) => ({ facetRailCollapsed }),setViewMode: (viewMode: LogsViewerViewMode) => ({ viewMode }),setGroupBy: (groupBy: LogsViewerGroupBy | null) => ({ groupBy }),+ setCompareEnabled: (enabled: boolean) => ({ enabled }),+ setBaselineMode: (mode: PatternsBaselineMode) => ({ mode }),+ // One-click "explain this window": open the Patterns view in compare mode against the+ // given baseline. Atomic so callers in other views (Logs toolbar, alert scenes) can't+ // half-configure the pivot.+ openPatternsComparison: (mode: PatternsBaselineMode) => ({ mode }),// Typed columns (unified column model)setColumns: (columns: LogsColumnConfig[]) => ({ columns }),@@ -113,6 +124,24 @@ export const logsViewerConfigLogic = kea<logsViewerConfigLogicType>([DEFAULT_VIEW_MODE as LogsViewerViewMode,{setViewMode: (_, { viewMode }) => viewMode,+ openPatternsComparison: () => 'patterns' as LogsViewerViewMode,+ },+ ],+ // Compare state lives here (not in logsPatternsLogic) so views other than Patterns can+ // arm the comparison before the patterns logic mounts, and the choice survives+ // Logs↔Patterns switches within a visit. Not persisted, like viewMode and groupBy.+ compareEnabled: [+ false,+ {+ setCompareEnabled: (_, { enabled }) => enabled,+ openPatternsComparison: () => true,+ },+ ],+ baselineMode: [+ 'lastWeek' as PatternsBaselineMode,+ {+ setBaselineMode: (_, { mode }) => mode,+ openPatternsComparison: (_, { mode }) => mode,},],columns: [diff --git a/products/logs/mcp/prompts/logs-patterns-diff.md b/products/logs/mcp/prompts/logs-patterns-diff.mdindex 5bf7a782025f..b46c5767acfb 100644--- a/products/logs/mcp/prompts/logs-patterns-diff.md+++ b/products/logs/mcp/prompts/logs-patterns-diff.md@@ -5,6 +5,7 @@ All parameters must be nested inside a `query` object, with an optional sibling# When to use- **Incident triage (the primary loop):** set `query.dateRange` to the incident window. Omit `baselineDateRange` (defaults to the same window one week earlier) or set it to a known-good window just before the incident. The `new` and biggest `rate_shift` entries are your suspects; pivot to their raw lines with `query-logs`.+- **Explain a spike:** when a count or sparkline shows a spike (e.g. from `logs-count-ranges`), set `query.dateRange` to the spike window and `baselineDateRange` to the window just before it — the top `new` and `rate_shift` entries are the explanation. This is one call; do not mine the two windows separately and diff them yourself.- **Post-deploy check:** current window = since the deploy; `baselineDateRange` = the same-length window just before it. New error-severity templates right after a deploy are the classic regression signature.- **"What changed this week?"** — current = `-1d`, baseline auto. Good periodic sweep for a service you own.diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex eb81f2ac0084..1748218c9814 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -5618,7 +5618,7 @@"feature_flag": "logs-patterns-view"},"logs-patterns-diff": {- "description": "Compare the log patterns of two time windows and return what changed: templates that are **new**, templates whose rate **shifted** (with magnitude, e.g. 4x), and templates that are **gone**. This is the single most useful call for incident triage — \"what is different about now vs. before it broke\" in one round trip, instead of mining two windows yourself and hand-matching templates.\n\nAll parameters must be nested inside a `query` object, with an optional sibling `baselineDateRange`.\n\n# When to use\n\n- **Incident triage (the primary loop):** set `query.dateRange` to the incident window. Omit `baselineDateRange` (defaults to the same window one week earlier) or set it to a known-good window just before the incident. The `new` and biggest `rate_shift` entries are your suspects; pivot to their raw lines with `query-logs`.\n- **Post-deploy check:** current window = since the deploy; `baselineDateRange` = the same-length window just before it. New error-severity templates right after a deploy are the classic regression signature.\n- **\"What changed this week?\"** — current = `-1d`, baseline auto. Good periodic sweep for a service you own.\n\n## Pick the right tool\n\n- Just summarize one window's content → `logs-patterns`.\n- Explain a _count_ change without needing message content → `logs-count-ranges` (cheaper).\n- Use **this** tool when you need to know _which messages_ are new or behaving differently between two periods.\n\n# Reading the response\n\nEntries come sorted most-interesting-first: `new` (by volume), then `rate_shift` (by magnitude), then `gone`, then `unchanged`.\n\n- `classification` — trust the labels; the thresholds already handle sampling honesty:\n - `new` requires clearing a novelty floor (~1% volume share, or any error/fatal lines). Below the floor, absence from the baseline sample is not evidence of novelty.\n - `rate_shift` requires ≥2x change in per-second rate (windows of different lengths are normalized) _and_ enough raw samples on both sides.\n - `unchanged` means \"no confident claim\", not \"provably identical\".\n- `rate_ratio` — current rate / baseline rate. 4.0 = 4x faster now, 0.25 = quartered.\n- `pattern` — full pattern stats including `match_regex` / `match_literal`, so you can pivot straight to the matching lines (same recipe as `logs-patterns`: message regex filter + the pattern's services/severities).\n- **Check `baseline.total_count` before trusting a wall of `new` entries** — an empty or tiny baseline (logging only started recently, service didn't exist last week) makes everything look new.\n- Both windows are mined from samples (`sampled: true`), so counts are estimates and templates rarer than ~1 in 10,000 rows may be invisible in either window.\n\nTemplate identity across the two windows is fingerprint-based (literal content), so the miner rendering `User <*> not found` in one window and `User <num> not found` in the other still compares as one pattern rather than a false new+gone pair.\n\n# Parameters\n\n## query.dateRange\n\nThe current (foreground) window — the period you are investigating. Same format as `logs-patterns`.\n\n## baselineDateRange\n\nOptional, sibling of `query` (not inside it). The comparison window. Omit for the default: the current window shifted back exactly one week, which absorbs daily/weekly volume cycles. Provide explicitly to compare against a pre-deploy or pre-incident period. It does not need to be the same length as the current window — rates are normalized per second.\n\n## query.severityLevels / query.serviceNames / query.searchTerm / query.filterGroup\n\nSame as `logs-patterns`; applied to **both** windows. Scoping by service is recommended — it prunes both scans and focuses the sample budget.\n\n# Examples\n\n## What changed during the incident vs. just before it\n\n```json\n{\n \"query\": {\n \"dateRange\": { \"date_from\": \"2026-07-07T09:30:00Z\", \"date_to\": \"2026-07-07T10:30:00Z\" },\n \"serviceNames\": [\"checkout\"]\n },\n \"baselineDateRange\": { \"date_from\": \"2026-07-07T08:00:00Z\", \"date_to\": \"2026-07-07T09:00:00Z\" }\n}\n```\n\n## What is new or different today vs. the same time last week\n\n```json\n{ \"query\": { \"dateRange\": { \"date_from\": \"-1d\" } } }\n```\n\n## Did the deploy change what the service logs?\n\n```json\n{\n \"query\": {\n \"dateRange\": { \"date_from\": \"2026-07-07T14:00:00Z\" },\n \"serviceNames\": [\"api\"]\n },\n \"baselineDateRange\": { \"date_from\": \"2026-07-07T10:00:00Z\", \"date_to\": \"2026-07-07T14:00:00Z\" }\n}\n```",+ "description": "Compare the log patterns of two time windows and return what changed: templates that are **new**, templates whose rate **shifted** (with magnitude, e.g. 4x), and templates that are **gone**. This is the single most useful call for incident triage — \"what is different about now vs. before it broke\" in one round trip, instead of mining two windows yourself and hand-matching templates.\n\nAll parameters must be nested inside a `query` object, with an optional sibling `baselineDateRange`.\n\n# When to use\n\n- **Incident triage (the primary loop):** set `query.dateRange` to the incident window. Omit `baselineDateRange` (defaults to the same window one week earlier) or set it to a known-good window just before the incident. The `new` and biggest `rate_shift` entries are your suspects; pivot to their raw lines with `query-logs`.\n- **Explain a spike:** when a count or sparkline shows a spike (e.g. from `logs-count-ranges`), set `query.dateRange` to the spike window and `baselineDateRange` to the window just before it — the top `new` and `rate_shift` entries are the explanation. This is one call; do not mine the two windows separately and diff them yourself.\n- **Post-deploy check:** current window = since the deploy; `baselineDateRange` = the same-length window just before it. New error-severity templates right after a deploy are the classic regression signature.\n- **\"What changed this week?\"** — current = `-1d`, baseline auto. Good periodic sweep for a service you own.\n\n## Pick the right tool\n\n- Just summarize one window's content → `logs-patterns`.\n- Explain a _count_ change without needing message content → `logs-count-ranges` (cheaper).\n- Use **this** tool when you need to know _which messages_ are new or behaving differently between two periods.\n\n# Reading the response\n\nEntries come sorted most-interesting-first: `new` (by volume), then `rate_shift` (by magnitude), then `gone`, then `unchanged`.\n\n- `classification` — trust the labels; the thresholds already handle sampling honesty:\n - `new` requires clearing a novelty floor (~1% volume share, or any error/fatal lines). Below the floor, absence from the baseline sample is not evidence of novelty.\n - `rate_shift` requires ≥2x change in per-second rate (windows of different lengths are normalized) _and_ enough raw samples on both sides.\n - `unchanged` means \"no confident claim\", not \"provably identical\".\n- `rate_ratio` — current rate / baseline rate. 4.0 = 4x faster now, 0.25 = quartered.\n- `pattern` — full pattern stats including `match_regex` / `match_literal`, so you can pivot straight to the matching lines (same recipe as `logs-patterns`: message regex filter + the pattern's services/severities).\n- **Check `baseline.total_count` before trusting a wall of `new` entries** — an empty or tiny baseline (logging only started recently, service didn't exist last week) makes everything look new.\n- Both windows are mined from samples (`sampled: true`), so counts are estimates and templates rarer than ~1 in 10,000 rows may be invisible in either window.\n\nTemplate identity across the two windows is fingerprint-based (literal content), so the miner rendering `User <*> not found` in one window and `User <num> not found` in the other still compares as one pattern rather than a false new+gone pair.\n\n# Parameters\n\n## query.dateRange\n\nThe current (foreground) window — the period you are investigating. Same format as `logs-patterns`.\n\n## baselineDateRange\n\nOptional, sibling of `query` (not inside it). The comparison window. Omit for the default: the current window shifted back exactly one week, which absorbs daily/weekly volume cycles. Provide explicitly to compare against a pre-deploy or pre-incident period. It does not need to be the same length as the current window — rates are normalized per second.\n\n## query.severityLevels / query.serviceNames / query.searchTerm / query.filterGroup\n\nSame as `logs-patterns`; applied to **both** windows. Scoping by service is recommended — it prunes both scans and focuses the sample budget.\n\n# Examples\n\n## What changed during the incident vs. just before it\n\n```json\n{\n \"query\": {\n \"dateRange\": { \"date_from\": \"2026-07-07T09:30:00Z\", \"date_to\": \"2026-07-07T10:30:00Z\" },\n \"serviceNames\": [\"checkout\"]\n },\n \"baselineDateRange\": { \"date_from\": \"2026-07-07T08:00:00Z\", \"date_to\": \"2026-07-07T09:00:00Z\" }\n}\n```\n\n## What is new or different today vs. the same time last week\n\n```json\n{ \"query\": { \"dateRange\": { \"date_from\": \"-1d\" } } }\n```\n\n## Did the deploy change what the service logs?\n\n```json\n{\n \"query\": {\n \"dateRange\": { \"date_from\": \"2026-07-07T14:00:00Z\" },\n \"serviceNames\": [\"api\"]\n },\n \"baselineDateRange\": { \"date_from\": \"2026-07-07T10:00:00Z\", \"date_to\": \"2026-07-07T14:00:00Z\" }\n}\n```","category": "Logs","feature": "logs","summary": "Diff log patterns between two windows",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 481657550a47..48156d5346d3 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -6054,7 +6054,7 @@"feature_flag": "logs-patterns-view"},"logs-patterns-diff": {- "description": "Compare the log patterns of two time windows and return what changed: templates that are **new**, templates whose rate **shifted** (with magnitude, e.g. 4x), and templates that are **gone**. This is the single most useful call for incident triage — \"what is different about now vs. before it broke\" in one round trip, instead of mining two windows yourself and hand-matching templates.\n\nAll parameters must be nested inside a `query` object, with an optional sibling `baselineDateRange`.\n\n# When to use\n\n- **Incident triage (the primary loop):** set `query.dateRange` to the incident window. Omit `baselineDateRange` (defaults to the same window one week earlier) or set it to a known-good window just before the incident. The `new` and biggest `rate_shift` entries are your suspects; pivot to their raw lines with `query-logs`.\n- **Post-deploy check:** current window = since the deploy; `baselineDateRange` = the same-length window just before it. New error-severity templates right after a deploy are the classic regression signature.\n- **\"What changed this week?\"** — current = `-1d`, baseline auto. Good periodic sweep for a service you own.\n\n## Pick the right tool\n\n- Just summarize one window's content → `logs-patterns`.\n- Explain a _count_ change without needing message content → `logs-count-ranges` (cheaper).\n- Use **this** tool when you need to know _which messages_ are new or behaving differently between two periods.\n\n# Reading the response\n\nEntries come sorted most-interesting-first: `new` (by volume), then `rate_shift` (by magnitude), then `gone`, then `unchanged`.\n\n- `classification` — trust the labels; the thresholds already handle sampling honesty:\n - `new` requires clearing a novelty floor (~1% volume share, or any error/fatal lines). Below the floor, absence from the baseline sample is not evidence of novelty.\n - `rate_shift` requires ≥2x change in per-second rate (windows of different lengths are normalized) _and_ enough raw samples on both sides.\n - `unchanged` means \"no confident claim\", not \"provably identical\".\n- `rate_ratio` — current rate / baseline rate. 4.0 = 4x faster now, 0.25 = quartered.\n- `pattern` — full pattern stats including `match_regex` / `match_literal`, so you can pivot straight to the matching lines (same recipe as `logs-patterns`: message regex filter + the pattern's services/severities).\n- **Check `baseline.total_count` before trusting a wall of `new` entries** — an empty or tiny baseline (logging only started recently, service didn't exist last week) makes everything look new.\n- Both windows are mined from samples (`sampled: true`), so counts are estimates and templates rarer than ~1 in 10,000 rows may be invisible in either window.\n\nTemplate identity across the two windows is fingerprint-based (literal content), so the miner rendering `User <*> not found` in one window and `User <num> not found` in the other still compares as one pattern rather than a false new+gone pair.\n\n# Parameters\n\n## query.dateRange\n\nThe current (foreground) window — the period you are investigating. Same format as `logs-patterns`.\n\n## baselineDateRange\n\nOptional, sibling of `query` (not inside it). The comparison window. Omit for the default: the current window shifted back exactly one week, which absorbs daily/weekly volume cycles. Provide explicitly to compare against a pre-deploy or pre-incident period. It does not need to be the same length as the current window — rates are normalized per second.\n\n## query.severityLevels / query.serviceNames / query.searchTerm / query.filterGroup\n\nSame as `logs-patterns`; applied to **both** windows. Scoping by service is recommended — it prunes both scans and focuses the sample budget.\n\n# Examples\n\n## What changed during the incident vs. just before it\n\n```json\n{\n \"query\": {\n \"dateRange\": { \"date_from\": \"2026-07-07T09:30:00Z\", \"date_to\": \"2026-07-07T10:30:00Z\" },\n \"serviceNames\": [\"checkout\"]\n },\n \"baselineDateRange\": { \"date_from\": \"2026-07-07T08:00:00Z\", \"date_to\": \"2026-07-07T09:00:00Z\" }\n}\n```\n\n## What is new or different today vs. the same time last week\n\n```json\n{ \"query\": { \"dateRange\": { \"date_from\": \"-1d\" } } }\n```\n\n## Did the deploy change what the service logs?\n\n```json\n{\n \"query\": {\n \"dateRange\": { \"date_from\": \"2026-07-07T14:00:00Z\" },\n \"serviceNames\": [\"api\"]\n },\n \"baselineDateRange\": { \"date_from\": \"2026-07-07T10:00:00Z\", \"date_to\": \"2026-07-07T14:00:00Z\" }\n}\n```",+ "description": "Compare the log patterns of two time windows and return what changed: templates that are **new**, templates whose rate **shifted** (with magnitude, e.g. 4x), and templates that are **gone**. This is the single most useful call for incident triage — \"what is different about now vs. before it broke\" in one round trip, instead of mining two windows yourself and hand-matching templates.\n\nAll parameters must be nested inside a `query` object, with an optional sibling `baselineDateRange`.\n\n# When to use\n\n- **Incident triage (the primary loop):** set `query.dateRange` to the incident window. Omit `baselineDateRange` (defaults to the same window one week earlier) or set it to a known-good window just before the incident. The `new` and biggest `rate_shift` entries are your suspects; pivot to their raw lines with `query-logs`.\n- **Explain a spike:** when a count or sparkline shows a spike (e.g. from `logs-count-ranges`), set `query.dateRange` to the spike window and `baselineDateRange` to the window just before it — the top `new` and `rate_shift` entries are the explanation. This is one call; do not mine the two windows separately and diff them yourself.\n- **Post-deploy check:** current window = since the deploy; `baselineDateRange` = the same-length window just before it. New error-severity templates right after a deploy are the classic regression signature.\n- **\"What changed this week?\"** — current = `-1d`, baseline auto. Good periodic sweep for a service you own.\n\n## Pick the right tool\n\n- Just summarize one window's content → `logs-patterns`.\n- Explain a _count_ change without needing message content → `logs-count-ranges` (cheaper).\n- Use **this** tool when you need to know _which messages_ are new or behaving differently between two periods.\n\n# Reading the response\n\nEntries come sorted most-interesting-first: `new` (by volume), then `rate_shift` (by magnitude), then `gone`, then `unchanged`.\n\n- `classification` — trust the labels; the thresholds already handle sampling honesty:\n - `new` requires clearing a novelty floor (~1% volume share, or any error/fatal lines). Below the floor, absence from the baseline sample is not evidence of novelty.\n - `rate_shift` requires ≥2x change in per-second rate (windows of different lengths are normalized) _and_ enough raw samples on both sides.\n - `unchanged` means \"no confident claim\", not \"provably identical\".\n- `rate_ratio` — current rate / baseline rate. 4.0 = 4x faster now, 0.25 = quartered.\n- `pattern` — full pattern stats including `match_regex` / `match_literal`, so you can pivot straight to the matching lines (same recipe as `logs-patterns`: message regex filter + the pattern's services/severities).\n- **Check `baseline.total_count` before trusting a wall of `new` entries** — an empty or tiny baseline (logging only started recently, service didn't exist last week) makes everything look new.\n- Both windows are mined from samples (`sampled: true`), so counts are estimates and templates rarer than ~1 in 10,000 rows may be invisible in either window.\n\nTemplate identity across the two windows is fingerprint-based (literal content), so the miner rendering `User <*> not found` in one window and `User <num> not found` in the other still compares as one pattern rather than a false new+gone pair.\n\n# Parameters\n\n## query.dateRange\n\nThe current (foreground) window — the period you are investigating. Same format as `logs-patterns`.\n\n## baselineDateRange\n\nOptional, sibling of `query` (not inside it). The comparison window. Omit for the default: the current window shifted back exactly one week, which absorbs daily/weekly volume cycles. Provide explicitly to compare against a pre-deploy or pre-incident period. It does not need to be the same length as the current window — rates are normalized per second.\n\n## query.severityLevels / query.serviceNames / query.searchTerm / query.filterGroup\n\nSame as `logs-patterns`; applied to **both** windows. Scoping by service is recommended — it prunes both scans and focuses the sample budget.\n\n# Examples\n\n## What changed during the incident vs. just before it\n\n```json\n{\n \"query\": {\n \"dateRange\": { \"date_from\": \"2026-07-07T09:30:00Z\", \"date_to\": \"2026-07-07T10:30:00Z\" },\n \"serviceNames\": [\"checkout\"]\n },\n \"baselineDateRange\": { \"date_from\": \"2026-07-07T08:00:00Z\", \"date_to\": \"2026-07-07T09:00:00Z\" }\n}\n```\n\n## What is new or different today vs. the same time last week\n\n```json\n{ \"query\": { \"dateRange\": { \"date_from\": \"-1d\" } } }\n```\n\n## Did the deploy change what the service logs?\n\n```json\n{\n \"query\": {\n \"dateRange\": { \"date_from\": \"2026-07-07T14:00:00Z\" },\n \"serviceNames\": [\"api\"]\n },\n \"baselineDateRange\": { \"date_from\": \"2026-07-07T10:00:00Z\", \"date_to\": \"2026-07-07T14:00:00Z\" }\n}\n```","category": "Logs","feature": "logs","summary": "Diff log patterns between two windows",