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): add three FireHydrant tables from the coverage audit (#107692)

Tom Owers4bc58a4cbbe1
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
index 85feb4e92383..a1da9d6b7b4c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
@@ -3165,8 +3165,8 @@ Today (24): `alerts`, `change_events`, `changes`, `checklist_templates`, `custom
Diffed against: <https://raw.githubusercontent.com/firehydrant/firehydrant-typescript-sdk/main/openapi.yaml>
- [x] `/v1/incidents/{incident_id}/milestones` — the incident state-transition history that every MTTx and lifecycle calculation is built from (high)
-- [ ] `/v1/incidents/{incident_id}/events` — the full incident timeline; incidents alone give no in-incident activity (high)
-- [ ] `/v1/incidents/{incident_id}/role_assignments` — membership table joining incidents to users and the already-synced incident_roles (high)
+- [x] `/v1/incidents/{incident_id}/events` — the full incident timeline; incidents alone give no in-incident activity (high)
+- [x] `/v1/incidents/{incident_id}/role_assignments` — membership table joining incidents to users and the already-synced incident_roles (high)
- [ ] `/v1/metrics/mttx` — FireHydrant's headline reliability metric (MTTA/MTTR/MTTM) with no equivalent in the current tables (high)
- [x] `/v1/schedules` — org-wide on-call schedules; signals_on_call is synced but the schedule definitions it references are not (high)
- [x] `/v1/teams/{team_id}/escalation_policies` — lookup resolving how alerts route per team, joining teams already synced (high)
@@ -3174,7 +3174,7 @@ Diffed against: <https://raw.githubusercontent.com/firehydrant/firehydrant-types
- [ ] `/v1/change_types` — lookup table resolving the change type carried on the synced changes and change_events rows (medium)
- [ ] `/v1/lifecycles/phases and /v1/lifecycles/measurement_definitions` — lookup tables that give milestones and lifecycle measurements their names and ordering (medium)
- [ ] `/v1/ticketing/tickets (plus /v1/ticketing/priorities, /v1/ticketing/ticket_tags)` — follow-up work tracked off incidents, entirely absent today (medium)
-- [ ] `/v1/services/{service_id}/dependencies` — service dependency graph edges; services are synced but their relationships are not (medium)
+- [x] `/v1/services/{service_id}/dependencies` — service dependency graph edges; services are synced but their relationships are not (medium)
- [ ] `/v1/metrics/incidents, /v1/metrics/milestone_funnel, /v1/metrics/retrospectives, /v1/metrics/user_involvements` — prebuilt reporting aggregates for incident volume, funnel conversion and responder load (medium)
Note: The repo already carries products/warehouse_sources/backend/temporal/data_imports/sources/firehydrant/api_inventory.md, which cites this same spec. The docs sidebar at docs.firehydrant.com additionally lists list_audit_events and list_incident_retrospectives, which do not appear in the SDK OpenAPI file, so paths for those could not be confirmed and they are omitted.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/firehydrant/api_inventory.md b/products/warehouse_sources/backend/temporal/data_imports/sources/firehydrant/api_inventory.md
index 7a9ccd7436e5..edb51b6efbd0 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/firehydrant/api_inventory.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/firehydrant/api_inventory.md
@@ -45,11 +45,14 @@ Walked once per parent row, through the shared dependent-resource helper. The pa
into each child row and forms part of the primary key, because FireHydrant only documents the child
ids as unique within their parent.
-| Schema name | Path | Parent | Primary key | Partition key |
-| ------------------------ | ----------------------------------------- | --------- | --------------- | ------------- |
-| incident_milestones | `/v1/incidents/{incident_id}/milestones` | incidents | incident_id, id | created_at |
-| incident_tasks | `/v1/incidents/{incident_id}/tasks` | incidents | incident_id, id | created_at |
-| team_escalation_policies | `/v1/teams/{team_id}/escalation_policies` | teams | team_id, id | — |
+| Schema name | Path | Parent | Primary key | Partition key |
+| ------------------------- | ---------------------------------------------- | --------- | --------------- | ------------- |
+| incident_milestones | `/v1/incidents/{incident_id}/milestones` | incidents | incident_id, id | created_at |
+| incident_tasks | `/v1/incidents/{incident_id}/tasks` | incidents | incident_id, id | created_at |
+| incident_events | `/v1/incidents/{incident_id}/events` | incidents | incident_id, id | occurred_at |
+| incident_role_assignments | `/v1/incidents/{incident_id}/role_assignments` | incidents | incident_id, id | created_at |
+| team_escalation_policies | `/v1/teams/{team_id}/escalation_policies` | teams | team_id, id | — |
+| service_dependencies | `/v1/services/{service_id}/dependencies` | services | service_id, id | created_at |
`/v1/incidents/{incident_id}/milestones` is the one paginated endpoint whose spec entry lists no
`page` / `per_page` params, though it returns the same paginated envelope as its siblings. The spec
@@ -57,6 +60,23 @@ also leaves the escalation policies response body empty, as it does for 100+ oth
endpoints; transport reads the standard `data` envelope either way and degrades to zero rows if the
endpoint answers differently.
+`/v1/services/{service_id}/dependencies` is the one endpoint that answers outside the `data` envelope.
+It is unpaginated and returns `child_service_dependencies` / `parent_service_dependencies` /
+`service_dependencies`; we request `flatten=true` and read `service_dependencies`, so each row keeps
+the `type` saying which direction the edge runs. A dependency edge is shared by the two services it
+joins, so the same edge id is returned under both — the parent service id is what makes each row
+unique table-wide.
+
+## Endpoints considered and not implemented
+
+- `/v1/metrics/mttx` (and the sibling `/v1/metrics/*` reports). These are report queries, not
+ collections: `start_date` and `end_date` are required, `group_by` is only accepted in a
+ `multipart/form-data` body on a GET, and the returned rows are recomputed aggregates keyed by an
+ opaque `group_attributes` string with no stable identifier to merge on. Any table we built would
+ hold whatever date range we invented. MTTA/MTTR/MTTM can be derived in HogQL from the synced
+ `incidents` and `incident_milestones` tables instead, which is the data FireHydrant computes them
+ from.
+
## Future enhancements
- Incremental sync on `/v1/incidents` via `created_at_or_after` / `updated_after` once the filter behavior and default sort order can be curl-verified against a live account.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/firehydrant/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/firehydrant/canonical_descriptions.py
index ec39ccbf91fb..21346858a878 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/firehydrant/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/firehydrant/canonical_descriptions.py
@@ -285,4 +285,46 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"team_id": "UUID of the team the escalation policy belongs to.",
},
},
+ "incident_events": {
+ "description": "The incident timeline: every entry recorded against an incident, such as notes, chat messages, status changes, role and task updates, and linked alerts.",
+ "docs_url": "https://docs.firehydrant.com/reference/list_incident_events",
+ "columns": {
+ "id": "UUID of the timeline event.",
+ "incident_id": "UUID of the incident the event belongs to.",
+ "type": "The kind of timeline entry, for example note, chat_message or incident_status.",
+ "context": "Where the event came from.",
+ "data": "The event body. Its shape depends on the event type.",
+ "occurred_at": "The time the event happened.",
+ "visibility": "Who can see the event: private_to_org, open_to_public or internal_status_page.",
+ "author": "The user or integration that produced the event.",
+ "votes": "Vote counts recorded on the event.",
+ "conversations": "Conversation references linked to the event.",
+ },
+ },
+ "incident_role_assignments": {
+ "description": "Which user held which incident role on each incident, joining incidents to users and incident_roles.",
+ "docs_url": "https://docs.firehydrant.com/reference/list_incident_role_assignments",
+ "columns": {
+ "id": "UUID of the role assignment.",
+ "incident_id": "UUID of the incident the role was assigned on.",
+ "status": "Whether the assignment is active or inactive.",
+ "incident_role": "The incident role that was assigned.",
+ "user": "The user the role was assigned to.",
+ "created_at": "The time the role was assigned.",
+ "updated_at": "The time the assignment was last changed.",
+ },
+ },
+ "service_dependencies": {
+ "description": "Edges of the service dependency graph. One row per dependency between the parent service and another service, in either direction.",
+ "docs_url": "https://docs.firehydrant.com/reference/get_service_dependencies",
+ "columns": {
+ "id": "UUID of the dependency edge.",
+ "service_id": "UUID of the service the dependency was read from.",
+ "service": "The service on the other end of the dependency.",
+ "type": "Which way the edge runs, relative to the service it was read from.",
+ "notes": "Free-text notes recorded on the dependency.",
+ "created_at": "The time the dependency was created.",
+ "updated_at": "The time the dependency was last changed.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/firehydrant/firehydrant.py b/products/warehouse_sources/backend/temporal/data_imports/sources/firehydrant/firehydrant.py
index e1e0e57c7d85..a05c90726faa 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/firehydrant/firehydrant.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/firehydrant/firehydrant.py
@@ -134,15 +134,15 @@ def firehydrant_source(
job_id=job_id,
db_incremental_field_last_value=None,
page_size_param="per_page",
- # A response that drops the `data` envelope is a shape change, not an empty page:
+ # A response that drops its rows envelope is a shape change, not an empty page:
# tolerating it would silently replace the whole table with no rows.
parent_endpoint_extra={
- "data_selector": "data",
+ "data_selector": FIREHYDRANT_ENDPOINTS[config.fanout.parent_name].data_selector,
"data_selector_required": True,
"data_selector_empty_ok": True,
},
child_endpoint_extra={
- "data_selector": "data",
+ "data_selector": config.data_selector,
"data_selector_required": True,
"data_selector_empty_ok": True,
},
@@ -162,7 +162,7 @@ def firehydrant_source(
# Paginated endpoints wrap rows in a top-level `data` array. A missing/empty
# `data` key degrades to zero rows (not required) so an endpoint with nothing
# to return ends cleanly rather than raising.
- "data_selector": "data",
+ "data_selector": config.data_selector,
},
}
],
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/firehydrant/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/firehydrant/settings.py
index 3babaae1e394..154f62f1b8bb 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/firehydrant/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/firehydrant/settings.py
@@ -27,6 +27,9 @@ class FireHydrantEndpointConfig:
page_size: int = PAGE_SIZE
# Read by the shared fan-out builder; every FireHydrant endpoint is full refresh, so it stays None.
default_incremental_field: Optional[str] = None
+ # JSON path the rows live under. Nearly every endpoint uses the paginated `data` envelope;
+ # /v1/services/{service_id}/dependencies answers with a named array instead.
+ data_selector: str = "data"
# Endpoint catalog. Paths are the FireHydrant v1 REST collection endpoints (verified against the
@@ -107,6 +110,51 @@ FIREHYDRANT_ENDPOINTS: dict[str, FireHydrantEndpointConfig] = {
parent_field_renames={"id": "team_id"},
),
),
+ # IncidentEventEntity carries no created_at; occurred_at is the (immutable) time the timeline
+ # entry happened, so it is the stable field to partition on.
+ "incident_events": FireHydrantEndpointConfig(
+ path="/v1/incidents/{incident_id}/events",
+ partition_key="occurred_at",
+ primary_keys=["incident_id", "id"],
+ fanout=DependentEndpointConfig(
+ parent_name="incidents",
+ resolve_param="incident_id",
+ resolve_field="id",
+ include_from_parent=["id"],
+ parent_field_renames={"id": "incident_id"},
+ ),
+ ),
+ "incident_role_assignments": FireHydrantEndpointConfig(
+ path="/v1/incidents/{incident_id}/role_assignments",
+ partition_key="created_at",
+ primary_keys=["incident_id", "id"],
+ fanout=DependentEndpointConfig(
+ parent_name="incidents",
+ resolve_param="incident_id",
+ resolve_field="id",
+ include_from_parent=["id"],
+ parent_field_renames={"id": "incident_id"},
+ ),
+ ),
+ # Dependency edges are shared between the two services they join, so the same edge id comes back
+ # under both endpoints; the parent service is what makes each row unique.
+ "service_dependencies": FireHydrantEndpointConfig(
+ path="/v1/services/{service_id}/dependencies",
+ partition_key="created_at",
+ primary_keys=["service_id", "id"],
+ data_selector="service_dependencies",
+ fanout=DependentEndpointConfig(
+ parent_name="services",
+ resolve_param="service_id",
+ resolve_field="id",
+ include_from_parent=["id"],
+ parent_field_renames={"id": "service_id"},
+ # `flatten` collapses the parent/child arrays into `service_dependencies`; each row keeps
+ # a `type` saying which direction the edge runs. Sent as a lowercase string because the
+ # API rejects Python's `True` repr.
+ child_params={"flatten": "true"},
+ ),
+ ),
}
ENDPOINTS = tuple(FIREHYDRANT_ENDPOINTS.keys())
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/firehydrant/tests/test_firehydrant.py b/products/warehouse_sources/backend/temporal/data_imports/sources/firehydrant/tests/test_firehydrant.py
index 48ebdb743b2e..14524f6d3a5d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/firehydrant/tests/test_firehydrant.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/firehydrant/tests/test_firehydrant.py
@@ -283,6 +283,37 @@ class TestFanout:
)
)
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_service_dependencies_read_the_flattened_named_array(self, MockSession) -> None:
+ # This endpoint answers outside the `data` envelope: reading `data` would sync zero rows,
+ # and reading the split arrays instead of the flattened one would double-count each edge.
+ session = MockSession.return_value
+ dependencies = Response()
+ dependencies.status_code = 200
+ dependencies._content = json.dumps(
+ {
+ "child_service_dependencies": [{"id": "d1", "type": "child"}],
+ "parent_service_dependencies": [{"id": "d2", "type": "parent"}],
+ "service_dependencies": [{"id": "d1", "type": "child"}, {"id": "d2", "type": "parent"}],
+ }
+ ).encode()
+ params, urls = _wire(session, [_response([{"id": "svc1"}], next_page=None), dependencies])
+
+ rows = _rows(
+ firehydrant_source(
+ "fhb_test", "service_dependencies", team_id=1, job_id="j", resumable_source_manager=_make_manager()
+ )
+ )
+
+ assert urls[1] == "https://api.firehydrant.io/v1/services/svc1/dependencies"
+ # The parent service id is what keeps an edge unique — the same edge id comes back under
+ # both services it joins.
+ assert rows == [
+ {"id": "d1", "type": "child", "service_id": "svc1"},
+ {"id": "d2", "type": "parent", "service_id": "svc1"},
+ ]
+ assert params[1]["flatten"] == "true"
+
@mock.patch(CLIENT_SESSION_PATCH)
def test_empty_child_body_is_zero_rows(self, MockSession) -> None:
# An empty container carries no rows and no alternative shape, so it must not fail loud.
@@ -322,9 +353,10 @@ class TestSourceResponse:
def test_partition_keys_are_stable_creation_fields(self) -> None:
# A partition key that changes (updated_at/lastSeen) rewrites partitions every sync.
+ # `occurred_at` is when a timeline event happened, which is as immutable as `created_at`.
for config in FIREHYDRANT_ENDPOINTS.values():
if config.partition_key:
- assert config.partition_key == "created_at"
+ assert config.partition_key in {"created_at", "occurred_at"}
@parameterized.expand(
[