Skip to content

Commit e558183

Browse files
Self-host: precise local setup docs + CLICKHOUSE_SECURE support (local ClickHouse) [Devin] (#1242)
self-host (minimal): CLICKHOUSE_SECURE support + precise local setup docs Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Alex <[email protected]>
1 parent 5d9718e commit e558183

File tree

7 files changed

+166
-2
lines changed

7 files changed

+166
-2
lines changed

app/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,61 @@
1+
Restart local stack and verify
2+
3+
- Restart services:
4+
docker compose -f compose.yaml -f opentelemetry-collector/compose.yaml down --remove-orphans
5+
docker compose -f compose.yaml -f opentelemetry-collector/compose.yaml up -d
6+
7+
- Check logs:
8+
docker compose -f compose.yaml -f opentelemetry-collector/compose.yaml logs --since=90s api
9+
docker compose -f compose.yaml -f opentelemetry-collector/compose.yaml logs --since=90s dashboard
10+
docker compose -f compose.yaml -f opentelemetry-collector/compose.yaml logs --since=90s otelcollector
11+
docker compose -f compose.yaml -f opentelemetry-collector/compose.yaml logs --since=90s clickhouse
12+
13+
- Open dashboard:
14+
http://localhost:3000/signin
15+
16+
- Generate a trace (example):
17+
AGENTOPS_API_KEY=&lt;key&gt; \
18+
AGENTOPS_API_ENDPOINT=http://localhost:8000 \
19+
AGENTOPS_APP_URL=http://localhost:3000 \
20+
AGENTOPS_EXPORTER_ENDPOINT=http://localhost:4318/v1/traces \
21+
OPENAI_API_KEY=&lt;openai_key&gt; \
22+
python examples/openai/openai_example_sync.py
23+
24+
- Verify ClickHouse and dashboard:
25+
curl -s -u default:password "http://localhost:8123/?query=SELECT%20count()%20FROM%20otel_2.otel_traces%20WHERE%20TraceId%20=%20'&lt;TRACE_ID&gt;'"
26+
27+
http://localhost:3000/traces?trace_id=&lt;TRACE_ID&gt;
28+
29+
30+
Local ClickHouse (self-hosted)
31+
- Set in .env:
32+
CLICKHOUSE_HOST=127.0.0.1
33+
CLICKHOUSE_PORT=8123
34+
CLICKHOUSE_USER=default
35+
CLICKHOUSE_PASSWORD=password
36+
CLICKHOUSE_DATABASE=otel_2
37+
CLICKHOUSE_SECURE=false
38+
CLICKHOUSE_ENDPOINT=http://clickhouse:8123
39+
CLICKHOUSE_USERNAME=default
40+
41+
- Start services (includes otelcollector + local ClickHouse):
42+
docker compose -f compose.yaml -f opentelemetry-collector/compose.yaml up -d
43+
44+
- Initialize ClickHouse schema:
45+
curl -u default:password 'http://localhost:8123/?query=CREATE%20DATABASE%20IF%20NOT%20EXISTS%20otel_2'
46+
curl --data-binary @app/clickhouse/migrations/0000_init.sql -u default:password 'http://localhost:8123/?query='
47+
48+
- Run example with local OTLP exporter:
49+
AGENTOPS_API_KEY=<your_key> \
50+
AGENTOPS_API_ENDPOINT=http://localhost:8000 \
51+
AGENTOPS_APP_URL=http://localhost:3000 \
52+
AGENTOPS_EXPORTER_ENDPOINT=http://localhost:4318/v1/traces \
53+
OPENAI_API_KEY=<openai_key> \
54+
python examples/openai/openai_example_sync.py
55+
56+
- Verify:
57+
- Dashboard: http://localhost:3000/traces?trace_id=<printed_id>
58+
- CH rows: curl -s -u default:password "http://localhost:8123/?query=SELECT%20count()%20FROM%20otel_2.otel_traces%20WHERE%20TraceId%20=%20'<TRACE_ID>'"
159
# AgentOps
260

361
[![License: ELv2](https://img.shields.io/badge/License-ELv2-blue.svg)](https://www.elastic.co/licensing/elastic-license)
@@ -312,6 +370,7 @@ AgentOps requires several external services. Here's how to set them up:
312370
```
313371
4. Run migrations: `supabase db push`
314372

373+
For Linux environments with CLI install issues, see docs/local_supabase_linux.md for a manual binary install and env mapping steps.
315374
**Option B: Cloud Supabase**
316375

317376
1. Create a new project at [supabase.com](https://supabase.com)

app/api/agentops/api/db/clickhouse_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
CLICKHOUSE_PASSWORD,
1414
CLICKHOUSE_PORT,
1515
CLICKHOUSE_USER,
16+
CLICKHOUSE_SECURE,
1617
)
1718

1819
# Global variables to store client instances
@@ -37,7 +38,7 @@ class ConnectionConfig:
3738
database: str = CLICKHOUSE_DATABASE
3839
username: str = CLICKHOUSE_USER
3940
password: str = CLICKHOUSE_PASSWORD
40-
secure: bool = True
41+
secure: bool = CLICKHOUSE_SECURE
4142

4243
def __init__(self) -> None:
4344
"""Non-instantiable class has a lower chance of being printed."""

app/api/agentops/api/environment.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
CLICKHOUSE_USER: str = os.getenv("CLICKHOUSE_USER", "")
1919
CLICKHOUSE_PASSWORD: str = os.getenv("CLICKHOUSE_PASSWORD", "")
2020
CLICKHOUSE_DATABASE: str = os.getenv("CLICKHOUSE_DATABASE", "")
21+
CLICKHOUSE_SECURE: bool = os.getenv("CLICKHOUSE_SECURE", "false").lower() in ("1", "true", "yes")
2122

2223

2324
PROFILING_ENABLED: bool = os.environ.get("PROFILING_ENABLED", "false").lower() == "true"

app/compose.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ services:
3737
CLICKHOUSE_SECURE: ${CLICKHOUSE_SECURE}
3838
CLICKHOUSE_ENDPOINT: ${CLICKHOUSE_ENDPOINT}
3939
CLICKHOUSE_USERNAME: ${CLICKHOUSE_USERNAME}
40+
SUPABASE_S3_BUCKET: ${SUPABASE_S3_BUCKET}
41+
SUPABASE_S3_LOGS_BUCKET: ${SUPABASE_S3_LOGS_BUCKET}
42+
SUPABASE_S3_ACCESS_KEY_ID: ${SUPABASE_S3_ACCESS_KEY_ID}
43+
SUPABASE_S3_SECRET_ACCESS_KEY: ${SUPABASE_S3_SECRET_ACCESS_KEY}
4044
network_mode: 'host'
4145
volumes:
4246
- ./api:/app/api

app/opentelemetry-collector/compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ services:
2525
- TRACES_TABLE_NAME=${TRACES_TABLE_NAME:-otel_traces}
2626
- CLICKHOUSE_TTL=${CLICKHOUSE_TTL:-12h}
2727
- CLICKHOUSE_TIMEOUT=${CLICKHOUSE_TIMEOUT:-10s}
28-
- JWT_SECRET=${JWT_SECRET:-}
28+
- JWT_SECRET=${JWT_SECRET_KEY:-super-secret-jwt-token-with-at-least-32-characters-long}
2929

3030
clickhouse:
3131
image: clickhouse/clickhouse-server:24.12

docs/local_clickhouse_setup.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Restart and verify
2+
3+
docker compose -f app/compose.yaml -f app/opentelemetry-collector/compose.yaml down --remove-orphans
4+
docker compose -f app/compose.yaml -f app/opentelemetry-collector/compose.yaml up -d
5+
docker compose -f app/compose.yaml -f app/opentelemetry-collector/compose.yaml logs --since=90s api
6+
docker compose -f app/compose.yaml -f app/opentelemetry-collector/compose.yaml logs --since=90s otelcollector
7+
docker compose -f app/compose.yaml -f app/opentelemetry-collector/compose.yaml logs --since=90s clickhouse
8+
9+
Open http://localhost:3000/signin
10+
11+
12+
Local ClickHouse Setup
13+
14+
1) Environment (.env)
15+
CLICKHOUSE_HOST=127.0.0.1
16+
CLICKHOUSE_PORT=8123
17+
CLICKHOUSE_USER=default
18+
CLICKHOUSE_PASSWORD=password
19+
CLICKHOUSE_DATABASE=otel_2
20+
CLICKHOUSE_SECURE=false
21+
CLICKHOUSE_ENDPOINT=http://clickhouse:8123
22+
CLICKHOUSE_USERNAME=default
23+
24+
2) Start services (includes local ClickHouse and otelcollector)
25+
docker compose -f app/compose.yaml -f app/opentelemetry-collector/compose.yaml up -d
26+
27+
3) Initialize ClickHouse schema
28+
curl -u default:password 'http://localhost:8123/?query=CREATE%20DATABASE%20IF%20NOT%20EXISTS%20otel_2'
29+
curl --data-binary @app/clickhouse/migrations/0000_init.sql -u default:password 'http://localhost:8123/?query='
30+
31+
4) Run OpenAI example with local OTLP
32+
AGENTOPS_API_KEY=<agentops_key> \
33+
AGENTOPS_API_ENDPOINT=http://localhost:8000 \
34+
AGENTOPS_APP_URL=http://localhost:3000 \
35+
AGENTOPS_EXPORTER_ENDPOINT=http://localhost:4318/v1/traces \
36+
OPENAI_API_KEY=<openai_key> \
37+
python examples/openai/openai_example_sync.py
38+
39+
5) Verify
40+
- Dashboard: http://localhost:3000/traces?trace_id=<TRACE_ID>
41+
- ClickHouse:
42+
curl -s -u default:password "http://localhost:8123/?query=SHOW%20TABLES%20FROM%20otel_2"
43+
curl -s -u default:password "http://localhost:8123/?query=SELECT%20count()%20FROM%20otel_2.otel_traces%20WHERE%20TraceId%20=%20'<TRACE_ID>'"

docs/local_supabase_linux.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
Local Supabase on Linux (CLI install fallback)
2+
3+
1) Install CLI
4+
- Download latest Linux x86_64 binary from https://github.com/supabase/cli/releases/latest
5+
- Extract to ~/.supabase/bin and chmod +x
6+
- Add to PATH:
7+
export PATH="$HOME/.supabase/bin:$PATH"
8+
- Verify:
9+
supabase --version
10+
11+
2) Initialize and start in app/
12+
- cd ~/repos/agentops/app
13+
- supabase init
14+
- supabase start
15+
16+
3) Capture credentials from output
17+
- URL: http://127.0.0.1:54321
18+
- anon key
19+
- service_role key
20+
- Postgres: host 127.0.0.1, port 54322, user postgres, password postgres, database postgres
21+
22+
4) Fill envs
23+
- app/.env
24+
NEXT_PUBLIC_SUPABASE_URL=http://127.0.0.1:54321
25+
NEXT_PUBLIC_SUPABASE_ANON_KEY=<anon>
26+
SUPABASE_SERVICE_ROLE_KEY=<service_role>
27+
SUPABASE_PROJECT_ID=local
28+
SUPABASE_HOST=127.0.0.1
29+
SUPABASE_PORT=54322
30+
SUPABASE_DATABASE=postgres
31+
SUPABASE_USER=postgres
32+
SUPABASE_PASSWORD=postgres
33+
- app/api/.env
34+
SUPABASE_URL=http://127.0.0.1:54321
35+
SUPABASE_KEY=<service_role>
36+
SUPABASE_HOST=127.0.0.1
37+
SUPABASE_PORT=54322
38+
SUPABASE_DATABASE=postgres
39+
SUPABASE_USER=postgres
40+
SUPABASE_PASSWORD=postgres
41+
- app/dashboard/.env.local
42+
NEXT_PUBLIC_SUPABASE_URL=http://127.0.0.1:54321
43+
NEXT_PUBLIC_SUPABASE_ANON_KEY=<anon>
44+
SUPABASE_SERVICE_ROLE_KEY=<service_role>
45+
SUPABASE_PROJECT_ID=local
46+
47+
5) Run stack
48+
- From app/: docker compose up -d
49+
- API: http://localhost:8000/redoc
50+
- Dashboard: http://localhost:3000
51+
52+
6) Notes
53+
- Playground must be disabled:
54+
app/.env -> NEXT_PUBLIC_PLAYGROUND=false
55+
app/dashboard/.env.local -> NEXT_PUBLIC_PLAYGROUND="false"
56+
- ClickHouse Cloud requires IP allowlist.

0 commit comments

Comments
 (0)