Skip to content

feat(clickhouse): add service_logs migration for internal service logs - #3455

Draft
rguliyev wants to merge 2 commits into
mainfrom
feat/internal-loki-clickhouse
Draft

feat(clickhouse): add service_logs migration for internal service logs#3455
rguliyev wants to merge 2 commits into
mainfrom
feat/internal-loki-clickhouse

Conversation

@rguliyev

@rguliyev rguliyev commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a goose migration owning the service_logs table used by the OTel collectors' ClickHouse log export of internal (platform service) logs, replacing the exporter's create_schema auto-DDL
  • column set, indexes, partitioning and sort key mirror the upstream clickhouseexporter v0.146.0 logs_table.sql exactly, so the exporter's fixed INSERT column list keeps working with create_schema: false (the exporter introspects optional columns like EventName at startup)
  • adds what create_schema never set: a 30-day TTL and a Distributed('cluster', ...) wrapper (cluster name rewritten by the migrator job on deployments that use a different cluster name)
  • service_logs (platform-internal, engineer-facing, 30-day retention, random sharding) is deliberately separate from the customer-facing sandbox_logs table: different tenancy, retention, sharding and exposure boundaries
  • every statement is individually re-runnable (ClickHouse has no transactional DDL); the initial DROPs discard the exporter-created otel_logs staging validation table

Testing

  • ran the full migration chain with goose against a throwaway single-node ClickHouse 25.6 container configured with the repo's local cluster definition: all migrations apply cleanly including this one
  • pre-created a plain otel_logs MergeTree (simulating the exporter-created staging table): dropped correctly, no leftovers in system.tables
  • exporter-style INSERT (15 fixed columns, no TimestampTime/EventName) through the Distributed service_logs table: succeeds, TimestampTime DEFAULT materializes
  • verified resulting engine Distributed('cluster', 'default', 'service_logs_local', rand()) and TTL TimestampTime + toIntervalDay(30) in system.tables

Rollout

Merge and promote the migrator image before (or with) the collectors switching to create_schema: false and logs_table_name: service_logs. The exporters' retry queue covers the brief window while the migration runs.

@rguliyev
rguliyev requested a review from a team as a code owner July 30, 2026 03:54
@cla-bot cla-bot Bot added the cla-signed label Jul 30, 2026
@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
3715 1 3714 9
View the top 3 failed test(s) by shortest run time
github.com/e2b-dev/infra/tests/integration/internal/tests/api/sandboxes::TestSnapshotTemplateCreateSandbox
Stack Traces | 0s run time
=== RUN   TestSnapshotTemplateCreateSandbox
=== PAUSE TestSnapshotTemplateCreateSandbox
=== CONT  TestSnapshotTemplateCreateSandbox
--- FAIL: TestSnapshotTemplateCreateSandbox (0.00s)
github.com/e2b-dev/infra/tests/integration/internal/tests/proxies::TestMaskRequestHostAPIParameter
Stack Traces | 5.61s run time
=== RUN   TestMaskRequestHostAPIParameter
=== PAUSE TestMaskRequestHostAPIParameter
=== CONT  TestMaskRequestHostAPIParameter
    mask_request_host_test.go:44: Command [python3] output: event:{start:{pid:1409}}
    mask_request_host_test.go:44: Command [python3] output: event:{end:{exited:true  status:"exit status 0"}}
    mask_request_host_test.go:44: Command [python3] completed successfully in sandbox iko1xy8nw50h62cg7zo3x
    mask_request_host_test.go:68: Command [cat] output: event:{start:{pid:1410}}
    mask_request_host_test.go:69: 
        	Error Trace:	.../tests/proxies/mask_request_host_test.go:69
        	Error:      	Received unexpected error:
        	            	failed to execute command cat in sandbox iko1xy8nw50h62cg7zo3x: invalid_argument: protocol error: incomplete envelope: unexpected EOF
        	Test:       	TestMaskRequestHostAPIParameter
--- FAIL: TestMaskRequestHostAPIParameter (5.61s)
github.com/e2b-dev/infra/tests/integration/internal/tests/api/sandboxes::TestSnapshotTemplateCreateSandbox/overwritten_snapshot_build_is_served_immediately_on_sandbox_create
Stack Traces | 47.1s run time
=== RUN   TestSnapshotTemplateCreateSandbox/overwritten_snapshot_build_is_served_immediately_on_sandbox_create
=== PAUSE TestSnapshotTemplateCreateSandbox/overwritten_snapshot_build_is_served_immediately_on_sandbox_create
=== CONT  TestSnapshotTemplateCreateSandbox/overwritten_snapshot_build_is_served_immediately_on_sandbox_create
    snapshot_template_test.go:392: 
        	Error Trace:	.../api/sandboxes/snapshot_template_test.go:392
        	Error:      	Received unexpected error:
        	            	failed to execute command /bin/sh in sandbox ioswi2w2w3r7uli4yoyqd: unavailable: HTTP status 502 Bad Gateway
        	Test:       	TestSnapshotTemplateCreateSandbox/overwritten_snapshot_build_is_served_immediately_on_sandbox_create
        	Messages:   	failed to write marker file
--- FAIL: TestSnapshotTemplateCreateSandbox/overwritten_snapshot_build_is_served_immediately_on_sandbox_create (47.15s)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Comment thread packages/clickhouse/migrations/20260730090000_add_otel_logs.sql Outdated
@rguliyev
rguliyev force-pushed the feat/internal-loki-clickhouse branch from f3b00e2 to 6040cc3 Compare July 30, 2026 04:05
@rguliyev rguliyev changed the title feat(clickhouse): add otel_logs migration for internal service logs feat(clickhouse): add service_logs migration for internal service logs Jul 30, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6040cc39f0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/clickhouse/migrations/20260730090000_add_service_logs.sql
@rguliyev
rguliyev force-pushed the feat/internal-loki-clickhouse branch from edffbde to 7facb3b Compare July 30, 2026 17:29
rguliyev added 2 commits July 30, 2026 10:57
Owns the schema the OTel collectors' clickhouse exporter previously
created itself (create_schema) when exporting internal service logs:
same column set, indexes and sort key as the upstream v0.146.0 DDL, so
the exporter's fixed INSERT list keeps working, plus what create_schema
never set - a 30-day TTL and the Distributed wrapper (cluster name
rewritten by the migrator job where deployments use a different one).

service_logs (platform-internal, engineer-facing, 30d, random sharding)
is deliberately separate from the customer-facing sandbox_logs table.

Statements are individually re-runnable (no transactional DDL in
ClickHouse); the initial DROPs discard the exporter-created otel_logs
staging table.
@rguliyev
rguliyev force-pushed the feat/internal-loki-clickhouse branch from 7facb3b to 23d328e Compare July 30, 2026 17:57
@rguliyev
rguliyev marked this pull request as draft July 30, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants