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.

feat(data-warehouse): show destination rows and synced sources on the ETL scene (#107718)

Tom Owers70080f683057
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index cf09a3ed596c..c2e16f4815ea 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -8737,13 +8737,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.6f9a746240c4bb66bf867ffdb0c0b4f2760968b7f6e6fefa3f09c87d3390b28a.cGt8qIGqmnOp8OGL0qZLsByWNj8WoodX4Swd4KYokpk
+ hash: v1.k794b7964.f97114fdf950bf28e82743f7dbd64d712d59c32ddb7e39c9d92518a40150b335.QxGeTzoXytUfBX6y_nmgVPqvaQqtKcOvDx4SuToXdtw
scenes-app-etl--healthy--light:
- hash: v1.k794b7964.de906e2ee3c8242d49e0334bfcc090b0ca35e0d15fc20e1a97aa604a4218bae6.rNzE7RZnEnjOx2bH3oDTB4x0bD45FO6pDErTQ_4u2Gk
+ hash: v1.k794b7964.e87e236939c2f5ce17ddd1db0b35993cbd5880500cf91b9d7f07e6e8ff6c5d16.cKL4CPwGG5PxuIadBIIRylCLQUFX3hIxA05T3T1DrX0
scenes-app-etl--needs-attention--dark:
- hash: v1.k794b7964.6e2de088e9b72f27c86f7302dddff92548e44bdee770221ec8bb4f481ffbf5eb.vUqG_HSyPzcbYsHBx7m2SatCcQcx0LkZdne5fThy5uc
+ hash: v1.k794b7964.921bac212428a17d90c76afa7fcd2cc184b49750fa1c31bed4d1b5e608fb6436.K0vj_KRaZKq1bLp6riYM6YnHdVi0I7jedojW6YfLvDk
scenes-app-etl--needs-attention--light:
- hash: v1.k794b7964.da980590bc87659d284578dcfe3778f9e9f68bbe218bedaef312f01a8847c625.sHm7R3KRP0yGxleUAjbXsqo6RxUjT5In5Gl9SVUIz_c
+ hash: v1.k794b7964.c0551483dd11af0fef0680c4aa13343cc2962ea9a350f203435ac577da182699.7bPbMAMAsvaJNhudkkKPijhKiAQJDGk8lCkVtwUsGUI
scenes-app-events--event-explorer--dark:
hash: v1.k794b7964.3bf3b01d0972be5ad8fe4a7408d20b10e2431ea8f28874aa0a63f7623c1af97c.ONFJgVNjjG1f32eqlxRZuleSgdLpLGIcFhHN2S4yvhk
scenes-app-events--event-explorer--light:
diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineHealth.tsx b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineHealth.tsx
index 1eaa18139e1d..9b5ce2f81639 100644
--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineHealth.tsx
+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineHealth.tsx
@@ -25,7 +25,6 @@ const STATUS_TAG_TYPES: Record<string, LemonTagType> = {
const TYPE_LABELS: Record<string, string> = {
external_data_sync: 'Sync',
- materialized_view: 'Materialized view',
source: 'Source',
destination: 'Destination',
transformation: 'Transformation',
diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.stories.tsx b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.stories.tsx
index c9d867294e1c..273e656b45da 100644
--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.stories.tsx
+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.stories.tsx
@@ -32,6 +32,8 @@ const UNHEALTHY = {
url: '/data-management/sources/2',
},
{
+ // Kept deliberately: the endpoint answers for the whole warehouse, and this row must
+ // not appear in the rendered scene.
id: '3',
name: 'account_activity',
type: 'materialized_view',
@@ -97,6 +99,35 @@ const FAILED_RUNS = {
],
}
+// The synced-sources table is the real one from the sources page, so the stories have to answer
+// the endpoints it loads for itself.
+const SOURCES = {
+ count: 2,
+ results: [
+ {
+ id: '1',
+ source_type: 'Stripe',
+ prefix: null,
+ status: 'Running',
+ access_method: 'warehouse',
+ last_run_at: '2026-09-25T08:00:00Z',
+ schemas: [
+ { id: 's1', name: 'charges', should_sync: true, status: 'Running' },
+ { id: 's2', name: 'customers', should_sync: true, status: 'Completed' },
+ ],
+ },
+ {
+ id: '2',
+ source_type: 'Postgres',
+ prefix: 'billing_',
+ status: 'Error',
+ access_method: 'warehouse',
+ last_run_at: '2026-09-24T02:00:00Z',
+ schemas: [{ id: 's3', name: 'public.invoices', should_sync: true, status: 'Failed' }],
+ },
+ ],
+}
+
function mocks(health: Record<string, unknown>, runs: Record<string, unknown>): ReturnType<typeof mswDecorator> {
return mswDecorator({
get: {
@@ -104,6 +135,9 @@ function mocks(health: Record<string, unknown>, runs: Record<string, unknown>):
'/api/projects/:team_id/data_warehouse/total_rows_stats': ROWS_STATS,
'/api/projects/:team_id/data_warehouse/data_health_issues': health,
'/api/projects/:team_id/data_warehouse/completed_activity': runs,
+ '/api/projects/:team_id/external_data_sources': SOURCES,
+ '/api/projects/:team_id/external_data_sources/wizard': {},
+ '/api/projects/:team_id/external_data_destinations': { count: 0, results: [] },
},
})
}
diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.tsx b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.tsx
index 1f04e81bfa1b..517d5612035e 100644
--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.tsx
+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.tsx
@@ -1,7 +1,7 @@
import { useActions, useValues } from 'kea'
import { IconPlusSmall, IconRefresh } from '@posthog/icons'
-import { LemonButton, LemonSelect, Link } from '@posthog/lemon-ui'
+import { LemonButton, LemonSelect } from '@posthog/lemon-ui'
import { NotFound } from 'lib/components/NotFound'
import { FEATURE_FLAGS } from 'lib/constants'
@@ -15,11 +15,14 @@ import { SceneSection } from '~/layout/scenes/components/SceneSection'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
import { ProductKey } from '~/queries/schema/schema-general'
+import { ManagedSourcesTable } from 'products/data_warehouse/frontend/shared/components/ManagedSourcesTable'
+
import { PipelineHealth } from './PipelineHealth'
import type { PipelineStatsWindow } from './pipelineOverviewSceneLogic'
import { pipelineOverviewSceneLogic } from './pipelineOverviewSceneLogic'
import { PipelineStatTiles } from './PipelineStatTiles'
import { RecentFailures } from './RecentFailures'
+import { RowsByDestination } from './RowsByDestination'
export const scene: SceneExport = {
component: PipelineOverviewScene,
@@ -29,7 +32,7 @@ export const scene: SceneExport = {
export function PipelineOverviewScene(): JSX.Element {
const { featureFlags, receivedFeatureFlags } = useValues(featureFlagLogic)
- const { window, jobStatsLoading } = useValues(pipelineOverviewSceneLogic)
+ const { window, jobStatsLoading, hasIssues } = useValues(pipelineOverviewSceneLogic)
const { setWindow, refresh } = useActions(pipelineOverviewSceneLogic)
// Wait for the flags to land before refusing. Rendering NotFound first and the scene a beat
@@ -73,14 +76,20 @@ export function PipelineOverviewScene(): JSX.Element {
<SceneDivider />
- <SceneSection
- title="Needs attention"
- description="Worst first. A pipeline stopped by a billing limit counts as needing attention."
- >
- <PipelineHealth />
- </SceneSection>
+ {/* Hidden entirely when everything is healthy: an empty problem list is not worth the
+ vertical space, and its absence already says there is nothing wrong. */}
+ {hasIssues ? (
+ <>
+ <SceneSection
+ title="Needs attention"
+ description="Sources and tables that have stopped, most serious first."
+ >
+ <PipelineHealth />
+ </SceneSection>
- <SceneDivider />
+ <SceneDivider />
+ </>
+ ) : null}
<SceneSection
title="Runs"
@@ -104,6 +113,18 @@ export function PipelineOverviewScene(): JSX.Element {
<SceneDivider />
+ <SceneSection title="Rows synced by destination" description="Where the imported rows were written.">
+ <RowsByDestination />
+ </SceneSection>
+
+ <SceneDivider />
+
+ <SceneSection title="Synced sources" description="Sources PostHog imports on a schedule.">
+ <ManagedSourcesTable />
+ </SceneSection>
+
+ <SceneDivider />
+
<SceneSection
title="Sources and destinations"
description="Connect a source, and choose where its tables are written."
@@ -121,10 +142,6 @@ export function PipelineOverviewScene(): JSX.Element {
Manage destinations
</LemonButton>
</div>
- <p className="mt-2 mb-0 text-xs text-muted">
- Pipeline failures are also listed on <Link to={urls.pipelineStatus()}>Pipeline status</Link>, which
- covers materialized views and batch exports too.
- </p>
</SceneSection>
</SceneContent>
)
diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineStatTiles.tsx b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineStatTiles.tsx
index bebbaead9c80..5f387fc60772 100644
--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineStatTiles.tsx
+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineStatTiles.tsx
@@ -46,10 +46,15 @@ export function PipelineStatTiles(): JSX.Element {
healthIssues,
healthIssuesLoading,
failingSyncCount,
+ issuesBySeverity,
} = useValues(pipelineOverviewSceneLogic)
- const issueCount = healthIssues?.count ?? 0
- const running = (jobStats?.external_data_jobs?.running ?? 0) + (jobStats?.modeling_jobs?.running ?? 0)
+ // `job_stats` reports syncs and materialized view runs separately, and every count here
+ // reads the sync half. The totals it also returns fold the two together.
+ const syncJobs = jobStats?.external_data_jobs
+ // The list this scene shows, not `healthIssues.count`, which counts the whole warehouse
+ // including the materialized views this scene leaves out.
+ const issueCount = issuesBySeverity.length
return (
<div className="@container">
@@ -64,22 +69,30 @@ export function PipelineStatTiles(): JSX.Element {
loading={rowsStatsLoading && rowsStats === null}
/>
<StatTile
- label="Runs"
- value={humanFriendlyNumber(jobStats?.total_jobs ?? 0)}
- sub={`${humanFriendlyNumber(jobStats?.successful_jobs ?? 0)} succeeded`}
+ label="Sync runs"
+ value={humanFriendlyNumber(syncJobs?.total ?? 0)}
+ sub={`${humanFriendlyNumber(syncJobs?.successful ?? 0)} succeeded`}
loading={jobStatsLoading && jobStats === null}
/>
<StatTile
label="Needs attention"
value={humanFriendlyNumber(issueCount)}
- sub={issueCount > 0 ? `${failingSyncCount} of them syncs` : 'Everything is healthy'}
+ // The list can also hold a source or a destination, so name the sync share
+ // only when it is not the whole of it.
+ sub={
+ issueCount === 0
+ ? 'Every sync is healthy'
+ : failingSyncCount < issueCount
+ ? `${failingSyncCount} of them syncs`
+ : undefined
+ }
loading={healthIssuesLoading && healthIssues === null}
danger={issueCount > 0}
/>
<StatTile
label="Running now"
- value={humanFriendlyNumber(running)}
- sub="Syncs and materializations"
+ value={humanFriendlyNumber(syncJobs?.running ?? 0)}
+ sub="Syncs in flight"
loading={jobStatsLoading && jobStats === null}
/>
</div>
diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/RowsByDestination.tsx b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/RowsByDestination.tsx
new file mode 100644
index 000000000000..bac9fe57731f
--- /dev/null
+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/RowsByDestination.tsx
@@ -0,0 +1,55 @@
+import { useValues } from 'kea'
+
+import { LemonSkeleton, LemonTag } from '@posthog/lemon-ui'
+
+import { humanFriendlyLargeNumber, humanFriendlyNumber } from 'lib/utils/numbers'
+
+import { pipelineOverviewSceneLogic } from './pipelineOverviewSceneLogic'
+
+export function RowsByDestination(): JSX.Element {
+ const { rowsByDestination, destinationRowTotals, destinationRowTotalsLoading, destinationsLoading } =
+ useValues(pipelineOverviewSceneLogic)
+
+ if ((destinationRowTotalsLoading && destinationRowTotals === null) || destinationsLoading) {
+ return <LemonSkeleton className="h-24 w-full" />
+ }
+
+ if (rowsByDestination.length === 0) {
+ return (
+ <div className="rounded border border-primary bg-surface-primary px-4 py-6 text-center text-muted">
+ No rows were written to a destination in this window.
+ </div>
+ )
+ }
+
+ // Bars are relative to the busiest destination rather than the total, so a single dominant
+ // destination does not flatten every other bar to nothing.
+ const busiest = Math.max(...rowsByDestination.map((row) => row.rows))
+
+ return (
+ <div className="flex flex-col gap-2 rounded border border-primary bg-surface-primary p-4">
+ {rowsByDestination.map((row) => (
+ <div key={row.id} className="flex flex-col gap-1">
+ <div className="flex flex-wrap items-baseline justify-between gap-2">
+ <span className="flex items-center gap-2 min-w-0">
+ <span className="truncate font-medium">{row.name}</span>
+ <LemonTag type="muted" size="small">
+ {row.type}
+ </LemonTag>
+ </span>
+ <span className="tabular-nums font-medium" title={humanFriendlyNumber(row.rows)}>
+ {humanFriendlyLargeNumber(row.rows)}
+ </span>
+ </div>
+ <div className="h-1.5 w-full overflow-hidden rounded bg-border">
+ <div
+ className="h-full rounded bg-brand-blue"
+ // Width is the one value that has to be computed from the data.
+ style={{ width: `${Math.max(2, (row.rows / busiest) * 100)}%` }}
+ />
+ </div>
+ </div>
+ ))}
+ </div>
+ )
+}
diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.test.ts b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.test.ts
index 8db3f523e79e..e35268d3450c 100644
--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.test.ts
+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.test.ts
@@ -11,7 +11,17 @@ jest.mock('products/data_warehouse/frontend/generated/api', () => ({
dataWarehouseCompletedActivityRetrieve: jest.fn(),
}))
+jest.mock('products/warehouse_sources/frontend/generated/api', () => ({
+ externalDataDestinationsList: jest.fn(),
+}))
+
+jest.mock('lib/components/AppMetrics/appMetricsLogic', () => ({
+ loadAppMetricsTotals: jest.fn(),
+}))
+
const api = jest.requireMock('products/data_warehouse/frontend/generated/api')
+const wsApi = jest.requireMock('products/warehouse_sources/frontend/generated/api')
+const metrics = jest.requireMock('lib/components/AppMetrics/appMetricsLogic')
const issue = (overrides: Record<string, any> = {}): Record<string, any> => ({
id: 'issue-1',
@@ -33,6 +43,8 @@ describe('pipelineOverviewSceneLogic', () => {
api.dataWarehouseTotalRowsStatsRetrieve.mockResolvedValue({ total_rows: 0 })
api.dataWarehouseDataHealthIssuesRetrieve.mockResolvedValue({ results: [], count: 0 })
api.dataWarehouseCompletedActivityRetrieve.mockResolvedValue({ results: [], next: null, previous: null })
+ wsApi.externalDataDestinationsList.mockResolvedValue({ results: [] })
+ metrics.loadAppMetricsTotals.mockResolvedValue({})
logic = pipelineOverviewSceneLogic()
logic.mount()
})
@@ -92,6 +104,38 @@ describe('pipelineOverviewSceneLogic', () => {
expect(logic.values.failingSyncCount).toEqual(1)
})
+ it('leaves materialized views out of the health list', async () => {
+ // The endpoint answers for the whole warehouse. This scene is about imports, so a broken
+ // view belongs on Pipeline status, not here, where nothing can be done about it.
+ api.dataWarehouseDataHealthIssuesRetrieve.mockResolvedValue({
+ count: 3,
+ results: [
+ issue({ id: 'a', type: 'materialized_view' }),
+ issue({ id: 'b', type: 'external_data_sync' }),
+ issue({ id: 'c', type: 'destination' }),
+ ],
+ })
+
+ await expectLogic(logic, () => logic.actions.loadHealthIssues()).toFinishAllListeners()
+
+ expect(logic.values.issuesBySeverity.map((i: any) => i.id)).toEqual(['b', 'c'])
+ })
+
+ it('leaves materialized view runs out of the failures list', async () => {
+ api.dataWarehouseCompletedActivityRetrieve.mockResolvedValue({
+ next: null,
+ previous: null,
+ results: [
+ { id: 'r1', type: 'Materialized view', name: 'account_activity', status: 'Failed' },
+ { id: 'r2', type: 'Stripe', name: 'charges', status: 'Failed' },
+ ],
+ })
+
+ await expectLogic(logic, () => logic.actions.loadRecentFailures()).toFinishAllListeners()
+
+ expect(logic.values.failedRuns.map((r: any) => r.id)).toEqual(['r2'])
+ })
+
it('asks for failed runs, not completed ones', async () => {
// Without the outcome parameter this endpoint returns successes, so the failures section
// would quietly list runs that worked.
@@ -132,4 +176,17 @@ describe('pipelineOverviewSceneLogic', () => {
expect(api.dataWarehouseDataHealthIssuesRetrieve).toHaveBeenCalled()
expect(api.dataWarehouseCompletedActivityRetrieve).toHaveBeenCalled()
})
+
+ it('asks for destination rows between two absolute timestamps', async () => {
+ // Both bounds go straight into `toDateTime(...)`, so a relative string or a missing
+ // `dateTo` makes the query throw instead of returning rows.
+ await expectLogic(logic).toFinishAllListeners()
+
+ const [request] = metrics.loadAppMetricsTotals.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))
+ })
})
diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.ts b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.ts
index 3fdeceacceee..5fd1a06838d7 100644
--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.ts
+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.ts
@@ -1,6 +1,19 @@
-import { MakeLogicType, actions, afterMount, connect, kea, listeners, path, reducers, selectors } from 'kea'
+import {
+ MakeLogicType,
+ actions,
+ afterMount,
+ beforeUnmount,
+ connect,
+ kea,
+ listeners,
+ path,
+ reducers,
+ selectors,
+} from 'kea'
import { loaders } from 'kea-loaders'
+import { loadAppMetricsTotals } from 'lib/components/AppMetrics/appMetricsLogic'
+import { dayjs } from 'lib/dayjs'
import { teamLogic } from 'scenes/teamLogic'
import { Breadcrumb } from '~/types'
@@ -19,10 +32,30 @@ import type {
PipelineJobStatsResponseApi,
PipelineRowsStatsResponseApi,
} from 'products/data_warehouse/frontend/generated/api.schemas'
+import { externalDataDestinationsList } from 'products/warehouse_sources/frontend/generated/api'
+import type { ExternalDataDestinationApi } from 'products/warehouse_sources/frontend/generated/api.schemas'
/** Windows `job_stats` accepts. Anything else is a 400. */
export type PipelineStatsWindow = 1 | 7 | 30
+/**
+ * `data_health_issues` and `completed_activity` both answer for the whole warehouse, which
+ * includes materialized views and batch exports. This scene is about imports and the
+ * destinations they write to, so those are filtered out here rather than shown as pipelines
+ * the reader cannot act on from this page.
+ */
+const SYNC_ISSUE_TYPES = ['external_data_sync', 'source', 'destination']
+
+/** `app_source` the import pipeline emits its metrics under. */
+const WAREHOUSE_APP_SOURCE = 'warehouse_source_sync'
+
+/**
+ * The headline numbers describe work in flight, so they go stale while the page sits open.
+ * Long enough not to hammer ClickHouse and Postgres from an idle tab.
+ */
+const STATS_POLL_INTERVAL_MS = 30_000
+const MATERIALIZED_VIEW_ACTIVITY_TYPE = 'Materialized view'
+
/** Most severe first, so the worst pipeline is the one a reader sees. */
const ISSUE_SEVERITY: Record<string, number> = {
failed: 0,
@@ -33,6 +66,7 @@ const ISSUE_SEVERITY: Record<string, number> = {
export interface pipelineOverviewSceneLogicValues {
currentTeamId: number | null // teamLogic
+ currentTeam: Record<string, any> | null // teamLogic
window: PipelineStatsWindow
jobStats: PipelineJobStatsResponseApi | null
jobStatsLoading: boolean
@@ -46,6 +80,12 @@ export interface pipelineOverviewSceneLogicValues {
issuesBySeverity: DataHealthIssueApi[]
failingSyncCount: number
failedRuns: PipelineActivityRowApi[]
+ destinations: ExternalDataDestinationApi[] | null
+ destinationsLoading: boolean
+ destinationRowTotals: Record<string, { total: number }> | null
+ destinationRowTotalsLoading: boolean
+ rowsByDestination: { id: string; name: string; type: string; rows: number }[]
+ hasIssues: boolean
loadingFirstTime: boolean
}
@@ -55,7 +95,11 @@ export interface pipelineOverviewSceneLogicActions {
loadRowsStats: () => any
loadHealthIssues: () => any
loadRecentFailures: () => any
+ loadDestinations: () => any
+ loadDestinationRowTotals: () => any
refresh: () => { value: true }
+ loadEverything: () => { value: true }
+ pollStats: () => { value: true }
}
export type pipelineOverviewSceneLogicType = MakeLogicType<
@@ -72,10 +116,12 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([
'PipelineOverviewScene',
'pipelineOverviewSceneLogic',
]),
- connect(() => ({ values: [teamLogic, ['currentTeamId']] })),
+ connect(() => ({ values: [teamLogic, ['currentTeamId', 'currentTeam']] })),
actions({
setWindow: (window: PipelineStatsWindow) => ({ window }),
refresh: true,
+ loadEverything: true,
+ pollStats: true,
}),
reducers({
window: [
@@ -101,13 +147,50 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([
null as DataHealthIssuesResponseApi | null,
{ loadHealthIssues: async () => await dataWarehouseDataHealthIssuesRetrieve(String(values.currentTeamId)) },
],
+ destinations: [
+ null as ExternalDataDestinationApi[] | null,
+ {
+ loadDestinations: async () =>
+ (await externalDataDestinationsList(String(values.currentTeamId))).results ?? [],
+ },
+ ],
+ /**
+ * Rows written per destination, across every source. The pipeline emits `rows_synced`
+ * three ways per run — keyed by schema, by schema and destination, and by destination
+ * alone — so a raw `instance_id` breakdown mixes all three. The destination-keyed rows
+ * are picked out in `rowsByDestination` by matching against the team's real destinations.
+ */
+ destinationRowTotals: [
+ null as Record<string, { total: number }> | null,
+ {
+ loadDestinationRowTotals: async () =>
+ await loadAppMetricsTotals(
+ {
+ appSource: WAREHOUSE_APP_SOURCE,
+ metricName: 'rows_synced',
+ breakdownBy: ['instance_id'],
+ // Both bounds are interpolated into `toDateTime(...)`, so they have to
+ // be absolute timestamps. The upper bound sits an hour ahead because
+ // the comparison is exclusive and rows land continuously.
+ dateFrom: dayjs().subtract(values.window, 'day').toISOString(),
+ dateTo: dayjs().add(1, 'hour').toISOString(),
+ // Bounded so a team with many schemas cannot silently truncate the
+ // destination rows out of the result.
+ limit: 500,
+ },
+ values.currentTeam?.timezone ?? 'UTC'
+ ),
+ },
+ ],
recentFailures: [
null as PipelineActivityResponseApi | null,
{
loadRecentFailures: async () =>
await dataWarehouseCompletedActivityRetrieve(String(values.currentTeamId), {
outcome: 'failed',
- limit: 10,
+ // Over-fetch: the endpoint has no sync-only filter, so view runs are
+ // dropped client-side and a page of them would otherwise show nothing.
+ limit: 50,
}),
},
],
@@ -120,19 +203,42 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([
issuesBySeverity: [
(s: any) => [s.healthIssues],
(healthIssues: DataHealthIssuesResponseApi | null): DataHealthIssueApi[] =>
- [...(healthIssues?.results ?? [])].sort(
- (a, b) => (ISSUE_SEVERITY[a.status] ?? 99) - (ISSUE_SEVERITY[b.status] ?? 99)
- ),
+ (healthIssues?.results ?? [])
+ .filter((issue) => SYNC_ISSUE_TYPES.includes(issue.type))
+ .sort((a, b) => (ISSUE_SEVERITY[a.status] ?? 99) - (ISSUE_SEVERITY[b.status] ?? 99)),
],
failingSyncCount: [
(s: any) => [s.healthIssues],
(healthIssues: DataHealthIssuesResponseApi | null): number =>
(healthIssues?.results ?? []).filter((issue) => issue.type === 'external_data_sync').length,
],
+ /** Rows written per destination over the window, biggest first. */
+ rowsByDestination: [
+ (s: any) => [s.destinationRowTotals, s.destinations],
+ (
+ totals: Record<string, { total: number }> | null,
+ destinations: ExternalDataDestinationApi[] | null
+ ): { id: string; name: string; type: string; rows: number }[] => {
+ if (!totals || !destinations) {
+ return []
+ }
+ return destinations
+ .map((destination) => ({
+ id: destination.id,
+ name: destination.name,
+ type: destination.type,
+ rows: totals[destination.id]?.total ?? 0,
+ }))
+ .filter((row) => row.rows > 0)
+ .sort((a, b) => b.rows - a.rows)
+ },
+ ],
+ /** Whether anything is wrong. The health section is hidden when nothing is. */
+ hasIssues: [(s: any) => [s.issuesBySeverity], (issues: DataHealthIssueApi[]): boolean => issues.length > 0],
failedRuns: [
(s: any) => [s.recentFailures],
(recentFailures: PipelineActivityResponseApi | null): PipelineActivityRowApi[] =>
- recentFailures?.results ?? [],
+ (recentFailures?.results ?? []).filter((run) => run.type !== MATERIALIZED_VIEW_ACTIVITY_TYPE),
],
// A first load shows skeletons; a refresh keeps the numbers on screen and dims them, so
// polling does not make the page flash.
@@ -149,18 +255,35 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([
listeners(({ actions }: any) => ({
// Only the run counts are windowed. Rows are reported per billing period and health is
// current state, so neither changes with the window.
- setWindow: () => actions.loadJobStats(),
- refresh: () => {
+ setWindow: () => {
+ actions.loadJobStats()
+ actions.loadDestinationRowTotals()
+ },
+ refresh: () => actions.loadEverything(),
+ loadEverything: () => {
actions.loadJobStats()
actions.loadRowsStats()
actions.loadHealthIssues()
actions.loadRecentFailures()
+ actions.loadDestinations()
+ actions.loadDestinationRowTotals()
+ },
+ // 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.
+ pollStats: () => {
+ actions.loadJobStats()
+ actions.loadHealthIssues()
},
})),
- afterMount(({ actions }: any) => {
- actions.loadJobStats()
- actions.loadRowsStats()
- actions.loadHealthIssues()
- actions.loadRecentFailures()
+ afterMount(({ actions, cache }: any) => {
+ actions.loadEverything()
+ cache.pollInterval = window.setInterval(() => actions.pollStats(), STATS_POLL_INTERVAL_MS)
+ }),
+ beforeUnmount(({ cache }: any) => {
+ // Without this the timer outlives the scene and keeps querying after navigation.
+ if (cache.pollInterval) {
+ window.clearInterval(cache.pollInterval)
+ cache.pollInterval = undefined
+ }
}),
])