@primafuture/telemetry-stack 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,235 @@
1
+ # @primafuture/telemetry-stack
2
+
3
+ Reusable telemetry stack.
4
+
5
+ This package does not contain Grafana, Loki, Tempo, Mimir, MinIO, Redpanda, Alloy, or Prometheus binaries. It contains a Docker Compose recipe and a small CLI that starts those Docker images for you.
6
+
7
+ ## Requirements
8
+
9
+ - Node.js 18+
10
+ - Docker
11
+ - Docker Compose plugin
12
+
13
+ ## Quick Start
14
+
15
+ Run a development telemetry stack and store its data in `./data/telemetry`:
16
+
17
+ ```bash
18
+ npx @primafuture/telemetry-stack up ./data/telemetry
19
+ ```
20
+
21
+ Open Grafana:
22
+
23
+ ```bash
24
+ npx @primafuture/telemetry-stack open ./data/telemetry grafana
25
+ ```
26
+
27
+ Stop the stack:
28
+
29
+ ```bash
30
+ npx @primafuture/telemetry-stack down ./data/telemetry
31
+ ```
32
+
33
+ ## Local Development
34
+
35
+ From this package directory:
36
+
37
+ ```bash
38
+ node bin/telemetry-stack.mjs doctor
39
+ node bin/telemetry-stack.mjs config /tmp/telemetry-stack-test
40
+ node bin/telemetry-stack.mjs up /tmp/telemetry-stack-test
41
+ ```
42
+
43
+ ## Commands
44
+
45
+ ```bash
46
+ telemetry-stack init <data-dir> [options]
47
+ telemetry-stack up <data-dir> [options]
48
+ telemetry-stack down <data-dir> [options]
49
+ telemetry-stack restart <data-dir> [options]
50
+ telemetry-stack ps <data-dir> [options]
51
+ telemetry-stack logs <data-dir> [service] [options]
52
+ telemetry-stack open <data-dir> [target] [options]
53
+ telemetry-stack config <data-dir> [options]
54
+ telemetry-stack doctor
55
+ ```
56
+
57
+ `<data-dir>` is where the stack stores runtime data and the instance config. Use a different directory for a different instance.
58
+
59
+ Common options:
60
+
61
+ ```text
62
+ --name <name> Override Docker Compose project name.
63
+ --mode <dev|prod> Instance mode for newly created config. Default: dev.
64
+ ```
65
+
66
+ Port options:
67
+
68
+ ```text
69
+ --grafana-port <port> Default: 3000
70
+ --otlp-grpc-port <port> Default: 4317
71
+ --otlp-http-port <port> Default: 4318
72
+ --tempo-port <port> Default: 3200
73
+ --loki-port <port> Default: 3100
74
+ --prometheus-port <port> Default: 9090
75
+ --mimir-port <port> Default: 9009
76
+ --minio-console-port <port> Default: 9001
77
+ --redpanda-port <port> Default: 9092
78
+ --redpanda-console-port <port> Default: 8080
79
+ --alloy-port <port> Default: 12345
80
+ ```
81
+
82
+ Logs options:
83
+
84
+ ```text
85
+ --follow, -f Follow log output. Only for logs.
86
+ --tail <lines> Number of log lines to show. Only for logs.
87
+ ```
88
+
89
+ ## Modes
90
+
91
+ The stack has two modes:
92
+
93
+ - `dev`: default mode. Uses simple non-secure credentials, enables anonymous Grafana Admin, and binds public ports to `0.0.0.0`.
94
+ - `prod`: single-node production-oriented mode. Generates random credentials, disables anonymous Grafana, enables the login form, and binds public ports to `127.0.0.1`.
95
+
96
+ Create an instance config without starting containers:
97
+
98
+ ```bash
99
+ telemetry-stack init ./data/telemetry --mode prod
100
+ ```
101
+
102
+ The instance config is stored here:
103
+
104
+ ```text
105
+ <data-dir>/telemetry-stack.env
106
+ ```
107
+
108
+ Generated service configs are stored here:
109
+
110
+ ```text
111
+ <data-dir>/generated-configs/
112
+ ```
113
+
114
+ For `prod`, find the Grafana admin user and password in `telemetry-stack.env`. The generated configs can also contain credentials, so do not commit the data directory. The `prod` mode is still single-node and not high availability. Put a reverse proxy, SSH tunnel, or private network in front of it if it needs remote access.
115
+
116
+ ## Multiple Instances
117
+
118
+ The simplest command uses default ports:
119
+
120
+ ```bash
121
+ telemetry-stack up ./data/telemetry
122
+ ```
123
+
124
+ If another stack already uses those ports, override them:
125
+
126
+ ```bash
127
+ telemetry-stack up ./data/telemetry-project-b \
128
+ --grafana-port 3300 \
129
+ --otlp-grpc-port 14317 \
130
+ --otlp-http-port 14318 \
131
+ --tempo-port 13200 \
132
+ --loki-port 13100 \
133
+ --prometheus-port 19090 \
134
+ --mimir-port 19009 \
135
+ --minio-console-port 19001 \
136
+ --redpanda-port 19092 \
137
+ --redpanda-console-port 18080 \
138
+ --alloy-port 22345
139
+ ```
140
+
141
+ Project name is derived automatically from the absolute data directory. If you need a specific Docker Compose project name:
142
+
143
+ ```bash
144
+ telemetry-stack up ./data/telemetry --name my-telemetry
145
+ ```
146
+
147
+ ## Logs
148
+
149
+ Follow all stack logs:
150
+
151
+ ```bash
152
+ telemetry-stack logs ./data/telemetry --follow --tail 100
153
+ ```
154
+
155
+ Follow one service:
156
+
157
+ ```bash
158
+ telemetry-stack logs ./data/telemetry alloy --follow --tail 100
159
+ ```
160
+
161
+ Useful service names:
162
+
163
+ ```text
164
+ alloy
165
+ tempo
166
+ loki
167
+ prometheus
168
+ mimir
169
+ grafana
170
+ minio
171
+ redpanda
172
+ redpanda-console
173
+ ```
174
+
175
+ ## Smoke Test
176
+
177
+ The stack no longer generates fake telemetry by default. To test the log path, send one OTLP HTTP log record to Alloy:
178
+
179
+ ```bash
180
+ TS="$(date +%s%N)"
181
+
182
+ curl -sS -X POST http://localhost:4318/v1/logs \
183
+ -H 'Content-Type: application/json' \
184
+ -d "{
185
+ \"resourceLogs\": [{
186
+ \"resource\": {
187
+ \"attributes\": [{
188
+ \"key\": \"service.name\",
189
+ \"value\": {\"stringValue\": \"telemetry-smoke-test\"}
190
+ }]
191
+ },
192
+ \"scopeLogs\": [{
193
+ \"scope\": {\"name\": \"manual-curl\"},
194
+ \"logRecords\": [{
195
+ \"timeUnixNano\": \"${TS}\",
196
+ \"severityText\": \"INFO\",
197
+ \"body\": {\"stringValue\": \"hello from telemetry-stack smoke test\"},
198
+ \"attributes\": [{
199
+ \"key\": \"log_type\",
200
+ \"value\": {\"stringValue\": \"smoke_test\"}
201
+ }]
202
+ }]
203
+ }]
204
+ }]
205
+ }"
206
+ ```
207
+
208
+ Query it from Loki:
209
+
210
+ ```bash
211
+ curl -G 'http://localhost:3100/loki/api/v1/query' \
212
+ --data-urlencode 'query={service_name="telemetry-smoke-test"}'
213
+ ```
214
+
215
+ ## Useful URLs
216
+
217
+ Default ports:
218
+
219
+ - Grafana: `http://localhost:3000`
220
+ - Tempo: `http://localhost:3200`
221
+ - Loki: `http://localhost:3100`
222
+ - Prometheus: `http://localhost:9090`
223
+ - Mimir: `http://localhost:9009`
224
+ - MinIO Console: `http://localhost:9001`
225
+ - Redpanda Console: `http://localhost:8080`
226
+ - OTLP gRPC: `localhost:4317`
227
+ - OTLP HTTP: `http://localhost:4318`
228
+
229
+ ## Notes
230
+
231
+ - `dev` is for local development and demos.
232
+ - `prod` is a safer single-node mode, not a full HA observability platform.
233
+ - Grafana runs with anonymous Admin access only in `dev` mode by default.
234
+ - Grafana runtime data is stored under `<data-dir>/grafana`.
235
+ - Docker images are pinned by digest in `stack/docker-compose.yaml`.