@zigordev/stack 1.10.1 → 1.11.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 +15 -0
- package/compose.local.yaml +1 -0
- package/compose.yaml +37 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -147,6 +147,21 @@ Traefik takes all its settings from variables, so its own health check reads the
|
|
|
147
147
|
|
|
148
148
|
Traefik warns once at each start that it "can reject some encoded characters in the request path". That is a notice about a setting we leave as it is.
|
|
149
149
|
|
|
150
|
+
### Browser monitoring
|
|
151
|
+
|
|
152
|
+
A web app's pages send what Grafana Faro measures in the browser, through toolkit's `@zigordev/rum`, to the path `/rum` on the app's own address. So the page's content security policy needs no other origin, as toolkit's record 0055 says. The shared services take that path on every address, the laptop's and production's, without a line per product:
|
|
153
|
+
|
|
154
|
+
| Part | What it does |
|
|
155
|
+
| ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
156
|
+
| Traefik's route `rum` | Takes ``Path(`/rum`)`` on every address, with priority 1000, ahead of every product's own route |
|
|
157
|
+
| The middleware `rum-limit` | Lets each visitor send 10 requests a second, with a burst of 50. In production it tells visitors apart by `CF-Connecting-IP`, which Cloudflare sets. On the laptop that header is missing, so every request shares one limit |
|
|
158
|
+
| The middleware `rum-path` | Hands the request to the path `/collect`, where the receiver listens |
|
|
159
|
+
| Alloy's `faro.receiver "browsers"` | Listens on port 12347, takes at most 1 MiB a request, and limits each app to 50 requests a second, with bursts of up to 100. It never downloads a source map from an address that a page sends, so nobody can make the agent fetch a URL |
|
|
160
|
+
|
|
161
|
+
The receiver sends the browser's lines to Loki and its traces to the same destination as the apps' own traces. Each line carries the labels `source="browser"`, `app_name`, such as `playground-web`, and `kind`: `log`, `exception`, `measurement` or `event`. So `{source="browser", app_name="playground-web"}` in Grafana's Explore shows one app's browser lines, apart from its server's. Its traces carry the app's name as their service, and continue in the API through the `traceparent` header.
|
|
162
|
+
|
|
163
|
+
Nothing personal leaves the browser: `@zigordev/rum` drops queries, users and console lines before it sends, as its README says. A product turns browser monitoring on by setting `RUM_URL` to `/rum` in its compose files, and the template does that once this route is in production.
|
|
164
|
+
|
|
150
165
|
### The broker
|
|
151
166
|
|
|
152
167
|
Kafka carries the events that one service sends to another. It is one node, broker and controller at once, so it keeps one copy of each message. Its data sits in the volume `kafka-data`, which in production is on the data disk, inside the disk's daily snapshot.
|
package/compose.local.yaml
CHANGED
package/compose.yaml
CHANGED
|
@@ -187,6 +187,32 @@ services:
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
faro.receiver "browsers" {
|
|
191
|
+
extra_log_labels = { source = "browser", app_name = "", kind = "" }
|
|
192
|
+
|
|
193
|
+
server {
|
|
194
|
+
listen_address = "0.0.0.0"
|
|
195
|
+
listen_port = 12347
|
|
196
|
+
max_allowed_payload_size = "1MiB"
|
|
197
|
+
|
|
198
|
+
rate_limiting {
|
|
199
|
+
enabled = true
|
|
200
|
+
strategy = "per_app"
|
|
201
|
+
rate = 50
|
|
202
|
+
burst_size = 100
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
sourcemaps {
|
|
207
|
+
download = false
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
output {
|
|
211
|
+
logs = [loki.write.destination.receiver]
|
|
212
|
+
traces = [otelcol.processor.batch.apps.input]
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
190
216
|
prometheus.exporter.self "alloy" { }
|
|
191
217
|
|
|
192
218
|
prometheus.exporter.unix "host" {
|
|
@@ -272,6 +298,17 @@ services:
|
|
|
272
298
|
interval: 5s
|
|
273
299
|
timeout: 3s
|
|
274
300
|
retries: 12
|
|
301
|
+
labels:
|
|
302
|
+
traefik.enable: "true"
|
|
303
|
+
traefik.http.routers.rum.rule: Path(`/rum`)
|
|
304
|
+
traefik.http.routers.rum.priority: "1000"
|
|
305
|
+
traefik.http.routers.rum.service: rum
|
|
306
|
+
traefik.http.routers.rum.middlewares: rum-limit,rum-path
|
|
307
|
+
traefik.http.middlewares.rum-limit.ratelimit.average: "10"
|
|
308
|
+
traefik.http.middlewares.rum-limit.ratelimit.burst: "50"
|
|
309
|
+
traefik.http.middlewares.rum-limit.ratelimit.sourcecriterion.requestheadername: CF-Connecting-IP
|
|
310
|
+
traefik.http.middlewares.rum-path.replacepath.path: /collect
|
|
311
|
+
traefik.http.services.rum.loadbalancer.server.port: "12347"
|
|
275
312
|
depends_on:
|
|
276
313
|
docker-proxy:
|
|
277
314
|
condition: service_healthy
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zigordev/stack",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "The shared services of the zigordev platform for a laptop: the ingress, the telemetry agent, a local Grafana and a mail catcher, as compose files with one command that starts them",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|