Skip to content

Commit bc6621e

Browse files
committed
docs: clarify identity file usage and Docker persistence
- Fix incorrect filename (metrics_identity.json -> shm_identity.json) - Add identity file structure documentation - Add Docker/Kubernetes volume mount instructions - Explain 401 error when identity is lost Fixes #3
1 parent 998253d commit bc6621e

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,36 @@ graph LR
350350
D[Admin Dashboard] -- Read API --> B
351351
```
352352

353-
1. **Client:** Generates Ed25519 keys on first run. Stores identity in `metrics_identity.json`.
353+
1. **Client:** Generates Ed25519 keys on first run. Stores identity in `shm_identity.json`.
354354
2. **Protocol:** Sends a Heartbeat/Snapshot signed with the private key.
355355
3. **Storage:** PostgreSQL stores the raw JSON payload in a `jsonb` column.
356356
4. **UI:** The server parses the JSON keys dynamically to build the table and graphs.
357357

358+
### Identity File
359+
360+
The SDK automatically generates `shm_identity.json` on first run. This file contains:
361+
362+
```json
363+
{
364+
"instance_id": "550e8400-e29b-41d4-a716-446655440000",
365+
"private_key": "hex-encoded-ed25519-private-key",
366+
"public_key": "hex-encoded-ed25519-public-key"
367+
}
368+
```
369+
370+
**Important for Docker/Kubernetes:** The identity file must be persisted across container restarts. Mount a volume for the `DataDir` (Go) or `dataDir` (Node.js) configuration:
371+
372+
```yaml
373+
services:
374+
my-app:
375+
volumes:
376+
- ./data:/app/data # Persist identity file
377+
environment:
378+
- SHM_DATA_DIR=/app/data
379+
```
380+
381+
If the identity file is lost, the instance will generate a new identity and the server will return **401 Unauthorized** for requests signed with the old key.
382+
358383
---
359384
360385
## 🛡️ Security & Privacy

sdk/golang/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ client, _ := shm.New(shm.Config{
9898

9999
4. **Periodic Snapshots**: System metrics + custom metrics are sent at the configured interval
100100

101+
> **Docker/Kubernetes:** The identity file must persist across restarts. Mount a volume for `DataDir`, otherwise a new identity will be generated and the server will reject requests with **401 Unauthorized**.
102+
101103
## System Metrics
102104

103105
The SDK automatically collects:

sdk/nodejs/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ const client = new SHMClient({
8787

8888
4. **Periodic Snapshots**: System metrics + custom metrics are sent at the configured interval
8989

90+
> **Docker/Kubernetes:** The identity file must persist across restarts. Mount a volume for `dataDir`, otherwise a new identity will be generated and the server will reject requests with **401 Unauthorized**.
91+
9092
## System Metrics
9193

9294
The SDK automatically collects:

0 commit comments

Comments
 (0)