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(data-warehouse): make the ETL scene reflect what the pipeline actually did (#108482)

Tom Owers1f2d2b50d571
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 7b402d4d9c0e..6393bd5a3db8 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -8859,13 +8859,13 @@ snapshots:
scenes-app-errortracking-linkedreports--several-reports-across-states--light:
hash: v1.k794b7964.fe2161a3bb0e898689ef58a342d071c353ded71ac270a62998ea566055359e7a.AnoCs1sNoTY6J1yl24yuZPh_1Jkjugz-jnYxHgY8ZyU
scenes-app-etl--healthy--dark:
- hash: v1.k794b7964.b014fe822cfc470eb04981917b5f28638647cac8feca4fa137c1b79365640623.S9NpXGsBnfAsXSAD2XWHhfIMtA2YmupBLf9DtD-_3EI
+ hash: v1.k794b7964.089b369b2c14ad62186846aeac2ba199350bbeb5938006a990813e86d2fe792f.azI7UlC6LJfxK7oem6akS12yttmxtUrAz2PgfjOGnAY
scenes-app-etl--healthy--light:
- hash: v1.k794b7964.d4c8ae82bcc3ad153bc7dc72f1f372c0d98d5a05a127bb4ab8cccb105f68f435.ylQlvdaOh5Ft3BQNFe1i_9bXUNUKU2lbRadlbNFHVSM
+ hash: v1.k794b7964.67c3c8bf986874ac2693e23f437912b8bb6413c6cbadc94a6d64f66367f934a5.uXG2VLv-329pEEzeWTK9fdpDOkzxlHxHV10dACQf-w4
scenes-app-etl--needs-attention--dark:
- hash: v1.k794b7964.97f183b4042023e78af8255ca342bc71e45d7ab44471d2b43872cd4b628fc55e.smS95IlHDwVE-094LYjLyY8mViUovxYg0aTO-rOCw10
+ hash: v1.k794b7964.a692bc11bcb8f43aacf00cbb903710fa4e3a206af239753d259009b65d15fbe2.twpUxi4BgMP4HedYol3gY2Fv3UFrCg3L5ZNXkKo9irE
scenes-app-etl--needs-attention--light:
- hash: v1.k794b7964.2c94576a10f6fab4a0940e803595c3251949ef656be2987d81a6b9783daf8133.UQ4cUFdnrkJH7YP2T7UelzPoLX8rBK9E6QFFIWZLijw
+ hash: v1.k794b7964.b5d11ee783dc6a1d388ea3df499d22a9c81bf0b5bed8741a5dd0b8ab0f9a455b.9wG3DFbZidOv5H33JDzkCqs7m3mYeaSJb8peEZu564s
scenes-app-events--event-explorer--dark:
hash: v1.k794b7964.3bf3b01d0972be5ad8fe4a7408d20b10e2431ea8f28874aa0a63f7623c1af97c.ONFJgVNjjG1f32eqlxRZuleSgdLpLGIcFhHN2S4yvhk
scenes-app-events--event-explorer--light:
diff --git a/products/data_warehouse/backend/presentation/pipeline_stats.py b/products/data_warehouse/backend/presentation/pipeline_stats.py
index 9cb25e49a2d3..45643d5833e9 100644
--- a/products/data_warehouse/backend/presentation/pipeline_stats.py
+++ b/products/data_warehouse/backend/presentation/pipeline_stats.py
@@ -44,6 +44,15 @@ class CompletedActivityQuerySerializer(PipelineActivityQuerySerializer):
default="completed",
help_text="Which outcome to return: 'completed' or 'failed'. Defaults to 'completed'.",
)
+ kind = serializers.ChoiceField(
+ choices=["all", "import", "model"],
+ required=False,
+ default="all",
+ help_text=(
+ "Which runs to return: 'import' for warehouse source syncs, 'model' for materialized "
+ "view runs, 'all' for both. Defaults to 'all'."
+ ),
+ )
class JobCountsSerializer(serializers.Serializer):
@@ -134,9 +143,19 @@ class DataHealthIssueSerializer(serializers.Serializer):
source_type = serializers.CharField(
allow_null=True, required=False, help_text="Source type for a sync issue, for example 'Stripe'."
)
+ sync_type = serializers.CharField(
+ allow_null=True,
+ required=False,
+ help_text=(
+ "How a sync issue's table is kept up to date, for example 'incremental' or 'webhook'. "
+ "A webhook table is pushed to rather than pulled on a schedule. Null for other types."
+ ),
+ )
status = serializers.CharField(help_text="Why it is unhealthy. One of: failed, disabled, degraded, billing_limit.")
error = serializers.CharField(allow_null=True, help_text="The error, where one was recorded.")
- failed_at = serializers.DateTimeField(allow_null=True, help_text="When it last failed.")
+ failed_at = serializers.DateTimeField(
+ allow_null=True, help_text="When a sync issue's table last synced successfully. Null if it never has."
+ )
url = serializers.CharField(allow_null=True, help_text="Where to go to fix it.")
diff --git a/products/data_warehouse/backend/presentation/views/data_warehouse.py b/products/data_warehouse/backend/presentation/views/data_warehouse.py
index 9fa901cdb56f..764359164455 100644
--- a/products/data_warehouse/backend/presentation/views/data_warehouse.py
+++ b/products/data_warehouse/backend/presentation/views/data_warehouse.py
@@ -176,6 +176,11 @@ FAILED_EXTERNAL_JOB_STATUSES = [
ACTIVITY_OUTCOME_COMPLETED = "completed"
ACTIVITY_OUTCOME_FAILED = "failed"
+ACTIVITY_KIND_ALL = "all"
+ACTIVITY_KIND_IMPORT = "import"
+ACTIVITY_KIND_MODEL = "model"
+ACTIVITY_KINDS = {ACTIVITY_KIND_ALL, ACTIVITY_KIND_IMPORT, ACTIVITY_KIND_MODEL}
+
ACTIVITY_OUTCOME_STATUSES: dict[str, tuple[list[str], list[str]]] = {
ACTIVITY_OUTCOME_COMPLETED: (
[ExternalDataJobStatus.COMPLETED],
@@ -581,6 +586,16 @@ class DataWarehouseViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):
{"error": "Invalid limit, offset, or cutoff_days parameter"}, status=status.HTTP_400_BAD_REQUEST
)
+ # Without this a caller that only wants imports has to over-fetch and drop the rest, and
+ # a team with enough view failures fills every page with them.
+ kind = request.GET.get("kind", ACTIVITY_KIND_ALL)
+ if kind not in ACTIVITY_KINDS:
+ supported = ", ".join(sorted(ACTIVITY_KINDS))
+ return Response(
+ {"error": f"Invalid kind parameter. Must be one of: {supported}."},
+ status=status.HTTP_400_BAD_REQUEST,
+ )
+
outcome = request.GET.get("outcome", ACTIVITY_OUTCOME_COMPLETED)
if outcome not in ACTIVITY_OUTCOME_STATUSES:
supported = ", ".join(sorted(ACTIVITY_OUTCOME_STATUSES))
@@ -625,8 +640,10 @@ class DataWarehouseViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):
AND (dwsq.id IS NULL OR dwsq.id = ANY(%s::uuid[]))
)
SELECT * FROM external_jobs
+ WHERE %s IN (%s, %s)
UNION ALL
SELECT * FROM modeling_jobs
+ WHERE %s IN (%s, %s)
ORDER BY created_at DESC
LIMIT %s OFFSET %s
""",
@@ -640,6 +657,14 @@ class DataWarehouseViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):
modeling_statuses,
cutoff_time,
saved_query_ids,
+ # Placeholders bind in SQL text order, so both kind filters come after
+ # every CTE parameter, not next to the CTE they read.
+ kind,
+ ACTIVITY_KIND_ALL,
+ ACTIVITY_KIND_IMPORT,
+ kind,
+ ACTIVITY_KIND_ALL,
+ ACTIVITY_KIND_MODEL,
limit + 1,
offset,
],
@@ -658,9 +683,9 @@ class DataWarehouseViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):
next_url = None
prev_url = None
if has_more:
- next_url = f"?limit={limit}&offset={offset + limit}&cutoff_days={cutoff_days}&outcome={outcome}"
+ next_url = f"?limit={limit}&offset={offset + limit}&cutoff_days={cutoff_days}&outcome={outcome}&kind={kind}"
if offset > 0:
- prev_url = f"?limit={limit}&offset={max(0, offset - limit)}&cutoff_days={cutoff_days}&outcome={outcome}"
+ prev_url = f"?limit={limit}&offset={max(0, offset - limit)}&cutoff_days={cutoff_days}&outcome={outcome}&kind={kind}"
return Response(
{
@@ -911,6 +936,9 @@ class DataWarehouseViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):
"source_type": schema.source.source_type if schema.source else None,
"status": sync_status,
"error": schema.latest_error,
+ # A webhook table is pushed to, never pulled on a schedule, so a surface
+ # about scheduled imports can drop it rather than call it stopped.
+ "sync_type": schema.sync_type,
"failed_at": schema.last_synced_at.isoformat() if schema.last_synced_at else None,
# The source scene keys on a prefixed id, so a bare UUID renders a
# broken page. Every ExternalDataSource uses the `managed-` prefix,
diff --git a/products/data_warehouse/backend/tests/api/test_data_warehouse.py b/products/data_warehouse/backend/tests/api/test_data_warehouse.py
index 1ec6ee0a4fe1..bab369bc98ac 100644
--- a/products/data_warehouse/backend/tests/api/test_data_warehouse.py
+++ b/products/data_warehouse/backend/tests/api/test_data_warehouse.py
@@ -250,6 +250,50 @@ class TestDataWarehouseAPI(APIBaseTest):
# The source scene keys on a prefixed id, so a bare UUID renders a broken page.
self.assertEqual(syncs[0]["url"], f"/data-warehouse/sources/managed-{source.id}")
+ def test_data_health_issues_reports_the_sync_type(self) -> None:
+ # A webhook table is pushed to, never pulled, so a caller about scheduled imports needs
+ # to tell it apart rather than calling it stopped.
+ endpoint = f"/api/projects/{self.team.id}/data_warehouse/data_health_issues"
+ source = ExternalDataSource.objects.create(
+ source_id="hook-id",
+ connection_id="conn-id",
+ destination_id="dest-id",
+ team=self.team,
+ source_type="Stripe",
+ )
+ ExternalDataSchema.objects.create(
+ name="messages",
+ team=self.team,
+ source=source,
+ should_sync=True,
+ status=ExternalDataSchema.Status.FAILED,
+ sync_type=ExternalDataSchema.SyncType.WEBHOOK,
+ )
+
+ results = self.client.get(endpoint).json()["results"]
+
+ syncs = [issue for issue in results if issue["type"] == "external_data_sync"]
+ self.assertEqual(len(syncs), 1)
+ self.assertEqual(syncs[0]["sync_type"], "webhook")
+
+ def test_completed_activity_filters_by_kind(self) -> None:
+ # Without a kind filter a team with many failing views fills every page with them, and a
+ # caller that only wants imports sees none of its own runs.
+ endpoint = f"/api/projects/{self.team.id}/data_warehouse/completed_activity"
+
+ both = self.client.get(f"{endpoint}?outcome=failed&kind=all").json()["results"]
+ imports = self.client.get(f"{endpoint}?outcome=failed&kind=import").json()["results"]
+ models = self.client.get(f"{endpoint}?outcome=failed&kind=model").json()["results"]
+
+ self.assertTrue(all(row["type"] != "Materialized view" for row in imports))
+ self.assertTrue(all(row["type"] == "Materialized view" for row in models))
+ self.assertEqual(len(both), len(imports) + len(models))
+
+ def test_completed_activity_rejects_an_unknown_kind(self) -> None:
+ endpoint = f"/api/projects/{self.team.id}/data_warehouse/completed_activity"
+ response = self.client.get(f"{endpoint}?kind=nonsense")
+ self.assertEqual(response.status_code, 400)
+
def test_data_health_issues_links_a_failed_source_with_a_prefixed_id(self) -> None:
endpoint = f"/api/projects/{self.team.id}/data_warehouse/data_health_issues"
source = ExternalDataSource.objects.create(
diff --git a/products/data_warehouse/frontend/generated/api.schemas.ts b/products/data_warehouse/frontend/generated/api.schemas.ts
index 4244ec371112..20cdec16700f 100644
--- a/products/data_warehouse/frontend/generated/api.schemas.ts
+++ b/products/data_warehouse/frontend/generated/api.schemas.ts
@@ -164,6 +164,11 @@ export interface DataHealthIssueApi {
* @nullable
*/
source_type?: string | null
+ /**
+ * How a sync issue's table is kept up to date, for example 'incremental' or 'webhook'. A webhook table is pushed to rather than pulled on a schedule. Null for other types.
+ * @nullable
+ */
+ sync_type?: string | null
/** Why it is unhealthy. One of: failed, disabled, degraded, billing_limit. */
status: string
/**
@@ -172,7 +177,7 @@ export interface DataHealthIssueApi {
*/
error: string | null
/**
- * When it last failed.
+ * When a sync issue's table last synced successfully. Null if it never has.
* @nullable
*/
failed_at: string | null
@@ -5268,6 +5273,15 @@ export type DataWarehouseCompletedActivityRetrieveParams = {
* Only include runs created within this many days of now. Defaults to 30.
*/
cutoff_days?: number
+ /**
+ * Which runs to return: 'import' for warehouse source syncs, 'model' for materialized view runs, 'all' for both. Defaults to 'all'.
+ *
+ * * `all` - all
+ * * `import` - import
+ * * `model` - model
+ * @minLength 1
+ */
+ kind?: DataWarehouseCompletedActivityRetrieveKind
/**
* Max rows to return. Capped at 50 server-side. Defaults to 20.
*/
@@ -5286,6 +5300,15 @@ export type DataWarehouseCompletedActivityRetrieveParams = {
outcome?: DataWarehouseCompletedActivityRetrieveOutcome
}
+export type DataWarehouseCompletedActivityRetrieveKind =
+ (typeof DataWarehouseCompletedActivityRetrieveKind)[keyof typeof DataWarehouseCompletedActivityRetrieveKind]
+
+export const DataWarehouseCompletedActivityRetrieveKind = {
+ All: 'all',
+ Import: 'import',
+ Model: 'model',
+} as const
+
export type DataWarehouseCompletedActivityRetrieveOutcome =
(typeof DataWarehouseCompletedActivityRetrieveOutcome)[keyof typeof DataWarehouseCompletedActivityRetrieveOutcome]
diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineHealth.tsx b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineHealth.tsx
index 62365e88eb26..c2b919fc09c4 100644
--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineHealth.tsx
+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineHealth.tsx
@@ -110,7 +110,7 @@ export function PipelineHealth(): JSX.Element {
width: 80,
render: (_, issue) =>
issue.url ? (
- <LemonButton type="secondary" size="xsmall" to={issue.url}>
+ <LemonButton type="tertiary" size="xsmall" to={issue.url}>
View
</LemonButton>
) : null,
diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.stories.tsx b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.stories.tsx
index bf5939e851a0..80729505d967 100644
--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.stories.tsx
+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.stories.tsx
@@ -16,6 +16,7 @@ const UNHEALTHY = {
name: 'charges',
type: 'external_data_sync',
source_type: 'Stripe',
+ sync_type: 'incremental',
status: 'failed',
error: 'Authentication error: expired API key',
failed_at: '2026-09-21T04:15:00Z',
@@ -132,13 +133,10 @@ const SOURCES = {
// chart needs the raw HogQL shape rather than the parsed one.
const DAYS = ['2026-09-22', '2026-09-23', '2026-09-24', '2026-09-25', '2026-09-26', '2026-09-27', '2026-09-28']
+// One request per destination now, each filtered on `instanceId`, so the mock answers a single
+// unnamed series rather than a breakdown.
const ROWS_QUERY = {
- results: [
- [DAYS, 'dest-1', [120000, 98000, 141000, 132000, 87000, 155000, 149000]],
- [DAYS, 'dest-2', [41000, 38000, 52000, 47000, 12000, 61000, 58000]],
- // A schema-keyed row. `rows_for` emits one per run and it must not become a series.
- [DAYS, '019df4a8-f218-0000-3c14-14195257f2fb', [161000, 136000, 193000, 179000, 99000, 216000, 207000]],
- ],
+ results: [[DAYS, 'rows_synced', [120000, 98000, 141000, 132000, 87000, 155000, 149000]]],
}
const DESTINATIONS = {
diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.tsx b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.tsx
index 7b9dbcb4299c..c02c4bb37003 100644
--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.tsx
+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.tsx
@@ -4,6 +4,7 @@ import { IconPlusSmall, IconRefresh } from '@posthog/icons'
import { LemonButton, LemonSelect } from '@posthog/lemon-ui'
import { NotFound } from 'lib/components/NotFound'
+import { TZLabel } from 'lib/components/TZLabel'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { SceneExport } from 'scenes/sceneTypes'
@@ -32,7 +33,7 @@ export const scene: SceneExport = {
export function PipelineOverviewScene(): JSX.Element {
const { featureFlags, receivedFeatureFlags } = useValues(featureFlagLogic)
- const { window, jobStatsLoading, hasIssues } = useValues(pipelineOverviewSceneLogic)
+ const { window, jobStatsLoading, hasIssues, lastUpdatedAt } = useValues(pipelineOverviewSceneLogic)
const { setWindow, refresh } = useActions(pipelineOverviewSceneLogic)
// Wait for the flags to land before refusing. Rendering NotFound first and the scene a beat
@@ -73,6 +74,11 @@ export function PipelineOverviewScene(): JSX.Element {
/>
<PipelineStatTiles />
+ {lastUpdatedAt ? (
+ <div className="-mt-1 text-xs text-muted">
+ Updated <TZLabel time={lastUpdatedAt} />, and every 30 seconds while this page is open
+ </div>
+ ) : null}
<SceneDivider />
diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineStatTiles.tsx b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineStatTiles.tsx
index 07f0a7c65299..31d09d7232ce 100644
--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineStatTiles.tsx
+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineStatTiles.tsx
@@ -68,7 +68,13 @@ export function PipelineStatTiles(): JSX.Element {
// otherwise wrap out of the tile.
value={humanFriendlyLargeNumber(rowsStats?.total_rows ?? 0)}
exact={humanFriendlyNumber(rowsStats?.total_rows ?? 0)}
- sub={rowsStats?.billing_available ? undefined : 'Billing is unavailable, so this may be behind'}
+ // Only once the answer is in: a null `rowsStats` is still loading, and
+ // reading it as "unavailable" put a warning under a spinner.
+ sub={
+ rowsStats && !rowsStats.billing_available
+ ? 'Billing is unavailable, so this may be behind'
+ : undefined
+ }
loading={rowsStatsLoading && rowsStats === null}
/>
<StatTile
diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.test.ts b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.test.ts
index 5a9aa2d236d4..c83577a686b5 100644
--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.test.ts
+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.test.ts
@@ -182,17 +182,67 @@ describe('pipelineOverviewSceneLogic', () => {
expect(api.dataWarehouseCompletedActivityRetrieve).toHaveBeenCalled()
})
- it('asks for destination rows between two absolute timestamps', async () => {
+ it('asks for each destination by id rather than one breakdown over every instance', async () => {
+ // The breakdown is capped at 100 rows. A team with thousands of tables pushes every
+ // destination out of that cap, which emptied the chart on a real project.
+ logic.unmount()
+ wsApi.externalDataDestinationsList.mockResolvedValue({
+ results: [
+ { id: 'dest-1', name: 'PostHog warehouse', type: 'PostHogWarehouse' },
+ { id: 'dest-2', name: 'Analytics Postgres', type: 'Postgres' },
+ ],
+ })
+ metrics.loadAppMetricsTimeSeries.mockResolvedValue({
+ labels: ['2026-09-27', '2026-09-28'],
+ interval: 'day',
+ timezone: 'UTC',
+ series: [{ name: 'rows_synced', values: [10, 20] }],
+ })
+
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+
+ const asked = metrics.loadAppMetricsTimeSeries.mock.calls.map(([request]: any[]) => request)
+ expect(asked.map((r: any) => r.instanceId).sort()).toEqual(['dest-1', 'dest-2'])
+ expect(asked.every((r: any) => r.breakdownBy === undefined)).toBe(true)
// Both bounds go straight into `toDateTime(...)`, so a relative string or a missing
// `dateTo` makes the query throw instead of returning rows.
+ asked.forEach((r: any) => {
+ expect(Date.parse(r.dateFrom)).not.toBeNaN()
+ expect(Date.parse(r.dateTo)).not.toBeNaN()
+ expect(Date.parse(r.dateFrom)).toBeLessThan(Date.parse(r.dateTo))
+ })
+ expect(logic.values.rowsByDestination.map((s: any) => s.label)).toEqual([
+ 'PostHog warehouse',
+ 'Analytics Postgres',
+ ])
+ })
+
+ it('leaves webhook tables out of the health list', async () => {
+ // A webhook table is pushed to on the vendor's schedule, never pulled on ours, so it has
+ // no last sync and cannot have stopped. A real project had 16 of them crowding the list.
+ api.dataWarehouseDataHealthIssuesRetrieve.mockResolvedValue({
+ count: 2,
+ results: [
+ issue({ id: 'a', type: 'external_data_sync', sync_type: 'webhook' }),
+ issue({ id: 'b', type: 'external_data_sync', sync_type: 'incremental' }),
+ ],
+ })
+
+ await expectLogic(logic, () => logic.actions.loadHealthIssues()).toFinishAllListeners()
+
+ expect(logic.values.issuesBySeverity.map((i: any) => i.id)).toEqual(['b'])
+ })
+
+ it('asks the runs endpoint for imports only', async () => {
+ // The endpoint answers for the whole warehouse and pages by time. A team with enough
+ // failing views filled every page with them, so this list rendered empty.
await expectLogic(logic).toFinishAllListeners()
- const [request] = metrics.loadAppMetricsTimeSeries.mock.calls[0]
- expect(request.metricName).toEqual('rows_synced')
- expect(request.breakdownBy).toEqual('instance_id')
- expect(Date.parse(request.dateFrom)).not.toBeNaN()
- expect(Date.parse(request.dateTo)).not.toBeNaN()
- expect(Date.parse(request.dateFrom)).toBeLessThan(Date.parse(request.dateTo))
+ expect(api.dataWarehouseCompletedActivityRetrieve).toHaveBeenCalledWith(
+ expect.anything(),
+ expect.objectContaining({ outcome: 'failed', kind: 'import' })
+ )
})
it('counts only the tables switched on across every page', async () => {
diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.ts b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.ts
index 2c2ca406bf7e..9065db5ce817 100644
--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.ts
+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.ts
@@ -12,7 +12,7 @@ import {
} from 'kea'
import { loaders } from 'kea-loaders'
-import { type AppMetricsTimeSeriesResponse, loadAppMetricsTimeSeries } from 'lib/components/AppMetrics/appMetricsLogic'
+import { loadAppMetricsTimeSeries } from 'lib/components/AppMetrics/appMetricsLogic'
import { dayjs } from 'lib/dayjs'
import { teamLogic } from 'scenes/teamLogic'
@@ -92,7 +92,8 @@ export interface pipelineOverviewSceneLogicValues {
sources: ExternalDataSourceSerializersApi[] | null
sourcesLoading: boolean
syncingTableCount: number
- destinationRowSeries: AppMetricsTimeSeriesResponse | null
+ lastUpdatedAt: string | null
+ destinationRowSeries: { labels: string[]; series: { id: string; values: number[] }[] } | null
destinationRowSeriesLoading: boolean
rowsByDestination: { key: string; label: string; data: number[]; type: 'area'; fill: { opacity: number } }[]
hasIssues: boolean
@@ -139,6 +140,14 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([
7 as PipelineStatsWindow,
{ setWindow: (_: unknown, { window }: { window: PipelineStatsWindow }) => window },
],
+ // Stamped when the polled numbers land, so the page can show that they are live rather
+ // than leaving a reader to guess whether a static count is stale.
+ lastUpdatedAt: [
+ null as string | null,
+ {
+ loadJobStatsSuccess: () => new Date().toISOString(),
+ },
+ ],
}),
loaders(({ values }: any) => ({
// `null` rather than an empty shape throughout: the scene has to tell "not answered yet"
@@ -191,24 +200,47 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([
},
],
destinationRowSeries: [
- null as AppMetricsTimeSeriesResponse | null,
+ null as { labels: string[]; series: { id: string; values: number[] }[] } | null,
{
- loadDestinationRowSeries: async () =>
- await loadAppMetricsTimeSeries(
- {
- appSource: WAREHOUSE_APP_SOURCE,
- metricName: 'rows_synced',
- breakdownBy: 'instance_id',
- // An hourly grain over a day keeps the 24-hour window from collapsing
- // to a single point.
- interval: values.window === 1 ? 'hour' : 'day',
- // Both bounds are interpolated into `toDateTime(...)`, so they have to
- // be absolute timestamps.
- dateFrom: dayjs().subtract(values.window, 'day').toISOString(),
- dateTo: dayjs().toISOString(),
- },
- values.currentTeam?.timezone ?? 'UTC'
- ),
+ loadDestinationRowSeries: async () => {
+ const destinations = values.destinations ?? []
+ if (destinations.length === 0) {
+ return { labels: [], series: [] }
+ }
+ const interval = values.window === 1 ? ('hour' as const) : ('day' as const)
+ // Both bounds are interpolated into `toDateTime(...)`, so they have to be
+ // absolute. The upper bound sits an hour ahead because the comparison is
+ // exclusive and rows land continuously.
+ const dateFrom = dayjs().subtract(values.window, 'day').toISOString()
+ const dateTo = dayjs().add(1, 'hour').toISOString()
+ // One request per destination, filtered on `instanceId`, rather than one
+ // breakdown over every instance. The breakdown is capped at 100 rows, and a
+ // team with thousands of tables pushes every destination out of that cap.
+ const answers = await Promise.all(
+ destinations.map(async (destination: ExternalDataDestinationApi) => ({
+ id: destination.id,
+ response: await loadAppMetricsTimeSeries(
+ {
+ appSource: WAREHOUSE_APP_SOURCE,
+ metricName: 'rows_synced',
+ instanceId: destination.id,
+ interval,
+ dateFrom,
+ dateTo,
+ },
+ values.currentTeam?.timezone ?? 'UTC'
+ ),
+ }))
+ )
+ return {
+ labels: answers.find((a) => a.response.labels.length > 0)?.response.labels ?? [],
+ series: answers.map((a) => ({
+ id: a.id,
+ // Without a breakdown the response carries a single unnamed series.
+ values: a.response.series[0]?.values ?? [],
+ })),
+ }
+ },
},
],
recentFailures: [
@@ -217,6 +249,9 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([
loadRecentFailures: async () =>
await dataWarehouseCompletedActivityRetrieve(String(values.currentTeamId), {
outcome: 'failed',
+ // Imports only. Without this a team with many failing views fills every
+ // page with them and this list renders empty.
+ kind: 'import',
// The window control sits in this section's own header. Without this the
// endpoint falls back to its own 30-day default and ignores the control.
cutoff_days: values.window,
@@ -237,6 +272,9 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([
(healthIssues: DataHealthIssuesResponseApi | null): DataHealthIssueApi[] =>
(healthIssues?.results ?? [])
.filter((issue) => SYNC_ISSUE_TYPES.includes(issue.type))
+ // A webhook table is pushed to on the vendor's schedule, never pulled on
+ // ours, so it has no last sync and cannot have "stopped".
+ .filter((issue) => issue.sync_type !== 'webhook')
.sort((a, b) => (ISSUE_SEVERITY[a.status] ?? 99) - (ISSUE_SEVERITY[b.status] ?? 99)),
],
failingSyncCount: [
@@ -244,16 +282,11 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([
(healthIssues: DataHealthIssuesResponseApi | null): number =>
(healthIssues?.results ?? []).filter((issue) => issue.type === 'external_data_sync').length,
],
- /**
- * One chart series per destination, biggest first so the legend order matches the stack.
- * `rows_for` emits `rows_synced` under three instance ids per run — the schema, the
- * destination, and `<schema>/<destination>` — so only ids matching a real destination are
- * kept, which drops the schema-level and combined rows rather than double counting them.
- */
+ /** One chart series per destination, biggest first so the legend matches the stack. */
rowsByDestination: [
(s: any) => [s.destinationRowSeries, s.destinations],
(
- series: AppMetricsTimeSeriesResponse | null,
+ answer: { labels: string[]; series: { id: string; values: number[] }[] } | null,
destinations: ExternalDataDestinationApi[] | null
): {
key: string
@@ -262,15 +295,14 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([
type: 'area'
fill: { opacity: number }
}[] => {
- if (!series || !destinations) {
+ if (!answer || !destinations) {
return []
}
const byId = new Map(destinations.map((d) => [d.id, d]))
- return series.series
- .filter((s) => byId.has(s.name))
+ return answer.series
.map((s) => ({
- key: s.name,
- label: byId.get(s.name)?.name ?? s.name,
+ key: s.id,
+ label: byId.get(s.id)?.name ?? s.id,
data: s.values,
type: 'area' as const,
// `fill` is what makes an area series fill; `type` alone draws a line.
@@ -279,6 +311,7 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([
fill: { opacity: 0.25 },
total: s.values.reduce((a, b) => a + b, 0),
}))
+ .filter((s) => s.total > 0)
.sort((a, b) => b.total - a.total)
.map(({ total: _total, ...rest }) => rest)
},
@@ -325,6 +358,9 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([
actions.loadRecentFailures()
},
refresh: () => actions.loadEverything(),
+ // The series are fetched one destination at a time, so the destination list has to land
+ // first. Chaining on success is what guarantees that on a reload as well as on mount.
+ loadDestinationsSuccess: () => actions.loadDestinationRowSeries(),
loadEverything: () => {
actions.loadJobStats()
actions.loadRowsStats()
@@ -332,7 +368,6 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([
actions.loadRecentFailures()
actions.loadDestinations()
actions.loadSources()
- actions.loadDestinationRowSeries()
},
// Only the headline numbers poll. Reloading the tables under someone mid-read moves rows
// they are looking at, and they change far less often than the counts do.
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 5e53c913907f..d1882a22a510 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -25905,6 +25905,11 @@ export namespace Schemas {
* @nullable
*/
source_type?: string | null;
+ /**
+ * How a sync issue's table is kept up to date, for example 'incremental' or 'webhook'. A webhook table is pushed to rather than pulled on a schedule. Null for other types.
+ * @nullable
+ */
+ sync_type?: string | null;
/** Why it is unhealthy. One of: failed, disabled, degraded, billing_limit. */
status: string;
/**
@@ -25913,7 +25918,7 @@ export namespace Schemas {
*/
error: string | null;
/**
- * When it last failed.
+ * When a sync issue's table last synced successfully. Null if it never has.
* @nullable
*/
failed_at: string | null;
@@ -111512,6 +111517,15 @@ export namespace Schemas {
* Only include runs created within this many days of now. Defaults to 30.
*/
cutoff_days?: number;
+ /**
+ * Which runs to return: 'import' for warehouse source syncs, 'model' for materialized view runs, 'all' for both. Defaults to 'all'.
+ *
+ * * `all` - all
+ * * `import` - import
+ * * `model` - model
+ * @minLength 1
+ */
+ kind?: DataWarehouseCompletedActivityRetrieveKind;
/**
* Max rows to return. Capped at 50 server-side. Defaults to 20.
*/
@@ -111530,6 +111544,15 @@ export namespace Schemas {
outcome?: DataWarehouseCompletedActivityRetrieveOutcome;
};
+ export type DataWarehouseCompletedActivityRetrieveKind = typeof DataWarehouseCompletedActivityRetrieveKind[keyof typeof DataWarehouseCompletedActivityRetrieveKind];
+
+
+ export const DataWarehouseCompletedActivityRetrieveKind = {
+ All: 'all',
+ Import: 'import',
+ Model: 'model',
+ } as const;
+
export type DataWarehouseCompletedActivityRetrieveOutcome = typeof DataWarehouseCompletedActivityRetrieveOutcome[keyof typeof DataWarehouseCompletedActivityRetrieveOutcome];