@zigordev/stack 1.3.1 → 1.5.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 +121 -74
- package/compose.local.yaml +17 -0
- package/compose.yaml +165 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +7 -1
- package/dist/cli.js.map +1 -1
- package/observability/alert-kafka-broker-is-down.json +60 -0
- package/observability/alert-message-reached-dead-letter-topic.json +60 -0
- package/observability/alert-messages-are-stuck.json +60 -0
- package/observability/dashboard-app.json +99 -0
- package/observability/dashboard-platform.json +56 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
# @zigordev/stack
|
|
2
2
|
|
|
3
|
-
The shared services of the zigordev platform for a laptop: the ingress, the telemetry agent, a local Grafana and a mail catcher. They are two compose files, the standard dashboards and alert rules, and one command that starts it all.
|
|
3
|
+
The shared services of the zigordev platform for a laptop: the ingress, the telemetry agent, the Kafka broker, a local Grafana and a mail catcher. They are two compose files, the standard dashboards and alert rules, and one command that starts it all.
|
|
4
4
|
|
|
5
5
|
## What it is
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
| Service | Image | What it does
|
|
10
|
-
| -------------- | ---------------------------- |
|
|
11
|
-
| `traefik` | Traefik 3.7 | The ingress. It sends each address to its container, from the labels that the container carries
|
|
12
|
-
| `docker-proxy` | wollomatic/socket-proxy 1.14 | A filtered door to Docker. It lets the ingress and the agent read which containers exist, and nothing else
|
|
13
|
-
| `alloy` | Grafana Alloy 1.22 | The telemetry agent. It receives traces and metrics from every app, reads every container's log lines and the machine's own numbers, and forwards all of it
|
|
14
|
-
| `
|
|
15
|
-
| `
|
|
16
|
-
| `
|
|
17
|
-
|
|
18
|
-
|
|
|
19
|
-
|
|
20
|
-
|
|
|
21
|
-
|
|
|
22
|
-
| `
|
|
23
|
-
| `
|
|
7
|
+
Six containers that every product on the laptop shares. Four of them run in production too, from the same file.
|
|
8
|
+
|
|
9
|
+
| Service | Image | What it does | Runs |
|
|
10
|
+
| -------------- | ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- |
|
|
11
|
+
| `traefik` | Traefik 3.7 | The ingress. It sends each address to its container, from the labels that the container carries | Everywhere |
|
|
12
|
+
| `docker-proxy` | wollomatic/socket-proxy 1.14 | A filtered door to Docker. It lets the ingress and the agent read which containers exist, and nothing else | Everywhere |
|
|
13
|
+
| `alloy` | Grafana Alloy 1.22 | The telemetry agent. It receives traces and metrics from every app, reads every container's log lines and the machine's own numbers, and forwards all of it | Everywhere |
|
|
14
|
+
| `kafka` | Apache Kafka 4.4 | The broker for events between services: one node that is broker and controller at once. Every client signs in with SCRAM-SHA-512 as a user of its own, and may do only what a rule allows | Everywhere |
|
|
15
|
+
| `kafka-setup` | Apache Kafka 4.4 | Not a service but a job: it adds Kafka's topics, users and rules from the list `KAFKA_SETUP`, and ends. It never deletes anything | Everywhere, after the broker is healthy |
|
|
16
|
+
| `lgtm` | grafana/otel-lgtm 0.41 | The local Grafana, with its stores for logs, traces and metrics in the same container | Laptop only |
|
|
17
|
+
| `mailpit` | Mailpit 1.34 | The mail catcher. It receives every email an app sends on the laptop, and shows it on a page | Laptop only |
|
|
18
|
+
| `gcx` | Grafana gcx 1.8 | Not a service but a job: it pushes the dashboards and the alert rules to the local Grafana, and ends | Laptop only, on each `up` |
|
|
19
|
+
|
|
20
|
+
| File | What it holds |
|
|
21
|
+
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
|
22
|
+
| `compose.yaml` | The four services that run everywhere, with the agent's config inside, and Kafka's job with its list of topics, users and rules |
|
|
23
|
+
| `compose.local.yaml` | What only the laptop has: the two other services, the local addresses, the published ports, the settings and Kafka's throwaway passwords |
|
|
24
|
+
| `observability/` | The dashboards and the alert rules as files, which `pnpm build` writes from the code in the repo's `observability/` folder |
|
|
25
|
+
| `bin/` and `src/` | The command `zigordev-stack`, which starts and stops them |
|
|
24
26
|
|
|
25
27
|
```mermaid
|
|
26
28
|
flowchart LR
|
|
@@ -30,6 +32,7 @@ flowchart LR
|
|
|
30
32
|
traefik --> mailpit
|
|
31
33
|
app -->|traces and metrics| alloy
|
|
32
34
|
app -->|email| mailpit
|
|
35
|
+
app -->|events, signed in| kafka
|
|
33
36
|
alloy -->|logs, traces, metrics| lgtm
|
|
34
37
|
traefik -.->|which containers exist| proxy["docker-proxy"]
|
|
35
38
|
alloy -.->|which containers exist, and their log lines| proxy
|
|
@@ -40,7 +43,7 @@ flowchart LR
|
|
|
40
43
|
|
|
41
44
|
Every product needs an ingress, somewhere to send its telemetry and somewhere to send its mail. Without this package each product would bring its own, and two products could not run side by side on one laptop: both would want port 80, and their logs would land in two places.
|
|
42
45
|
|
|
43
|
-
Because the same
|
|
46
|
+
Because the same four services run in production from the same file, a route or a log line that works on the laptop works there too. What differs is a short list of settings, and it is written down below.
|
|
44
47
|
|
|
45
48
|
Without the Docker proxy, the ingress and the agent would hold Docker's socket itself, which is the right to start any container with any privilege. A flaw in either would then be a flaw in the whole machine.
|
|
46
49
|
|
|
@@ -48,13 +51,15 @@ Without the Docker proxy, the ingress and the agent would hold Docker's socket i
|
|
|
48
51
|
|
|
49
52
|
### One project, one network, fixed names
|
|
50
53
|
|
|
51
|
-
The
|
|
54
|
+
The six containers form one Compose project named `platform`, whichever folder the files are started from. A product starts the same project from its own copy of this package, so a second start changes nothing, and two products share one set of services.
|
|
52
55
|
|
|
53
56
|
| Name | What it is |
|
|
54
57
|
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
55
58
|
| `zigordev` | The network that every app joins. On it, the services answer to their own names |
|
|
56
59
|
| `alloy:4318` | Where an app sends its traces and metrics, over OTLP on HTTP. Port 4317 takes the same over gRPC |
|
|
57
60
|
| `127.0.0.1:4318` | The same port, published on the laptop itself, for an app that runs as a process outside a container, such as one started with `pnpm dev`. HTTP only |
|
|
61
|
+
| `kafka:9092` | Where an app in a container reaches Kafka, signed in with SCRAM-SHA-512 as its own user |
|
|
62
|
+
| `localhost:9094` | The same broker, published on the laptop itself, for an app that runs as a process outside a container |
|
|
58
63
|
| `mailpit:1025` | Where an app sends its mail on the laptop, over SMTP |
|
|
59
64
|
| `zigordev-docker` | A second network with no way out. Only the Docker proxy, the ingress and the agent are on it |
|
|
60
65
|
|
|
@@ -80,43 +85,47 @@ The agent reads the log lines of every container on the two networks, through th
|
|
|
80
85
|
| ---------------------------------------------------------------- | -------------------------------------------------------------- | ---------------------------------------------------------------------- |
|
|
81
86
|
| Its own heartbeat, under the name `alloy` | Itself | One series. An alert fires when it has been missing for 10 minutes |
|
|
82
87
|
| The machine's processor, memory and disks, under the name `host` | Three read-only mounts of the machine: `/proc`, `/sys` and `/` | Only the series that a dashboard or an alert uses, and only real disks |
|
|
88
|
+
| Whether the Kafka broker answers, under the name `kafka` | A connection to `kafka:9092` once a minute, with no sign-in | One series. An alert fires when it has failed for 5 minutes |
|
|
83
89
|
|
|
84
90
|
The three mounts let the agent read the machine's numbers. It runs as a user that is not root, so it reads only what every user of the machine may read. On the laptop "the machine" is the small Linux machine inside Docker Desktop.
|
|
85
91
|
|
|
92
|
+
The check of the broker only opens a connection. Alloy's own Kafka exporter would sign in at the agent's start, and on 2026-11-25 it stopped the whole agent whenever Kafka was down then, so it is not used. How far behind a consumer is, and the messages it set aside, come from each app's own numbers instead, which `@zigordev/events` reports.
|
|
93
|
+
|
|
86
94
|
### Dashboards and alert rules
|
|
87
95
|
|
|
88
|
-
`zigordev-stack up` ends by pushing
|
|
96
|
+
`zigordev-stack up` ends by pushing twelve files to the local Grafana, with gcx: one folder, two dashboards and nine alert rules. A second push changes nothing.
|
|
89
97
|
|
|
90
|
-
| In Grafana | What it shows
|
|
91
|
-
| --------------------------------------- |
|
|
92
|
-
| Dashboards, folder `zigordev`, App | One app, picked from a list: whether it reports, its version, its requests, the share that fail, its response times, its events and its
|
|
93
|
-
| Dashboards, folder `zigordev`, Platform | The machine's processor, memory and disks, the requests at the ingress, who is reporting,
|
|
94
|
-
| Alerting,
|
|
98
|
+
| In Grafana | What it shows |
|
|
99
|
+
| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
100
|
+
| Dashboards, folder `zigordev`, App | One app, picked from a list: whether it reports, its version, its requests, the share that fail, its response times, its events, its errors, and its messages waiting and set aside |
|
|
101
|
+
| Dashboards, folder `zigordev`, Platform | The machine's processor, memory and disks, the requests at the ingress, who is reporting, how old each product's newest dump and last good restore test are, and whether the Kafka broker answers |
|
|
102
|
+
| Alerting, nine rules | [The runbooks](../docs/runbooks/README.md) list them. On the laptop they show in Grafana and notify nobody |
|
|
95
103
|
|
|
96
104
|
A new app needs no entry anywhere. It appears in the list of the App dashboard with its first request, and every rule covers it.
|
|
97
105
|
|
|
98
106
|
### Each container is boxed in
|
|
99
107
|
|
|
100
|
-
| Rule
|
|
101
|
-
|
|
|
102
|
-
| An exact image version and its digest
|
|
103
|
-
| A health check
|
|
104
|
-
| A restart unless it was stopped
|
|
105
|
-
| A memory limit and a CPU limit
|
|
106
|
-
| An init process, no new privileges, no capabilities, at most 30 seconds to stop
|
|
107
|
-
| A user that is not root, and a read-only file system
|
|
108
|
-
| No published port, except port 80 of the ingress and port
|
|
109
|
-
|
|
110
|
-
`src/compose.test.ts` holds every service to these rules, one by one, and the
|
|
111
|
-
|
|
112
|
-
| Service | Memory limit | CPU limit | Used when idle on 2026-11-22
|
|
113
|
-
| -------------- | ------------ | --------- |
|
|
114
|
-
| `traefik` | 128 MiB | 1 | 24 MiB
|
|
115
|
-
| `docker-proxy` | 64 MiB | 0.25 | 11 MiB
|
|
116
|
-
| `alloy` | 256 MiB | 1 | 51 MiB
|
|
117
|
-
| `lgtm` | 2 GiB | 2 | 614 MiB
|
|
118
|
-
| `mailpit` | 128 MiB | 0.5 | 10 MiB
|
|
119
|
-
| `
|
|
108
|
+
| Rule | Why |
|
|
109
|
+
| ------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
|
|
110
|
+
| An exact image version and its digest | The same bytes everywhere, and a tag pushed again changes nothing. Renovate proposes the next |
|
|
111
|
+
| A health check | `up` can wait for it, and the ingress can trust it |
|
|
112
|
+
| A restart unless it was stopped | The host restarts at night for updates, and every service comes back by itself |
|
|
113
|
+
| A memory limit and a CPU limit | One service cannot starve the others |
|
|
114
|
+
| An init process, no new privileges, no capabilities, at most 30 seconds to stop | A broken service stays inside its box and stops cleanly |
|
|
115
|
+
| A user that is not root, and a read-only file system | A flaw in the service cannot change the service |
|
|
116
|
+
| No published port, except port 80 of the ingress, port 4318 of the agent and port 9094 of the broker, all on this laptop itself | Nothing is reachable from the network the laptop is on |
|
|
117
|
+
|
|
118
|
+
`src/compose.test.ts` holds every service to these rules, one by one, and the jobs `gcx` and `kafka-setup` to all but the health check, which a job that ends does not need. The broker keeps a read-only root by writing only to its data volume and to two folders in memory: the settings its image writes at each start, and `/tmp`. `lgtm` is the one exception to the last-but-one row: it is six programs in one container, which start as root and write to their own folders. It runs on the laptop only.
|
|
119
|
+
|
|
120
|
+
| Service | Memory limit | CPU limit | Used when idle on 2026-11-22 |
|
|
121
|
+
| -------------- | ------------ | --------- | ------------------------------------------ |
|
|
122
|
+
| `traefik` | 128 MiB | 1 | 24 MiB |
|
|
123
|
+
| `docker-proxy` | 64 MiB | 0.25 | 11 MiB |
|
|
124
|
+
| `alloy` | 256 MiB | 1 | 51 MiB |
|
|
125
|
+
| `lgtm` | 2 GiB | 2 | 614 MiB |
|
|
126
|
+
| `mailpit` | 128 MiB | 0.5 | 10 MiB |
|
|
127
|
+
| `kafka` | 1 GiB | 1 | 397 MiB on 2026-11-25, with a 512 MiB heap |
|
|
128
|
+
| `cloudflared` | 128 MiB | 0.5 | Not measured yet, production only |
|
|
120
129
|
|
|
121
130
|
### The Docker proxy
|
|
122
131
|
|
|
@@ -134,21 +143,57 @@ Traefik takes all its settings from variables, so its own health check reads the
|
|
|
134
143
|
|
|
135
144
|
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.
|
|
136
145
|
|
|
146
|
+
### The broker
|
|
147
|
+
|
|
148
|
+
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.
|
|
149
|
+
|
|
150
|
+
Every client signs in with SCRAM-SHA-512 as a user of its own, and may do only what a rule allows. A user without a rule can do nothing, and writing to a topic never makes it. So a typo in a topic's name fails at once, instead of making a second topic.
|
|
151
|
+
|
|
152
|
+
The list `KAFKA_SETUP`, in the settings of the job `kafka-setup` in `compose.yaml`, holds every topic, user and rule, one per line. The job runs once the broker is healthy, signs in as the user `setup`, adds what is missing, and ends. It never deletes: a line that goes leaves its topic, user or rule on the broker, because a topic holds data.
|
|
153
|
+
|
|
154
|
+
| Line | What it adds |
|
|
155
|
+
| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
156
|
+
| `topic <name> <partitions>` | A topic with that many partitions, and one copy of each message |
|
|
157
|
+
| `user <name>` | A user. Its password comes from the job's variable `KAFKA_PASSWORD_<NAME>`, the name in capitals with `-` as `_`, and the job stops when it is not set |
|
|
158
|
+
| `allow <user> <operation> topic <name>` | A rule: the user may do the operation, such as `Read`, `Write` or `Describe`, on that topic |
|
|
159
|
+
| `allow <user> <operation> group <name>` | The same for a consumer group, which a reader needs too |
|
|
160
|
+
| Either `allow` line, ending `prefixed` | The rule covers every name that starts with `<name>` |
|
|
161
|
+
|
|
162
|
+
For example, an app `notes-api` that sends to `notes.requests`, reads it in the group `notes-api.counts`, and sets failed messages aside, as `@zigordev/events` does, needs these lines:
|
|
163
|
+
|
|
164
|
+
```yaml
|
|
165
|
+
KAFKA_SETUP: |
|
|
166
|
+
topic notes.requests 3
|
|
167
|
+
topic notes.requests.dead-letter 1
|
|
168
|
+
user notes-api
|
|
169
|
+
allow notes-api Write topic notes.requests
|
|
170
|
+
allow notes-api Read topic notes.requests
|
|
171
|
+
allow notes-api Write topic notes.requests.dead-letter
|
|
172
|
+
allow notes-api Read group notes-api. prefixed
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
On the laptop the job also needs `KAFKA_PASSWORD_NOTES_API`, a throwaway password in `compose.local.yaml`. The app reaches the broker with three settings, which `@zigordev/events` reads: `KAFKA_BROKERS: kafka:9092`, `KAFKA_USERNAME: notes-api` and `KAFKA_PASSWORD`, the same password. Where an app's password lives in production is decided with the first app that needs one.
|
|
176
|
+
|
|
177
|
+
The broker formats its own storage before the image starts it, and makes the users `admin` and `setup` there, because image 4.4.0 ignores the setting that would do that. [Record 0027](../docs/adr/0027-the-broker-formats-its-own-storage-and-one-list-holds-its-topics-users-and-rules.md) says why.
|
|
178
|
+
|
|
137
179
|
### The laptop and production
|
|
138
180
|
|
|
139
181
|
The host starts `compose.yaml` with `compose.production.yaml`, through the deploy path of platform: every merge to `main` deploys them as the target `platform`. `docs/cloud-first-deploy.md` in platform says how.
|
|
140
182
|
|
|
141
|
-
| Thing
|
|
142
|
-
|
|
|
143
|
-
| The
|
|
144
|
-
| How a request arrives
|
|
145
|
-
| How an app outside a container reports
|
|
146
|
-
|
|
|
147
|
-
|
|
|
148
|
-
|
|
|
149
|
-
|
|
|
150
|
-
|
|
|
151
|
-
| The
|
|
183
|
+
| Thing | On the laptop | In production |
|
|
184
|
+
| -------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
185
|
+
| The four shared services | From `compose.yaml` | The same file |
|
|
186
|
+
| How a request arrives | Port 80 on the laptop itself, over IPv4 and IPv6 | Through Cloudflare's tunnel. `cloudflared`, its connector, runs in production only and hands each request to the ingress |
|
|
187
|
+
| How an app outside a container reports | To `127.0.0.1:4318`, the agent's port published on the laptop itself | Every app runs in a container, so the port is not published |
|
|
188
|
+
| How an app outside a container reaches Kafka | `localhost:9094`, a listener published on the laptop itself | Every app runs in a container, so there is no such listener |
|
|
189
|
+
| Kafka's passwords | Throwaway ones in `compose.local.yaml` | The host's secrets `KAFKA_ADMIN_PASSWORD` and `KAFKA_SETUP_PASSWORD`, which `.env.production.example` names |
|
|
190
|
+
| Kafka's topics, users and rules | `zigordev-stack up` runs the job `kafka-setup` after the health checks | The deploy runs the job after the broker is healthy, as it runs a product's migrate job |
|
|
191
|
+
| Where the agent sends | To `lgtm`, with a made-up name and password that nothing checks | To Grafana Cloud, with the secrets that `.env.production.example` names. Traces and metrics go to `${GRAFANA_OTLP_URL}/otlp`, and logs to `${GRAFANA_LOKI_URL}/loki/api/v1/push`, because the stored addresses carry no path |
|
|
192
|
+
| Each container's memory | No file, so the agent reads none | The host's file `/var/lib/platform/metrics/containers.prom`, which a timer writes every minute |
|
|
193
|
+
| The backups' results | No file, so the agent reads none | The host's files `/var/lib/platform/metrics/backup-dump.prom` and `backup-restore-test.prom`, which the backup script writes after each run |
|
|
194
|
+
| Grafana and the mail catcher | `lgtm` and `mailpit` | Grafana Cloud and Amazon SES |
|
|
195
|
+
| The ingress's own pages | At `traefik.localhost` | Off |
|
|
196
|
+
| The proxy's group | 0, which owns the socket on Docker Desktop | The group that owns the socket on the host, which the deploy passes as `DOCKER_SOCKET_GROUP` |
|
|
152
197
|
|
|
153
198
|
## How to use it, with one worked example
|
|
154
199
|
|
|
@@ -160,7 +205,7 @@ pnpm local:down
|
|
|
160
205
|
pnpm local:reset
|
|
161
206
|
```
|
|
162
207
|
|
|
163
|
-
`local:up` builds the dashboard files, starts the services and waits until each one is healthy. It then pushes the dashboards and the alert rules, and prints the four addresses. `local:down` stops them and keeps their data. `local:reset` stops them, deletes their data and starts them again.
|
|
208
|
+
`local:up` builds the dashboard files, starts the services and waits until each one is healthy. It then sets up Kafka's topics, users and rules, pushes the dashboards and the alert rules, and prints the four addresses. `local:down` stops them and keeps their data. `local:reset` stops them, deletes their data and starts them again.
|
|
164
209
|
|
|
165
210
|
| Address | What opens |
|
|
166
211
|
| -------------------------- | --------------------------------------------------------------------- |
|
|
@@ -203,11 +248,11 @@ pnpm add --save-dev @zigordev/stack
|
|
|
203
248
|
pnpm exec zigordev-stack up
|
|
204
249
|
```
|
|
205
250
|
|
|
206
|
-
| Command | What it does
|
|
207
|
-
| ---------------------- |
|
|
208
|
-
| `zigordev-stack up` | Starts the services, waits until each one is healthy, and pushes the dashboards and the alert rules. When they run already, it changes nothing |
|
|
209
|
-
| `zigordev-stack down` | Stops them and keeps their data
|
|
210
|
-
| `zigordev-stack reset` | Stops them, deletes their data and starts them again
|
|
251
|
+
| Command | What it does |
|
|
252
|
+
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
253
|
+
| `zigordev-stack up` | Starts the services, waits until each one is healthy, sets up Kafka's topics, users and rules, and pushes the dashboards and the alert rules. When they run already, it changes nothing |
|
|
254
|
+
| `zigordev-stack down` | Stops them and keeps their data |
|
|
255
|
+
| `zigordev-stack reset` | Stops them, deletes their data and starts them again |
|
|
211
256
|
|
|
212
257
|
The package holds the two compose files, the dashboard and alert files already built, and the command. It has no dependency of its own. It needs Node.js 26 or later, and Docker running.
|
|
213
258
|
|
|
@@ -217,23 +262,25 @@ Every product starts the same project, named `platform`. Two products that hold
|
|
|
217
262
|
|
|
218
263
|
## How to check that it works, and what to do when it does not
|
|
219
264
|
|
|
220
|
-
| Try this | What must happen
|
|
221
|
-
| ---------------------------------------------------------------------------- |
|
|
222
|
-
| `pnpm local:up` | It ends with "The shared services are up:" and the four addresses
|
|
223
|
-
| `pnpm local:up` a second time | The same, within seconds, and no
|
|
224
|
-
| Open `http://grafana.localhost`, then Dashboards, then the folder `zigordev` | The dashboards App and Platform are there, and Platform shows the machine's numbers
|
|
225
|
-
| In Grafana, open Alerting, then Alert rules |
|
|
226
|
-
| Open `http://grafana.localhost` and `http://mail.localhost` | Both pages open, with no sign-in
|
|
227
|
-
| In Grafana's Explore, pick Loki and run `{service_name="traefik"}` | Traefik's own log lines show
|
|
228
|
-
| Open `http://nothing.localhost` | Traefik answers 404, because no container asked for that address
|
|
229
|
-
| `pnpm exec vitest run stack` | Every rule on this page that a machine can check passes
|
|
230
|
-
| Open a pull request | The job "Shared services" starts all
|
|
265
|
+
| Try this | What must happen |
|
|
266
|
+
| ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
267
|
+
| `pnpm local:up` | It prints "kafka-setup: done", and ends with "The shared services are up:" and the four addresses |
|
|
268
|
+
| `pnpm local:up` a second time | The same, within seconds, and no service is recreated |
|
|
269
|
+
| Open `http://grafana.localhost`, then Dashboards, then the folder `zigordev` | The dashboards App and Platform are there, and Platform shows the machine's numbers |
|
|
270
|
+
| In Grafana, open Alerting, then Alert rules | Nine rules are listed in the folder `zigordev`, each one "Normal" |
|
|
271
|
+
| Open `http://grafana.localhost` and `http://mail.localhost` | Both pages open, with no sign-in |
|
|
272
|
+
| In Grafana's Explore, pick Loki and run `{service_name="traefik"}` | Traefik's own log lines show |
|
|
273
|
+
| Open `http://nothing.localhost` | Traefik answers 404, because no container asked for that address |
|
|
274
|
+
| `pnpm exec vitest run stack` | Every rule on this page that a machine can check passes |
|
|
275
|
+
| Open a pull request | The job "Shared services" starts all six on GitHub's machine, opens the four addresses and stops them. A change that breaks a start cannot merge |
|
|
231
276
|
|
|
232
277
|
| What you see | What it means | What to do |
|
|
233
278
|
| ------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
234
279
|
| `Cannot connect to the Docker daemon` | Docker is not running | Start Docker Desktop |
|
|
235
280
|
| `Bind for 127.0.0.1:80 failed: port is already allocated` | Another program on the laptop holds port 80 | Find it with `lsof -nP -iTCP:80 -sTCP:LISTEN`, and stop it |
|
|
236
281
|
| `Bind for 127.0.0.1:4318 failed: port is already allocated` | Another program on the laptop holds port 4318, often another OpenTelemetry collector | Find it with `lsof -nP -iTCP:4318 -sTCP:LISTEN`, and stop it |
|
|
282
|
+
| `Bind for 127.0.0.1:9094 failed: port is already allocated` | Another program on the laptop holds port 9094, often another Kafka | Find it with `lsof -nP -iTCP:9094 -sTCP:LISTEN`, and stop it |
|
|
283
|
+
| `local:up` says Kafka's topics and users could not be set up | The job `kafka-setup` could not sign in, or a line of `KAFKA_SETUP` is wrong, or a user's password is not set | The line above "zigordev-stack:" starts with "kafka-setup:" and says which. Each line takes one of the three forms of record 0027 |
|
|
237
284
|
| `local:up` ends with "not every shared service became healthy" | One container did not pass its health check in 5 minutes | The lines above name it. `docker logs platform-<service>-1` shows why |
|
|
238
285
|
| `zigordev-stack up` says "the dashboard files are missing" | The files in `stack/observability/` are built, not committed | `pnpm build`, which `pnpm local:up` does by itself |
|
|
239
286
|
| `local:up` says the dashboards and the alert rules could not be pushed | gcx could not reach Grafana, or Grafana refused a file | The lines above name the file and the reason. `pnpm exec vitest run observability` checks the files' shape |
|
package/compose.local.yaml
CHANGED
|
@@ -29,6 +29,23 @@ services:
|
|
|
29
29
|
traefik.http.routers.alloy.rule: Host(`alloy.localhost`)
|
|
30
30
|
traefik.http.services.alloy.loadbalancer.server.port: "12345"
|
|
31
31
|
|
|
32
|
+
kafka:
|
|
33
|
+
ports:
|
|
34
|
+
- 127.0.0.1:9094:9094
|
|
35
|
+
- "[::1]:9094:9094"
|
|
36
|
+
environment:
|
|
37
|
+
KAFKA_LISTENERS: SASL_PLAINTEXT://:9092,CONTROLLER://localhost:9093,EXTERNAL://:9094
|
|
38
|
+
KAFKA_ADVERTISED_LISTENERS: SASL_PLAINTEXT://kafka:9092,EXTERNAL://localhost:9094
|
|
39
|
+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,SASL_PLAINTEXT:SASL_PLAINTEXT,EXTERNAL:SASL_PLAINTEXT
|
|
40
|
+
KAFKA_LISTENER_NAME_EXTERNAL_SCRAM___SHA___512_SASL_JAAS_CONFIG: org.apache.kafka.common.security.scram.ScramLoginModule required;
|
|
41
|
+
KAFKA_ADMIN_PASSWORD: local-only-admin
|
|
42
|
+
KAFKA_SETUP_PASSWORD: local-only-setup
|
|
43
|
+
|
|
44
|
+
kafka-setup:
|
|
45
|
+
profiles: [setup]
|
|
46
|
+
environment:
|
|
47
|
+
KAFKA_SETUP_PASSWORD: local-only-setup
|
|
48
|
+
|
|
32
49
|
lgtm:
|
|
33
50
|
image: grafana/otel-lgtm:0.41.1@sha256:1b852b77d7bcadb7699bfe7c78a51d059dff85168de674728cf7abf4474645e5
|
|
34
51
|
init: true
|
package/compose.yaml
CHANGED
|
@@ -200,10 +200,21 @@ services:
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
+
prometheus.exporter.blackbox "kafka" {
|
|
204
|
+
config = "{ modules: { tcp: { prober: tcp, timeout: 5s } } }"
|
|
205
|
+
|
|
206
|
+
target {
|
|
207
|
+
name = "kafka"
|
|
208
|
+
address = "kafka:9092"
|
|
209
|
+
module = "tcp"
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
203
213
|
prometheus.scrape "machine" {
|
|
204
214
|
targets = array.concat(
|
|
205
215
|
prometheus.exporter.self.alloy.targets,
|
|
206
216
|
prometheus.exporter.unix.host.targets,
|
|
217
|
+
prometheus.exporter.blackbox.kafka.targets,
|
|
207
218
|
)
|
|
208
219
|
scrape_interval = "60s"
|
|
209
220
|
forward_to = [prometheus.relabel.machine.receiver]
|
|
@@ -214,7 +225,7 @@ services:
|
|
|
214
225
|
|
|
215
226
|
rule {
|
|
216
227
|
source_labels = ["__name__", "mode", "fstype"]
|
|
217
|
-
regex = "alloy_build_info;;|node_cpu_seconds_total;idle;|node_memory_(MemTotal|MemAvailable)_bytes;;|node_filesystem_(size|avail)_bytes;;(ext4|xfs)|container_(memory_working_set|spec_memory_limit)_bytes;;|platform_backup_(last_success_timestamp_seconds|size_bytes);;|platform_restore_test_(last_success_timestamp_seconds|tables);;"
|
|
228
|
+
regex = "alloy_build_info;;|node_cpu_seconds_total;idle;|node_memory_(MemTotal|MemAvailable)_bytes;;|node_filesystem_(size|avail)_bytes;;(ext4|xfs)|container_(memory_working_set|spec_memory_limit)_bytes;;|platform_backup_(last_success_timestamp_seconds|size_bytes);;|platform_restore_test_(last_success_timestamp_seconds|tables);;|probe_success;;"
|
|
218
229
|
action = "keep"
|
|
219
230
|
}
|
|
220
231
|
|
|
@@ -231,6 +242,13 @@ services:
|
|
|
231
242
|
target_label = "job"
|
|
232
243
|
replacement = "host"
|
|
233
244
|
}
|
|
245
|
+
|
|
246
|
+
rule {
|
|
247
|
+
source_labels = ["job"]
|
|
248
|
+
regex = "integrations/blackbox/kafka"
|
|
249
|
+
target_label = "job"
|
|
250
|
+
replacement = "kafka"
|
|
251
|
+
}
|
|
234
252
|
}
|
|
235
253
|
|
|
236
254
|
otelcol.receiver.prometheus "machine" {
|
|
@@ -259,6 +277,151 @@ services:
|
|
|
259
277
|
condition: service_healthy
|
|
260
278
|
networks: [zigordev, docker]
|
|
261
279
|
|
|
280
|
+
kafka:
|
|
281
|
+
image: apache/kafka:4.4.0@sha256:833b867a9585a141da455dc2b57431c65cbccb27f11c91f694444cca9f777e0f
|
|
282
|
+
command:
|
|
283
|
+
- bash
|
|
284
|
+
- -c
|
|
285
|
+
- |
|
|
286
|
+
set -euo pipefail
|
|
287
|
+
export KAFKA_LISTENER_NAME_SASL__PLAINTEXT_SCRAM___SHA___512_SASL_JAAS_CONFIG="org.apache.kafka.common.security.scram.ScramLoginModule required username=\"admin\" password=\"$${KAFKA_ADMIN_PASSWORD}\";"
|
|
288
|
+
printf '%s\n' \
|
|
289
|
+
"process.roles=$${KAFKA_PROCESS_ROLES}" \
|
|
290
|
+
"node.id=$${KAFKA_NODE_ID}" \
|
|
291
|
+
"controller.quorum.voters=$${KAFKA_CONTROLLER_QUORUM_VOTERS}" \
|
|
292
|
+
"controller.listener.names=$${KAFKA_CONTROLLER_LISTENER_NAMES}" \
|
|
293
|
+
"listeners=$${KAFKA_LISTENERS}" \
|
|
294
|
+
"advertised.listeners=$${KAFKA_ADVERTISED_LISTENERS}" \
|
|
295
|
+
"listener.security.protocol.map=$${KAFKA_LISTENER_SECURITY_PROTOCOL_MAP}" \
|
|
296
|
+
"inter.broker.listener.name=$${KAFKA_INTER_BROKER_LISTENER_NAME}" \
|
|
297
|
+
"sasl.enabled.mechanisms=$${KAFKA_SASL_ENABLED_MECHANISMS}" \
|
|
298
|
+
"sasl.mechanism.inter.broker.protocol=$${KAFKA_SASL_MECHANISM_INTER_BROKER_PROTOCOL}" \
|
|
299
|
+
"log.dirs=$${KAFKA_LOG_DIRS}" > /tmp/format.properties
|
|
300
|
+
KAFKA_LOG4J_OPTS=-Dlog4j2.configurationFile=/etc/kafka/docker/tools-log4j2.yaml \
|
|
301
|
+
/opt/kafka/bin/kafka-storage.sh format --ignore-formatted -t "$${CLUSTER_ID}" -c /tmp/format.properties \
|
|
302
|
+
--add-scram "SCRAM-SHA-512=[name=admin,password=$${KAFKA_ADMIN_PASSWORD}]" \
|
|
303
|
+
--add-scram "SCRAM-SHA-512=[name=setup,password=$${KAFKA_SETUP_PASSWORD}]"
|
|
304
|
+
rm /tmp/format.properties
|
|
305
|
+
exec /etc/kafka/docker/run
|
|
306
|
+
user: "1000:1000"
|
|
307
|
+
init: true
|
|
308
|
+
read_only: true
|
|
309
|
+
cap_drop: [ALL]
|
|
310
|
+
security_opt: [no-new-privileges:true]
|
|
311
|
+
stop_grace_period: 30s
|
|
312
|
+
restart: unless-stopped
|
|
313
|
+
mem_limit: 1g
|
|
314
|
+
cpus: 1
|
|
315
|
+
environment:
|
|
316
|
+
CLUSTER_ID: zxDw5kpHRNCfbBLbNLddOw
|
|
317
|
+
KAFKA_NODE_ID: "1"
|
|
318
|
+
KAFKA_PROCESS_ROLES: broker,controller
|
|
319
|
+
KAFKA_LISTENERS: SASL_PLAINTEXT://:9092,CONTROLLER://localhost:9093
|
|
320
|
+
KAFKA_ADVERTISED_LISTENERS: SASL_PLAINTEXT://kafka:9092
|
|
321
|
+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,SASL_PLAINTEXT:SASL_PLAINTEXT
|
|
322
|
+
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
|
|
323
|
+
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@localhost:9093
|
|
324
|
+
KAFKA_INTER_BROKER_LISTENER_NAME: SASL_PLAINTEXT
|
|
325
|
+
KAFKA_SASL_ENABLED_MECHANISMS: SCRAM-SHA-512
|
|
326
|
+
KAFKA_SASL_MECHANISM_INTER_BROKER_PROTOCOL: SCRAM-SHA-512
|
|
327
|
+
KAFKA_OPTS: -Djava.security.auth.login.config=/dev/null
|
|
328
|
+
KAFKA_AUTHORIZER_CLASS_NAME: org.apache.kafka.metadata.authorizer.StandardAuthorizer
|
|
329
|
+
KAFKA_SUPER_USERS: User:admin;User:setup;User:ANONYMOUS
|
|
330
|
+
KAFKA_ALLOW_EVERYONE_IF_NO_ACL_FOUND: "false"
|
|
331
|
+
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false"
|
|
332
|
+
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: "1"
|
|
333
|
+
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: "1"
|
|
334
|
+
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: "1"
|
|
335
|
+
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: "0"
|
|
336
|
+
KAFKA_LOG_DIRS: /var/lib/kafka/data
|
|
337
|
+
KAFKA_HEAP_OPTS: -Xms512m -Xmx512m
|
|
338
|
+
KAFKA_JMX_OPTS: " "
|
|
339
|
+
tmpfs:
|
|
340
|
+
- /tmp
|
|
341
|
+
- /opt/kafka/config:uid=1000,gid=1000
|
|
342
|
+
- /opt/kafka/logs:uid=1000,gid=1000
|
|
343
|
+
volumes:
|
|
344
|
+
- kafka-data:/var/lib/kafka/data
|
|
345
|
+
healthcheck:
|
|
346
|
+
test: [CMD, bash, -c, "exec 3<>/dev/tcp/127.0.0.1/9092"]
|
|
347
|
+
interval: 5s
|
|
348
|
+
timeout: 3s
|
|
349
|
+
retries: 12
|
|
350
|
+
start_period: 60s
|
|
351
|
+
start_interval: 2s
|
|
352
|
+
networks: [zigordev]
|
|
353
|
+
|
|
354
|
+
kafka-setup:
|
|
355
|
+
image: apache/kafka:4.4.0@sha256:833b867a9585a141da455dc2b57431c65cbccb27f11c91f694444cca9f777e0f
|
|
356
|
+
command:
|
|
357
|
+
- bash
|
|
358
|
+
- -c
|
|
359
|
+
- |
|
|
360
|
+
set -euo pipefail
|
|
361
|
+
bin=/opt/kafka/bin
|
|
362
|
+
server=kafka:9092
|
|
363
|
+
printf '%s\n' "security.protocol=SASL_PLAINTEXT" "sasl.mechanism=SCRAM-SHA-512" \
|
|
364
|
+
"sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required username=\"setup\" password=\"$${KAFKA_SETUP_PASSWORD}\";" \
|
|
365
|
+
> /tmp/setup.properties
|
|
366
|
+
sign_in=(--bootstrap-server "$$server" --command-config /tmp/setup.properties)
|
|
367
|
+
"$$bin/kafka-topics.sh" "$${sign_in[@]}" --list > /dev/null
|
|
368
|
+
while read -r verb first second third fourth fifth; do
|
|
369
|
+
case "$$verb" in
|
|
370
|
+
'') ;;
|
|
371
|
+
topic)
|
|
372
|
+
"$$bin/kafka-topics.sh" "$${sign_in[@]}" --create --if-not-exists --topic "$$first" \
|
|
373
|
+
--partitions "$$second" --replication-factor 1 > /dev/null
|
|
374
|
+
echo "kafka-setup: topic $$first"
|
|
375
|
+
;;
|
|
376
|
+
user)
|
|
377
|
+
variable="KAFKA_PASSWORD_$$(printf '%s' "$$first" | tr 'a-z-' 'A-Z_')"
|
|
378
|
+
password="$${!variable:-}"
|
|
379
|
+
if [ -z "$$password" ]; then
|
|
380
|
+
echo "kafka-setup: $$variable is not set, so the user $$first cannot sign in" >&2
|
|
381
|
+
exit 1
|
|
382
|
+
fi
|
|
383
|
+
"$$bin/kafka-configs.sh" "$${sign_in[@]}" --alter --entity-type users --entity-name "$$first" \
|
|
384
|
+
--add-config "SCRAM-SHA-512=[password=$$password]" > /dev/null
|
|
385
|
+
echo "kafka-setup: user $$first"
|
|
386
|
+
;;
|
|
387
|
+
allow)
|
|
388
|
+
pattern=literal
|
|
389
|
+
if [ "$${fifth:-}" = prefixed ]; then
|
|
390
|
+
pattern=prefixed
|
|
391
|
+
fi
|
|
392
|
+
"$$bin/kafka-acls.sh" "$${sign_in[@]}" --add --allow-principal "User:$$first" \
|
|
393
|
+
--operation "$$second" "--$$third" "$$fourth" --resource-pattern-type "$$pattern" > /dev/null
|
|
394
|
+
echo "kafka-setup: $$first may $$second $$third $$fourth ($$pattern)"
|
|
395
|
+
;;
|
|
396
|
+
*)
|
|
397
|
+
echo "kafka-setup: unknown line: $$verb $$first" >&2
|
|
398
|
+
exit 1
|
|
399
|
+
;;
|
|
400
|
+
esac
|
|
401
|
+
done <<< "$${KAFKA_SETUP:-}"
|
|
402
|
+
echo "kafka-setup: done"
|
|
403
|
+
user: "1000:1000"
|
|
404
|
+
init: true
|
|
405
|
+
read_only: true
|
|
406
|
+
cap_drop: [ALL]
|
|
407
|
+
security_opt: [no-new-privileges:true]
|
|
408
|
+
stop_grace_period: 10s
|
|
409
|
+
restart: "no"
|
|
410
|
+
mem_limit: 512m
|
|
411
|
+
cpus: 0.5
|
|
412
|
+
environment:
|
|
413
|
+
KAFKA_HEAP_OPTS: -Xms128m -Xmx256m
|
|
414
|
+
KAFKA_SETUP: ""
|
|
415
|
+
tmpfs:
|
|
416
|
+
- /tmp
|
|
417
|
+
- /opt/kafka/logs:uid=1000,gid=1000
|
|
418
|
+
labels:
|
|
419
|
+
com.zigordev.job: migrate
|
|
420
|
+
depends_on:
|
|
421
|
+
kafka:
|
|
422
|
+
condition: service_healthy
|
|
423
|
+
networks: [zigordev]
|
|
424
|
+
|
|
262
425
|
networks:
|
|
263
426
|
zigordev:
|
|
264
427
|
name: zigordev
|
|
@@ -268,3 +431,4 @@ networks:
|
|
|
268
431
|
|
|
269
432
|
volumes:
|
|
270
433
|
alloy-data:
|
|
434
|
+
kafka-data:
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;AAEzF,MAAM,WAAW,EAAE;IACjB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,KAAK,YAAI,cAAc,EAAE,oBAAoB,CAAU,CAAC;AACrE,eAAO,MAAM,SAAS,kBAAkB,CAAC;AAEzC,eAAO,MAAM,SAAS,sBACnB,0BAA0B,EAAE,oDAAoD,aAChF,uBAAuB,EAAE,0CAA0C,aACnE,0BAA0B,EAAE,8BAA8B,aAC1D,wBAAwB,EAAE,+CAA+C,EAClE,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;AAEzF,MAAM,WAAW,EAAE;IACjB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,KAAK,YAAI,cAAc,EAAE,oBAAoB,CAAU,CAAC;AACrE,eAAO,MAAM,SAAS,kBAAkB,CAAC;AAEzC,eAAO,MAAM,SAAS,sBACnB,0BAA0B,EAAE,oDAAoD,aAChF,uBAAuB,EAAE,0CAA0C,aACnE,0BAA0B,EAAE,8BAA8B,aAC1D,wBAAwB,EAAE,+CAA+C,EAClE,CAAC;AAoEX,wBAAgB,IAAI,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,MAAM,CAe5D"}
|
package/dist/cli.js
CHANGED
|
@@ -13,7 +13,8 @@ const usage = [
|
|
|
13
13
|
' zigordev-stack reset',
|
|
14
14
|
'',
|
|
15
15
|
'up Starts the shared services and waits until each one is healthy.',
|
|
16
|
-
|
|
16
|
+
" It then sets up Kafka's topics and users, and pushes the dashboards",
|
|
17
|
+
' and the alert rules to the local Grafana.',
|
|
17
18
|
' When the services are running already, it changes nothing.',
|
|
18
19
|
'down Stops them and keeps their data.',
|
|
19
20
|
'reset Stops them, deletes their data and starts them again.',
|
|
@@ -32,6 +33,11 @@ function up(io) {
|
|
|
32
33
|
io.write('zigordev-stack: not every shared service became healthy. The lines above name the one that did not\n');
|
|
33
34
|
return started;
|
|
34
35
|
}
|
|
36
|
+
const setUp = compose(io, 'run', '--rm', 'kafka-setup');
|
|
37
|
+
if (setUp !== 0) {
|
|
38
|
+
io.write("zigordev-stack: the services are up, but Kafka's topics and users could not be set up. The lines above say why\n");
|
|
39
|
+
return setUp;
|
|
40
|
+
}
|
|
35
41
|
const pushed = compose(io, 'run', '--rm', 'gcx');
|
|
36
42
|
if (pushed !== 0) {
|
|
37
43
|
io.write('zigordev-stack: the services are up, but the dashboards and the alert rules could not be pushed. The lines above say why\n');
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAWjC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,cAAc,EAAE,oBAAoB,CAAU,CAAC;AACrE,MAAM,CAAC,MAAM,SAAS,GAAG,eAAe,CAAC;AAEzC,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,CAAC,0BAA0B,EAAE,oDAAoD,CAAC;IAClF,CAAC,uBAAuB,EAAE,0CAA0C,CAAC;IACrE,CAAC,0BAA0B,EAAE,8BAA8B,CAAC;IAC5D,CAAC,wBAAwB,EAAE,+CAA+C,CAAC;CACnE,CAAC;AAEX,MAAM,KAAK,GAAG;IACZ,0BAA0B;IAC1B,4BAA4B;IAC5B,6BAA6B;IAC7B,EAAE;IACF,wEAAwE;IACxE,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"apiVersion": "rules.alerting.grafana.app/v1beta1",
|
|
3
|
+
"kind": "AlertRule",
|
|
4
|
+
"metadata": {
|
|
5
|
+
"name": "kafka-broker-is-down",
|
|
6
|
+
"annotations": {
|
|
7
|
+
"grafana.app/folder": "zigordev"
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"spec": {
|
|
11
|
+
"title": "The Kafka broker is down",
|
|
12
|
+
"trigger": {
|
|
13
|
+
"interval": "1m"
|
|
14
|
+
},
|
|
15
|
+
"for": "5m",
|
|
16
|
+
"noDataState": "Ok",
|
|
17
|
+
"execErrState": "Error",
|
|
18
|
+
"labels": {
|
|
19
|
+
"severity": "phone"
|
|
20
|
+
},
|
|
21
|
+
"annotations": {
|
|
22
|
+
"summary": "The Kafka broker has not answered on its port for 5 minutes, so no app can send or read events",
|
|
23
|
+
"runbook_url": "https://github.com/zigordev/platform/blob/main/docs/runbooks/kafka-broker-is-down.md",
|
|
24
|
+
"__dashboardUid__": "platform",
|
|
25
|
+
"__panelId__": "14"
|
|
26
|
+
},
|
|
27
|
+
"expressions": {
|
|
28
|
+
"A": {
|
|
29
|
+
"datasourceUID": "prometheus",
|
|
30
|
+
"relativeTimeRange": {
|
|
31
|
+
"from": "10m",
|
|
32
|
+
"to": "0s"
|
|
33
|
+
},
|
|
34
|
+
"model": {
|
|
35
|
+
"refId": "A",
|
|
36
|
+
"expr": "(max(probe_success{job=\"kafka\"})) < 1",
|
|
37
|
+
"instant": true
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"B": {
|
|
41
|
+
"source": true,
|
|
42
|
+
"model": {
|
|
43
|
+
"refId": "B",
|
|
44
|
+
"type": "threshold",
|
|
45
|
+
"expression": "A",
|
|
46
|
+
"conditions": [
|
|
47
|
+
{
|
|
48
|
+
"evaluator": {
|
|
49
|
+
"type": "gt",
|
|
50
|
+
"params": [
|
|
51
|
+
0
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"apiVersion": "rules.alerting.grafana.app/v1beta1",
|
|
3
|
+
"kind": "AlertRule",
|
|
4
|
+
"metadata": {
|
|
5
|
+
"name": "message-reached-dead-letter-topic",
|
|
6
|
+
"annotations": {
|
|
7
|
+
"grafana.app/folder": "zigordev"
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"spec": {
|
|
11
|
+
"title": "A message reached a dead-letter topic",
|
|
12
|
+
"trigger": {
|
|
13
|
+
"interval": "1m"
|
|
14
|
+
},
|
|
15
|
+
"for": "0s",
|
|
16
|
+
"noDataState": "Ok",
|
|
17
|
+
"execErrState": "Error",
|
|
18
|
+
"labels": {
|
|
19
|
+
"severity": "email"
|
|
20
|
+
},
|
|
21
|
+
"annotations": {
|
|
22
|
+
"summary": "{{ $labels.service_name }} set a message from {{ $labels.messaging_destination_name }} aside on its dead-letter topic, with the reason {{ $labels.zigordev_events_reason }}",
|
|
23
|
+
"runbook_url": "https://github.com/zigordev/platform/blob/main/docs/runbooks/message-reached-dead-letter-topic.md",
|
|
24
|
+
"__dashboardUid__": "app",
|
|
25
|
+
"__panelId__": "14"
|
|
26
|
+
},
|
|
27
|
+
"expressions": {
|
|
28
|
+
"A": {
|
|
29
|
+
"datasourceUID": "prometheus",
|
|
30
|
+
"relativeTimeRange": {
|
|
31
|
+
"from": "10m",
|
|
32
|
+
"to": "0s"
|
|
33
|
+
},
|
|
34
|
+
"model": {
|
|
35
|
+
"refId": "A",
|
|
36
|
+
"expr": "sum by (service_name, messaging_destination_name, zigordev_events_reason) (increase(zigordev_events_dead_letters_total[10m])) > 0",
|
|
37
|
+
"instant": true
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"B": {
|
|
41
|
+
"source": true,
|
|
42
|
+
"model": {
|
|
43
|
+
"refId": "B",
|
|
44
|
+
"type": "threshold",
|
|
45
|
+
"expression": "A",
|
|
46
|
+
"conditions": [
|
|
47
|
+
{
|
|
48
|
+
"evaluator": {
|
|
49
|
+
"type": "gt",
|
|
50
|
+
"params": [
|
|
51
|
+
0
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"apiVersion": "rules.alerting.grafana.app/v1beta1",
|
|
3
|
+
"kind": "AlertRule",
|
|
4
|
+
"metadata": {
|
|
5
|
+
"name": "messages-are-stuck",
|
|
6
|
+
"annotations": {
|
|
7
|
+
"grafana.app/folder": "zigordev"
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"spec": {
|
|
11
|
+
"title": "Messages are stuck",
|
|
12
|
+
"trigger": {
|
|
13
|
+
"interval": "1m"
|
|
14
|
+
},
|
|
15
|
+
"for": "5m",
|
|
16
|
+
"noDataState": "Ok",
|
|
17
|
+
"execErrState": "Error",
|
|
18
|
+
"labels": {
|
|
19
|
+
"severity": "phone"
|
|
20
|
+
},
|
|
21
|
+
"annotations": {
|
|
22
|
+
"summary": "{{ $labels.service_name }} has had messages waiting on {{ $labels.messaging_destination_name }} for 15 minutes, and has handled none of them",
|
|
23
|
+
"runbook_url": "https://github.com/zigordev/platform/blob/main/docs/runbooks/messages-are-stuck.md",
|
|
24
|
+
"__dashboardUid__": "app",
|
|
25
|
+
"__panelId__": "13"
|
|
26
|
+
},
|
|
27
|
+
"expressions": {
|
|
28
|
+
"A": {
|
|
29
|
+
"datasourceUID": "prometheus",
|
|
30
|
+
"relativeTimeRange": {
|
|
31
|
+
"from": "10m",
|
|
32
|
+
"to": "0s"
|
|
33
|
+
},
|
|
34
|
+
"model": {
|
|
35
|
+
"refId": "A",
|
|
36
|
+
"expr": "(max by (service_name, messaging_destination_name, messaging_consumer_group_name) (zigordev_events_consumer_lag) > 0) unless on (service_name, messaging_destination_name, messaging_consumer_group_name) (sum by (service_name, messaging_destination_name, messaging_consumer_group_name) (increase(messaging_client_consumed_messages_total[10m])) > 0)",
|
|
37
|
+
"instant": true
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"B": {
|
|
41
|
+
"source": true,
|
|
42
|
+
"model": {
|
|
43
|
+
"refId": "B",
|
|
44
|
+
"type": "threshold",
|
|
45
|
+
"expression": "A",
|
|
46
|
+
"conditions": [
|
|
47
|
+
{
|
|
48
|
+
"evaluator": {
|
|
49
|
+
"type": "gt",
|
|
50
|
+
"params": [
|
|
51
|
+
0
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -617,6 +617,105 @@
|
|
|
617
617
|
"refId": "A"
|
|
618
618
|
}
|
|
619
619
|
]
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
"type": "row",
|
|
623
|
+
"collapsed": false,
|
|
624
|
+
"id": 0,
|
|
625
|
+
"panels": [],
|
|
626
|
+
"title": "Messages",
|
|
627
|
+
"gridPos": {
|
|
628
|
+
"x": 0,
|
|
629
|
+
"y": 46,
|
|
630
|
+
"h": 1,
|
|
631
|
+
"w": 24
|
|
632
|
+
}
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
"type": "timeseries",
|
|
636
|
+
"transparent": false,
|
|
637
|
+
"repeatDirection": "h",
|
|
638
|
+
"options": {
|
|
639
|
+
"legend": {
|
|
640
|
+
"displayMode": "list",
|
|
641
|
+
"placement": "bottom",
|
|
642
|
+
"showLegend": false,
|
|
643
|
+
"calcs": []
|
|
644
|
+
},
|
|
645
|
+
"tooltip": {
|
|
646
|
+
"mode": "single",
|
|
647
|
+
"sort": "asc"
|
|
648
|
+
}
|
|
649
|
+
},
|
|
650
|
+
"fieldConfig": {
|
|
651
|
+
"defaults": {
|
|
652
|
+
"custom": {},
|
|
653
|
+
"unit": "short"
|
|
654
|
+
},
|
|
655
|
+
"overrides": []
|
|
656
|
+
},
|
|
657
|
+
"id": 13,
|
|
658
|
+
"title": "Messages waiting, by topic",
|
|
659
|
+
"datasource": {
|
|
660
|
+
"type": "prometheus",
|
|
661
|
+
"uid": "prometheus"
|
|
662
|
+
},
|
|
663
|
+
"gridPos": {
|
|
664
|
+
"h": 8,
|
|
665
|
+
"w": 12,
|
|
666
|
+
"x": 0,
|
|
667
|
+
"y": 47
|
|
668
|
+
},
|
|
669
|
+
"targets": [
|
|
670
|
+
{
|
|
671
|
+
"expr": "max by (messaging_destination_name, messaging_consumer_group_name) (zigordev_events_consumer_lag{service_name=\"$app\"})",
|
|
672
|
+
"legendFormat": "{{messaging_destination_name}}",
|
|
673
|
+
"refId": "A"
|
|
674
|
+
}
|
|
675
|
+
]
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
"type": "timeseries",
|
|
679
|
+
"transparent": false,
|
|
680
|
+
"repeatDirection": "h",
|
|
681
|
+
"options": {
|
|
682
|
+
"legend": {
|
|
683
|
+
"displayMode": "list",
|
|
684
|
+
"placement": "bottom",
|
|
685
|
+
"showLegend": false,
|
|
686
|
+
"calcs": []
|
|
687
|
+
},
|
|
688
|
+
"tooltip": {
|
|
689
|
+
"mode": "single",
|
|
690
|
+
"sort": "asc"
|
|
691
|
+
}
|
|
692
|
+
},
|
|
693
|
+
"fieldConfig": {
|
|
694
|
+
"defaults": {
|
|
695
|
+
"custom": {},
|
|
696
|
+
"unit": "short"
|
|
697
|
+
},
|
|
698
|
+
"overrides": []
|
|
699
|
+
},
|
|
700
|
+
"id": 14,
|
|
701
|
+
"title": "Messages set aside, by topic",
|
|
702
|
+
"datasource": {
|
|
703
|
+
"type": "prometheus",
|
|
704
|
+
"uid": "prometheus"
|
|
705
|
+
},
|
|
706
|
+
"gridPos": {
|
|
707
|
+
"h": 8,
|
|
708
|
+
"w": 12,
|
|
709
|
+
"x": 12,
|
|
710
|
+
"y": 47
|
|
711
|
+
},
|
|
712
|
+
"targets": [
|
|
713
|
+
{
|
|
714
|
+
"expr": "sum by (messaging_destination_name, zigordev_events_reason) (increase(zigordev_events_dead_letters_total{service_name=\"$app\"}[$__rate_interval]))",
|
|
715
|
+
"legendFormat": "{{messaging_destination_name}}, {{zigordev_events_reason}}",
|
|
716
|
+
"refId": "A"
|
|
717
|
+
}
|
|
718
|
+
]
|
|
620
719
|
}
|
|
621
720
|
]
|
|
622
721
|
}
|
|
@@ -645,6 +645,62 @@
|
|
|
645
645
|
"refId": "A"
|
|
646
646
|
}
|
|
647
647
|
]
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
"type": "row",
|
|
651
|
+
"collapsed": false,
|
|
652
|
+
"id": 0,
|
|
653
|
+
"panels": [],
|
|
654
|
+
"title": "Kafka",
|
|
655
|
+
"gridPos": {
|
|
656
|
+
"x": 0,
|
|
657
|
+
"y": 48,
|
|
658
|
+
"h": 1,
|
|
659
|
+
"w": 24
|
|
660
|
+
}
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
"type": "timeseries",
|
|
664
|
+
"transparent": false,
|
|
665
|
+
"repeatDirection": "h",
|
|
666
|
+
"options": {
|
|
667
|
+
"legend": {
|
|
668
|
+
"displayMode": "list",
|
|
669
|
+
"placement": "bottom",
|
|
670
|
+
"showLegend": false,
|
|
671
|
+
"calcs": []
|
|
672
|
+
},
|
|
673
|
+
"tooltip": {
|
|
674
|
+
"mode": "single",
|
|
675
|
+
"sort": "asc"
|
|
676
|
+
}
|
|
677
|
+
},
|
|
678
|
+
"fieldConfig": {
|
|
679
|
+
"defaults": {
|
|
680
|
+
"custom": {},
|
|
681
|
+
"unit": "short"
|
|
682
|
+
},
|
|
683
|
+
"overrides": []
|
|
684
|
+
},
|
|
685
|
+
"id": 14,
|
|
686
|
+
"title": "The broker answers on its port",
|
|
687
|
+
"datasource": {
|
|
688
|
+
"type": "prometheus",
|
|
689
|
+
"uid": "prometheus"
|
|
690
|
+
},
|
|
691
|
+
"gridPos": {
|
|
692
|
+
"h": 8,
|
|
693
|
+
"w": 12,
|
|
694
|
+
"x": 0,
|
|
695
|
+
"y": 49
|
|
696
|
+
},
|
|
697
|
+
"targets": [
|
|
698
|
+
{
|
|
699
|
+
"expr": "max(probe_success{job=\"kafka\"})",
|
|
700
|
+
"legendFormat": "kafka",
|
|
701
|
+
"refId": "A"
|
|
702
|
+
}
|
|
703
|
+
]
|
|
648
704
|
}
|
|
649
705
|
]
|
|
650
706
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zigordev/stack",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.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",
|