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(warehouse-sources): add koyeb projects and catalog tables (#113897)

Tom Owers2a98ed853586
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 6baab6625536..9fcd13ada01f 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
@@ -4864,10 +4864,10 @@ Today (16): `activities`, `app_events`, `apps`, `deployment_events`, `deployment
Diffed against: <https://raw.githubusercontent.com/koyeb/koyeb-api-client-go/main/api/v1/koyeb/api/openapi.yaml>
-- [ ] `/v1/catalog/instances` — lookup resolving the instance_type on services/deployments to vCPU, memory and price (high)
-- [ ] `/v1/catalog/regions` — lookup resolving region codes carried on regional_deployments and instances (high)
-- [ ] `/v1/projects` — lookup that groups apps and services; project_id is unresolvable today (high)
-- [ ] `/v1/usages` — org-level usage rollup; PostHog syncs only usages/details, so totals must be re-derived (medium)
+- [x] `/v1/catalog/instances` — lookup resolving the instance_type on services/deployments to vCPU, memory and price (high). Added as `catalog_instances`.
+- [x] `/v1/catalog/regions` — lookup resolving region codes carried on regional_deployments and instances (high). Added as `catalog_regions`.
+- [x] `/v1/projects` — lookup that groups apps and services; project_id is unresolvable today (high). Added as `projects`.
+- ~~`/v1/usages`~~ — not table material: the reply is one nested object per period that sums `duration_seconds` by app, service, region and instance type. `usage_details` already holds those per-run durations, so the rollup is a `GROUP BY` over it.
- [ ] `/v1/volume_events` — volume lifecycle history, the only event stream missing while app/service/deployment/instance events are synced (medium)
- [ ] `/v1/regional_deployment_events` — per-region deployment transition history to explain rollout failures (medium)
- [ ] `/v1/catalog/datacenters` — lookup mapping datacenter ids on regional deployments to physical locations (medium)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/koyeb/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/koyeb/canonical_descriptions.py
index 56c7199212b4..e232016521a1 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/koyeb/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/koyeb/canonical_descriptions.py
@@ -5,6 +5,19 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.can
# Descriptions sourced from the Koyeb public API reference (https://developer.koyeb.com/public),
# generated from the spec at https://api.prod.koyeb.com/public.swagger.json.
CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
+ "projects": {
+ "description": "Projects in your Koyeb organization. A project groups related apps and services.",
+ "docs_url": "https://developer.koyeb.com/public#tag/projects",
+ "columns": {
+ "id": "Unique identifier of the project.",
+ "name": "Name of the project.",
+ "description": "Description of the project.",
+ "organization_id": "Identifier of the organization owning the project.",
+ "service_count": "Number of services in the project.",
+ "created_at": "When the project was created.",
+ "updated_at": "When the project was last updated.",
+ },
+ },
"apps": {
"description": "Applications in your Koyeb organization. An app groups services and holds the public *.koyeb.app domains assigned to them.",
"docs_url": "https://developer.koyeb.com/public#tag/apps",
@@ -220,4 +233,43 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"terminated_at": "When the instance run terminated.",
},
},
+ "catalog_instances": {
+ "description": "Catalog of Koyeb instance types with their resources, pricing, and availability. Join on instance_type to size and price services, deployments, and usage.",
+ "docs_url": "https://developer.koyeb.com/public#tag/catalog-instances",
+ "columns": {
+ "id": "Name of the instance type (e.g. nano, small).",
+ "display_name": "Display name of the instance type.",
+ "description": "Short description of the instance type.",
+ "type": "Type of the instance (e.g. gpu).",
+ "vcpu": "Number of CPUs. Deprecated in favor of vcpu_shares.",
+ "vcpu_shares": "Number of vCPU shares reserved for the instance.",
+ "memory": "Memory of the instance, in a format like 5MB.",
+ "disk": "Disk size of the instance, in a format like 5MB.",
+ "gpu": "GPU details (count, brand, memory, name) for GPU instance types.",
+ "price_per_second": "Price per second of running the instance.",
+ "price_hourly": "Price per hour of running the instance.",
+ "price_monthly": "Price per month of running the instance.",
+ "regions": "Regions where the instance type is available.",
+ "service_types": "Service types allowed on the instance type (e.g. web, worker).",
+ "require_plan": "Plans required to use the instance type.",
+ "aliases": "Alternative names for the instance type.",
+ "volumes_enabled": "Whether volumes can be attached to the instance type.",
+ "light_sleep_enabled": "Whether light sleep is available for the instance type.",
+ "status": "Availability status of the instance type.",
+ },
+ },
+ "catalog_regions": {
+ "description": "Catalog of Koyeb regions with their location and the instance types available in each. Join on region to resolve the region codes on deployments, instances, and usage.",
+ "docs_url": "https://developer.koyeb.com/public#tag/catalog-regions",
+ "columns": {
+ "id": "Code of the region (e.g. fra, was).",
+ "name": "Name of the region.",
+ "coordinates": "Latitude and longitude of the region.",
+ "scope": "Scope of the region, such as continent or metropolitan area.",
+ "status": "Availability status of the region.",
+ "instances": "Instance types available in the region.",
+ "datacenters": "Datacenters available in the region.",
+ "volumes_enabled": "Whether volumes are available in the region.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/koyeb/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/koyeb/settings.py
index 6bef612d2235..25d8414c8ee6 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/koyeb/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/koyeb/settings.py
@@ -43,6 +43,13 @@ class KoyebEndpointConfig:
# `activities` are append-only but expose no time filter, so re-paging them is a full refresh by
# definition; the remaining config entities are small and ship as full refresh too.
KOYEB_ENDPOINTS: dict[str, KoyebEndpointConfig] = {
+ "projects": KoyebEndpointConfig(
+ name="projects",
+ path="/v1/projects",
+ response_data_key="projects",
+ primary_keys=["id"],
+ partition_key="created_at",
+ ),
"apps": KoyebEndpointConfig(
name="apps",
path="/v1/apps",
@@ -186,6 +193,20 @@ KOYEB_ENDPOINTS: dict[str, KoyebEndpointConfig] = {
supports_order=True,
requires_time_window=True,
),
+ # Koyeb-wide catalogs, not organization data: `id` is the instance type or region code that
+ # services, deployments and usage rows reference. Catalog rows carry no timestamps.
+ "catalog_instances": KoyebEndpointConfig(
+ name="catalog_instances",
+ path="/v1/catalog/instances",
+ response_data_key="instances",
+ primary_keys=["id"],
+ ),
+ "catalog_regions": KoyebEndpointConfig(
+ name="catalog_regions",
+ path="/v1/catalog/regions",
+ response_data_key="regions",
+ primary_keys=["id"],
+ ),
}
ENDPOINTS = tuple(KOYEB_ENDPOINTS.keys())
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/koyeb/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/koyeb/source.py
index 7f221e9d3d23..3858084befbf 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/koyeb/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/koyeb/source.py
@@ -48,7 +48,7 @@ class KoyebSource(ResumableSource[KoyebSourceConfig, KoyebResumeConfig]):
category=DataWarehouseSourceCategory.ENGINEERING___MONITORING,
label="Koyeb",
releaseStatus=ReleaseStatus.ALPHA,
- caption="""Enter a Koyeb API token to pull your Koyeb apps, services, deployments, instances, event streams, and usage details into the PostHog Data warehouse.
+ caption="""Enter a Koyeb API token to pull your Koyeb projects, apps, services, deployments, instances, event streams, usage details, and the instance and region catalogs into the PostHog Data warehouse.
Create an API token under [API settings](https://app.koyeb.com/user/settings/api) in the Koyeb console. Tokens are scoped to the organization they were created in.""",
iconPath="/static/services/koyeb.svg",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/koyeb/tests/test_koyeb.py b/products/warehouse_sources/backend/temporal/data_imports/sources/koyeb/tests/test_koyeb.py
index 5aaa043adacd..1c0a795f0ab7 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/koyeb/tests/test_koyeb.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/koyeb/tests/test_koyeb.py
@@ -121,16 +121,29 @@ class TestValidateCredentials:
class TestPagination:
+ @parameterized.expand(
+ [
+ ("apps", "apps", True),
+ # Catalog replies carry only `count`, no `has_next`, so the short page must end the walk.
+ ("catalog_instances", "instances", None),
+ ]
+ )
@mock.patch(CLIENT_SESSION_PATCH)
- def test_follows_offset_pagination_and_progresses(self, MockSession) -> None:
+ def test_follows_offset_pagination_and_progresses(
+ self, endpoint: str, data_key: str, has_next: bool | None, MockSession
+ ) -> None:
session = MockSession.return_value
full_page = [{"id": str(i)} for i in range(100)]
snaps = _wire(
- session, [_response("apps", full_page, has_next=True), _response("apps", [{"id": "last"}], has_next=False)]
+ session,
+ [
+ _response(data_key, full_page, has_next=has_next),
+ _response(data_key, [{"id": "last"}], has_next=False if has_next else None),
+ ],
)
manager = _make_manager()
- rows = _rows(_run("apps", manager=manager))
+ rows = _rows(_run(endpoint, manager=manager))
assert len(rows) == 101
assert session.send.call_count == 2