Merge branch 'worktree-agent-a0da72b13ddddf5c2'
Browse files at this commit4 changed files +166 -0
- README.md +17 -0
- compose.yaml +128 -0
- observability/Containerfile.temps +20 -0
- observability/temps-admin-password +1 -0
README.mdmodified+17 -0
| @@ -240,6 +240,23 @@ container so the published port works. Production knobs (`COOKIE_SECURE`, | ||
| 240 | 240 | means dev mirror mode without credentials; a cookie-using browser frontend |
| 241 | 241 | must be allowlisted explicitly. Works with `docker compose` too. |
| 242 | 242 | |
| 243 | +Three more services make up the telemetry sink: `temps` (UI and API on | |
| 244 | +`127.0.0.1:3000`, OTLP ingest on `127.0.0.1:9000`) with its TimescaleDB and | |
| 245 | +ClickHouse stores. Its image is built locally from | |
| 246 | +`observability/Containerfile.temps` — the published one is tagged alpine but | |
| 247 | +ships a glibc binary that cannot exec. Temps refuses to start its console | |
| 248 | +without a container socket, so `systemctl --user start podman.socket` first. | |
| 249 | +Log in at http://127.0.0.1:3000 as `admin@hezarfen.local` with the password in | |
| 250 | +`observability/temps-admin-password`, then mint an ingest key (Settings → API | |
| 251 | +Keys, or `podman exec hezarfen-temps temps api-key --name <name>`) and note the | |
| 252 | +project id shown on the project page. Uncomment the backend's | |
| 253 | +`OTEL_EXPORTER_OTLP_ENDPOINT` (`http://temps:9000/api/otel`), | |
| 254 | +`OTEL_EXPORTER_OTLP_PROTOCOL` (`http/protobuf` — Temps has no gRPC listener) | |
| 255 | +and `OTEL_EXPORTER_OTLP_HEADERS` | |
| 256 | +(`Authorization=Bearer <key>,X-Temps-Project-Id=<id>`), and traces, metrics and | |
| 257 | +logs start landing. Signals are kept 90 days | |
| 258 | +(`TEMPS_OTEL_RETENTION_DAYS`). | |
| 259 | + | |
| 243 | 260 | The backend survives the database going away, at boot and at runtime. |
| 244 | 261 | |
| 245 | 262 | At boot it retries the connection (1s doubling to 5s) until the server |
compose.yamlmodified+128 -0
| @@ -58,6 +58,16 @@ services: | ||
| 58 | 58 | # RATE_LIMIT_AUTH_PER_MINUTE: "10" |
| 59 | 59 | # RATE_LIMIT_API_PER_MINUTE: "300" |
| 60 | 60 | # TRUST_PROXY: "true" |
| 61 | + # Telemetry — export traces, metrics and logs to Temps over OTLP/HTTP. | |
| 62 | + # Uncomment once a Temps project exists: create the project in the UI at | |
| 63 | + # http://127.0.0.1:3000, mint an API key (tk_...) under Settings > API | |
| 64 | + # Keys, and put its numeric project id in the header. OTLP/HTTP protobuf | |
| 65 | + # only — Temps has no gRPC port, and the ingest path is /api/otel/v1/*, | |
| 66 | + # so the endpoint carries the /api/otel prefix. | |
| 67 | + # OTEL_EXPORTER_OTLP_ENDPOINT: http://temps:9000/api/otel | |
| 68 | + # OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf | |
| 69 | + # OTEL_EXPORTER_OTLP_HEADERS: "Authorization=Bearer tk_xxx,X-Temps-Project-Id=1" | |
| 70 | + # OTEL_SERVICE_NAME: hezarfen-backend | |
| 61 | 71 | # AI bridge — the AI services dial IN over QUIC. Unset means off; a |
| 62 | 72 | # bad address or a missing token fails the boot rather than leaving a |
| 63 | 73 | # silently dead feature. Listening with no service connected is fine: |
| @@ -80,6 +90,124 @@ services: | ||
| 80 | 90 | retries: 3 |
| 81 | 91 | start_period: 10s |
| 82 | 92 | |
| 93 | + # ── Telemetry sink ──────────────────────────────────────────────────────── | |
| 94 | + # Temps is the only telemetry sink (no Grafana/Jaeger/Loki). It stores | |
| 95 | + # metadata in TimescaleDB and the OTLP signals themselves in ClickHouse, so | |
| 96 | + # both come along. Neither database is published to the host; only the Temps | |
| 97 | + # API/UI (3000) and its public ingest listener (9000) are, on loopback. | |
| 98 | + temps-postgres: | |
| 99 | + image: docker.io/gotempsh/timescaledb-walg:pg18 | |
| 100 | + container_name: hezarfen-temps-postgres | |
| 101 | + environment: | |
| 102 | + POSTGRES_DB: temps | |
| 103 | + POSTGRES_USER: temps | |
| 104 | + # Local-dev credential, same status as the root/root above. Never leaves | |
| 105 | + # the compose network — the port is not published. | |
| 106 | + POSTGRES_PASSWORD: temps_local_dev | |
| 107 | + TIMESCALEDB_TELEMETRY: off | |
| 108 | + volumes: | |
| 109 | + # Spilo/timescaledb-ha initialises its cluster here, not in the stock | |
| 110 | + # postgres image's /var/lib/postgresql/data. Mounting the wrong path | |
| 111 | + # loses everything on every recreation. | |
| 112 | + - temps-postgres-data:/home/postgres/pgdata/data | |
| 113 | + restart: unless-stopped | |
| 114 | + healthcheck: | |
| 115 | + test: | |
| 116 | + [ | |
| 117 | + "CMD-SHELL", | |
| 118 | + "PGPASSWORD=$$POSTGRES_PASSWORD psql -h 127.0.0.1 -U temps -d temps -tAc 'SELECT 1' | grep -qx 1", | |
| 119 | + ] | |
| 120 | + interval: 10s | |
| 121 | + timeout: 5s | |
| 122 | + retries: 12 | |
| 123 | + start_period: 30s | |
| 124 | + | |
| 125 | + temps-clickhouse: | |
| 126 | + image: docker.io/clickhouse/clickhouse-server:26.7.5.10-alpine | |
| 127 | + container_name: hezarfen-temps-clickhouse | |
| 128 | + environment: | |
| 129 | + CLICKHOUSE_DB: temps | |
| 130 | + CLICKHOUSE_USER: temps | |
| 131 | + CLICKHOUSE_PASSWORD: temps_local_dev | |
| 132 | + volumes: | |
| 133 | + - temps-clickhouse-data:/var/lib/clickhouse | |
| 134 | + ulimits: | |
| 135 | + nofile: | |
| 136 | + soft: 262144 | |
| 137 | + hard: 262144 | |
| 138 | + restart: unless-stopped | |
| 139 | + healthcheck: | |
| 140 | + test: ["CMD", "clickhouse-client", "--user", "temps", "--database", "temps", "--query", "SELECT 1"] | |
| 141 | + interval: 10s | |
| 142 | + timeout: 5s | |
| 143 | + retries: 12 | |
| 144 | + start_period: 20s | |
| 145 | + | |
| 146 | + temps: | |
| 147 | + # Built locally from the pinned upstream artifact — see | |
| 148 | + # observability/Containerfile.temps for why the published image can't run. | |
| 149 | + build: | |
| 150 | + context: ./observability | |
| 151 | + dockerfile: Containerfile.temps | |
| 152 | + image: localhost/hezarfen-temps:0.1.0-nightly.20260906.48c2396e | |
| 153 | + container_name: hezarfen-temps | |
| 154 | + environment: | |
| 155 | + TEMPS_DATABASE_URL: postgresql://temps:temps_local_dev@temps-postgres:5432/temps | |
| 156 | + # UI + API on 3000, public ingest (OTLP among it) on 9000. | |
| 157 | + TEMPS_ADDRESS: 0.0.0.0:3000 | |
| 158 | + TEMPS_CONSOLE_ADDRESS: 0.0.0.0:9000 | |
| 159 | + TEMPS_DATA_DIR: /app/data | |
| 160 | + TEMPS_LOG_LEVEL: info | |
| 161 | + TEMPS_CLICKHOUSE_URL: http://temps-clickhouse:8123 | |
| 162 | + TEMPS_CLICKHOUSE_DATABASE: temps | |
| 163 | + TEMPS_CLICKHOUSE_USER: temps | |
| 164 | + TEMPS_CLICKHOUSE_PASSWORD: temps_local_dev | |
| 165 | + # Signal retention. 90 is also Temps' own default (the spans table's | |
| 166 | + # `retention_days` column defaults to 90 and the TTL is derived from it), | |
| 167 | + # set here so the number is in the file rather than only in Temps' own | |
| 168 | + # settings row, which the console can change. | |
| 169 | + TEMPS_OTEL_RETENTION_DAYS: "90" | |
| 170 | + # First-boot admin, created once. The password is mounted from a file so | |
| 171 | + # it stays out of argv; change observability/temps-admin-password before | |
| 172 | + # this is reachable from anywhere but your machine. | |
| 173 | + TEMPS_ADMIN_EMAIL: admin@hezarfen.local | |
| 174 | + TEMPS_ADMIN_PASSWORD_FILE: /run/temps/admin_password | |
| 175 | + TEMPS_EXECUTION_ENV: docker | |
| 176 | + ports: | |
| 177 | + - "127.0.0.1:3000:3000" | |
| 178 | + - "127.0.0.1:9000:9000" | |
| 179 | + volumes: | |
| 180 | + - temps-data:/app/data | |
| 181 | + - ./observability/temps-admin-password:/run/temps/admin_password:ro | |
| 182 | + # Temps refuses to start its console (UI + OTLP ingest) without a | |
| 183 | + # container socket. Podman's API is Docker-compatible; start it with | |
| 184 | + # `systemctl --user start podman.socket`. Running as root inside the | |
| 185 | + # container is what makes the rootless socket readable (container root | |
| 186 | + # maps to your host user) — same reasoning as surrealdb above. | |
| 187 | + - ${XDG_RUNTIME_DIR:-/run/user/1000}/podman/podman.sock:/var/run/docker.sock | |
| 188 | + user: "0" | |
| 189 | + # SELinux blocks reading the podman socket from inside the container | |
| 190 | + # ("Permission denied", which Temps reports as "Socket not found"). | |
| 191 | + # Relabelling the socket itself would break podman, so the label is | |
| 192 | + # dropped for this container only. | |
| 193 | + security_opt: | |
| 194 | + - label=disable | |
| 195 | + depends_on: | |
| 196 | + temps-postgres: | |
| 197 | + condition: service_healthy | |
| 198 | + temps-clickhouse: | |
| 199 | + condition: service_healthy | |
| 200 | + restart: unless-stopped | |
| 201 | + healthcheck: | |
| 202 | + test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:9000/readyz"] | |
| 203 | + interval: 30s | |
| 204 | + timeout: 5s | |
| 205 | + retries: 3 | |
| 206 | + start_period: 40s | |
| 207 | + | |
| 83 | 208 | volumes: |
| 84 | 209 | hezarfen-data: |
| 85 | 210 | surreal-data: |
| 211 | + temps-postgres-data: | |
| 212 | + temps-clickhouse-data: | |
| 213 | + temps-data: |
observability/Containerfile.tempsadded+20 -0
| @@ -0,0 +1,20 @@ | ||
| 1 | +# Temps ships a broken runtime image: ghcr.io/gotempsh/temps:* is alpine/musl | |
| 2 | +# but the binary inside is glibc-linked, so it dies with "exec container | |
| 3 | +# process (missing dynamic library?) /usr/local/bin/temps". Their supported | |
| 4 | +# path is building the whole thing from source. Rebasing the same pinned | |
| 5 | +# artifact onto debian-slim gives a runnable image in seconds instead. | |
| 6 | +# Delete this file and use the upstream image directly once it executes. | |
| 7 | +FROM ghcr.io/gotempsh/temps:0.1.0-nightly.20260906.48c2396e AS artifacts | |
| 8 | + | |
| 9 | +FROM docker.io/library/debian:bookworm-slim | |
| 10 | +RUN apt-get update \ | |
| 11 | + && apt-get install -y --no-install-recommends ca-certificates tzdata wget \ | |
| 12 | + && rm -rf /var/lib/apt/lists/* | |
| 13 | +COPY --from=artifacts /usr/local/bin/temps /usr/local/bin/temps | |
| 14 | +RUN useradd --uid 1000 --create-home temps \ | |
| 15 | + && mkdir -p /app/data \ | |
| 16 | + && chown -R temps:temps /app | |
| 17 | +USER temps | |
| 18 | +WORKDIR /app | |
| 19 | +ENTRYPOINT ["/usr/local/bin/temps"] | |
| 20 | +CMD ["serve"] |
observability/temps-admin-passwordadded+1 -0
| @@ -0,0 +1 @@ | ||
| 1 | +Temps-Local-Dev-1 |