@zigordev/stack 1.8.0 → 1.9.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 CHANGED
@@ -6,19 +6,19 @@ The shared services of the zigordev platform for a laptop: the ingress, the tele
6
6
 
7
7
  Six containers that every product on the laptop shares, and on the laptop the notifications service with its database. Four of them run in production too, from the same file.
8
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
- | `notifications-api` | notifications, pinned to one commit | The email service of every product. It reads each app's email requests from Kafka and sends the email to Mailpit | Laptop only, started last by `up` |
20
- | `notifications-api-migrate` | notifications, pinned to one commit | Not a service but a job: it sets up notifications' database, and ends | Laptop only, before the service |
21
- | `notifications-postgres` | PostgreSQL 18 | notifications' own database, on a network of its own | Laptop only |
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
+ | `notifications-api` | notifications, its tag `main` | The email service of every product. It reads each app's email requests from Kafka and sends the email to Mailpit | Laptop only, started last by `up` |
20
+ | `notifications-api-migrate` | notifications, its tag `main` | Not a service but a job: it sets up notifications' database, and ends | Laptop only, before the service |
21
+ | `notifications-postgres` | PostgreSQL 18 | notifications' own database, on a network of its own | Laptop only |
22
22
 
23
23
  | File | What it holds |
24
24
  | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -191,7 +191,7 @@ The broker formats its own storage before the image starts it, and makes the use
191
191
  Every product's email requests travel over Kafka to the notifications service, which sends the email. So that one command brings everything up, the laptop also runs notifications, from the profile `notifications` in `compose.local.yaml`: the service, its migration job and its own PostgreSQL. It sends every email to Mailpit. In production notifications is a deploy target of its own, from its own repo.
192
192
 
193
193
  - `zigordev-stack up` starts it last, after Kafka's job has made the topics and users, because a consumer that finds a topic missing never starts.
194
- - It runs the image that notifications published, pinned to a commit and its digest. A newer version is a new pin, in a pull request.
194
+ - It runs notifications' newest image: its tag `main`, pinned with the digest. Each merge to notifications' `main` moves the tag, and Renovate then proposes the new digest here, after the day's wait, as for every other image. toolkit's record 0052 says why. Its health check names the version `main`.
195
195
  - It asks Traefik for no route, and its database publishes no port. It signs in to Kafka as `notifications-api`, with the throwaway password that Kafka's job gives that user.
196
196
  - Work on notifications itself runs its own copy, from its repo. `zigordev-stack up --without notifications` stops the shared copy instead of starting it, so the two copies never share the requests.
197
197
  - It holds at most 640 MB of memory: 256 MB for the service, 128 MB for the job while it runs, and 256 MB for the database.
@@ -135,7 +135,7 @@ services:
135
135
  networks: [zigordev]
136
136
 
137
137
  notifications-api:
138
- image: ghcr.io/zigordev/notifications-api:282146ba160fce8374cf3b827b475229522e7f59@sha256:eb4fef5f7f72a7dae9f18bb931050080ee02c52f9a194ff453929590ada09d74
138
+ image: ghcr.io/zigordev/notifications-api:main@sha256:ccc88fdd3c4469660a16034d40bf84f0c61c4dcac29f5009153e553feb25c140
139
139
  profiles: [notifications]
140
140
  restart: unless-stopped
141
141
  user: "1000:1000"
@@ -149,7 +149,7 @@ services:
149
149
  environment:
150
150
  PORT: "3000"
151
151
  OTEL_SERVICE_NAME: notifications-api
152
- OTEL_SERVICE_VERSION: 282146ba160fce8374cf3b827b475229522e7f59
152
+ OTEL_SERVICE_VERSION: main
153
153
  OTEL_RESOURCE_ATTRIBUTES: deployment.environment.name=local
154
154
  OTEL_EXPORTER_OTLP_ENDPOINT: http://alloy:4318
155
155
  DATABASE_URL: postgresql://notifications_api:local-only@notifications-postgres:5432/notifications_api
@@ -174,7 +174,7 @@ services:
174
174
  networks: [zigordev, notifications]
175
175
 
176
176
  notifications-api-migrate:
177
- image: ghcr.io/zigordev/notifications-api:282146ba160fce8374cf3b827b475229522e7f59@sha256:eb4fef5f7f72a7dae9f18bb931050080ee02c52f9a194ff453929590ada09d74
177
+ image: ghcr.io/zigordev/notifications-api:main@sha256:ccc88fdd3c4469660a16034d40bf84f0c61c4dcac29f5009153e553feb25c140
178
178
  profiles: [notifications]
179
179
  command: [node, src/migrate.ts]
180
180
  restart: "no"
@@ -188,7 +188,7 @@ services:
188
188
  cpus: 1
189
189
  environment:
190
190
  OTEL_SERVICE_NAME: notifications-api-migrate
191
- OTEL_SERVICE_VERSION: 282146ba160fce8374cf3b827b475229522e7f59
191
+ OTEL_SERVICE_VERSION: main
192
192
  DATABASE_URL: postgresql://notifications_api:local-only@notifications-postgres:5432/notifications_api
193
193
  DATABASE_ADMIN_URL: postgresql://postgres:local-only@notifications-postgres:5432/postgres
194
194
  labels:
@@ -0,0 +1,60 @@
1
+ {
2
+ "apiVersion": "rules.alerting.grafana.app/v1beta1",
3
+ "kind": "AlertRule",
4
+ "metadata": {
5
+ "name": "app-cannot-be-reached-from-outside",
6
+ "annotations": {
7
+ "grafana.app/folder": "zigordev"
8
+ }
9
+ },
10
+ "spec": {
11
+ "title": "An app cannot be reached from outside",
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 latest outside check of {{ $labels.product }} has failed from every place for 5 minutes, so its visitors likely cannot reach it either",
23
+ "runbook_url": "https://github.com/zigordev/platform/blob/main/docs/runbooks/app-cannot-be-reached-from-outside.md",
24
+ "__dashboardUid__": "platform",
25
+ "__panelId__": "17"
26
+ },
27
+ "expressions": {
28
+ "A": {
29
+ "datasourceUID": "prometheus",
30
+ "relativeTimeRange": {
31
+ "from": "10m",
32
+ "to": "0s"
33
+ },
34
+ "model": {
35
+ "refId": "A",
36
+ "expr": "(1 - max by (product) (probe_success{product!=\"\"})) > 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": "email-failed-for-good",
6
+ "annotations": {
7
+ "grafana.app/folder": "zigordev"
8
+ }
9
+ },
10
+ "spec": {
11
+ "title": "An email failed for good",
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": "An email that {{ $labels.producer }} asked {{ $labels.service_name }} to send has failed for good, so its recipient will not get it",
23
+ "runbook_url": "https://github.com/zigordev/platform/blob/main/docs/runbooks/email-failed-for-good.md",
24
+ "__dashboardUid__": "platform",
25
+ "__panelId__": "15"
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, producer) (increase(notifications_email_deliveries_total{outcome=\"failed\"}[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": "jobs-are-waiting",
6
+ "annotations": {
7
+ "grafana.app/folder": "zigordev"
8
+ }
9
+ },
10
+ "spec": {
11
+ "title": "Jobs are waiting",
12
+ "trigger": {
13
+ "interval": "1m"
14
+ },
15
+ "for": "15m",
16
+ "noDataState": "Ok",
17
+ "execErrState": "Error",
18
+ "labels": {
19
+ "severity": "phone"
20
+ },
21
+ "annotations": {
22
+ "summary": "{{ $labels.service_name }} has had jobs ready to start on its queue {{ $labels.messaging_destination_name }} for 15 minutes, so their work is late",
23
+ "runbook_url": "https://github.com/zigordev/platform/blob/main/docs/runbooks/jobs-are-waiting.md",
24
+ "__dashboardUid__": "app",
25
+ "__panelId__": "15"
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) (pgboss_queue_jobs{pgboss_job_state=\"ready\"}) > 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
+ }
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "model": {
35
35
  "refId": "A",
36
- "expr": "(max(probe_success{job=\"kafka\"})) < 1",
36
+ "expr": "(1 - max(probe_success{job=\"kafka\"})) > 0",
37
37
  "instant": true
38
38
  }
39
39
  },
@@ -0,0 +1,60 @@
1
+ {
2
+ "apiVersion": "rules.alerting.grafana.app/v1beta1",
3
+ "kind": "AlertRule",
4
+ "metadata": {
5
+ "name": "mail-server-cannot-be-reached",
6
+ "annotations": {
7
+ "grafana.app/folder": "zigordev"
8
+ }
9
+ },
10
+ "spec": {
11
+ "title": "The mail server cannot be reached",
12
+ "trigger": {
13
+ "interval": "1m"
14
+ },
15
+ "for": "10m",
16
+ "noDataState": "Ok",
17
+ "execErrState": "Error",
18
+ "labels": {
19
+ "severity": "email"
20
+ },
21
+ "annotations": {
22
+ "summary": "{{ $labels.service_name }} has failed to reach its mail server, or to sign in to it, for 10 minutes, so it holds every email until it can",
23
+ "runbook_url": "https://github.com/zigordev/platform/blob/main/docs/runbooks/mail-server-cannot-be-reached.md",
24
+ "__dashboardUid__": "platform",
25
+ "__panelId__": "16"
26
+ },
27
+ "expressions": {
28
+ "A": {
29
+ "datasourceUID": "prometheus",
30
+ "relativeTimeRange": {
31
+ "from": "10m",
32
+ "to": "0s"
33
+ },
34
+ "model": {
35
+ "refId": "A",
36
+ "expr": "(1 - max by (service_name) (notifications_provider_up)) > 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
+ }
@@ -716,6 +716,62 @@
716
716
  "refId": "A"
717
717
  }
718
718
  ]
719
+ },
720
+ {
721
+ "type": "row",
722
+ "collapsed": false,
723
+ "id": 0,
724
+ "panels": [],
725
+ "title": "Jobs",
726
+ "gridPos": {
727
+ "x": 0,
728
+ "y": 55,
729
+ "h": 1,
730
+ "w": 24
731
+ }
732
+ },
733
+ {
734
+ "type": "timeseries",
735
+ "transparent": false,
736
+ "repeatDirection": "h",
737
+ "options": {
738
+ "legend": {
739
+ "displayMode": "list",
740
+ "placement": "bottom",
741
+ "showLegend": false,
742
+ "calcs": []
743
+ },
744
+ "tooltip": {
745
+ "mode": "single",
746
+ "sort": "asc"
747
+ }
748
+ },
749
+ "fieldConfig": {
750
+ "defaults": {
751
+ "custom": {},
752
+ "unit": "short"
753
+ },
754
+ "overrides": []
755
+ },
756
+ "id": 15,
757
+ "title": "Jobs ready to start, by queue",
758
+ "datasource": {
759
+ "type": "prometheus",
760
+ "uid": "prometheus"
761
+ },
762
+ "gridPos": {
763
+ "h": 8,
764
+ "w": 12,
765
+ "x": 0,
766
+ "y": 56
767
+ },
768
+ "targets": [
769
+ {
770
+ "expr": "max by (messaging_destination_name) (pgboss_queue_jobs{service_name=\"$app\", pgboss_job_state=\"ready\"})",
771
+ "legendFormat": "{{messaging_destination_name}}",
772
+ "refId": "A"
773
+ }
774
+ ]
719
775
  }
720
776
  ]
721
777
  }
@@ -701,6 +701,161 @@
701
701
  "refId": "A"
702
702
  }
703
703
  ]
704
+ },
705
+ {
706
+ "type": "row",
707
+ "collapsed": false,
708
+ "id": 0,
709
+ "panels": [],
710
+ "title": "Email",
711
+ "gridPos": {
712
+ "x": 0,
713
+ "y": 57,
714
+ "h": 1,
715
+ "w": 24
716
+ }
717
+ },
718
+ {
719
+ "type": "timeseries",
720
+ "transparent": false,
721
+ "repeatDirection": "h",
722
+ "options": {
723
+ "legend": {
724
+ "displayMode": "list",
725
+ "placement": "bottom",
726
+ "showLegend": false,
727
+ "calcs": []
728
+ },
729
+ "tooltip": {
730
+ "mode": "single",
731
+ "sort": "asc"
732
+ }
733
+ },
734
+ "fieldConfig": {
735
+ "defaults": {
736
+ "custom": {},
737
+ "unit": "short"
738
+ },
739
+ "overrides": []
740
+ },
741
+ "id": 15,
742
+ "title": "Emails that ended, by app and outcome",
743
+ "datasource": {
744
+ "type": "prometheus",
745
+ "uid": "prometheus"
746
+ },
747
+ "gridPos": {
748
+ "h": 8,
749
+ "w": 12,
750
+ "x": 0,
751
+ "y": 58
752
+ },
753
+ "targets": [
754
+ {
755
+ "expr": "sum by (producer, outcome) (increase(notifications_email_deliveries_total[$__rate_interval]))",
756
+ "legendFormat": "{{producer}}, {{outcome}}",
757
+ "refId": "A"
758
+ }
759
+ ]
760
+ },
761
+ {
762
+ "type": "timeseries",
763
+ "transparent": false,
764
+ "repeatDirection": "h",
765
+ "options": {
766
+ "legend": {
767
+ "displayMode": "list",
768
+ "placement": "bottom",
769
+ "showLegend": false,
770
+ "calcs": []
771
+ },
772
+ "tooltip": {
773
+ "mode": "single",
774
+ "sort": "asc"
775
+ }
776
+ },
777
+ "fieldConfig": {
778
+ "defaults": {
779
+ "custom": {},
780
+ "unit": "short"
781
+ },
782
+ "overrides": []
783
+ },
784
+ "id": 16,
785
+ "title": "The mail server answers",
786
+ "datasource": {
787
+ "type": "prometheus",
788
+ "uid": "prometheus"
789
+ },
790
+ "gridPos": {
791
+ "h": 8,
792
+ "w": 12,
793
+ "x": 12,
794
+ "y": 58
795
+ },
796
+ "targets": [
797
+ {
798
+ "expr": "max by (service_name) (notifications_provider_up)",
799
+ "legendFormat": "{{service_name}}",
800
+ "refId": "A"
801
+ }
802
+ ]
803
+ },
804
+ {
805
+ "type": "row",
806
+ "collapsed": false,
807
+ "id": 0,
808
+ "panels": [],
809
+ "title": "From outside",
810
+ "gridPos": {
811
+ "x": 0,
812
+ "y": 66,
813
+ "h": 1,
814
+ "w": 24
815
+ }
816
+ },
817
+ {
818
+ "type": "timeseries",
819
+ "transparent": false,
820
+ "repeatDirection": "h",
821
+ "options": {
822
+ "legend": {
823
+ "displayMode": "list",
824
+ "placement": "bottom",
825
+ "showLegend": false,
826
+ "calcs": []
827
+ },
828
+ "tooltip": {
829
+ "mode": "single",
830
+ "sort": "asc"
831
+ }
832
+ },
833
+ "fieldConfig": {
834
+ "defaults": {
835
+ "custom": {},
836
+ "unit": "short"
837
+ },
838
+ "overrides": []
839
+ },
840
+ "id": 17,
841
+ "title": "Outside checks that pass, by product and place",
842
+ "datasource": {
843
+ "type": "prometheus",
844
+ "uid": "prometheus"
845
+ },
846
+ "gridPos": {
847
+ "h": 8,
848
+ "w": 12,
849
+ "x": 0,
850
+ "y": 67
851
+ },
852
+ "targets": [
853
+ {
854
+ "expr": "max by (product, probe) (probe_success{product!=\"\"})",
855
+ "legendFormat": "{{product}} from {{probe}}",
856
+ "refId": "A"
857
+ }
858
+ ]
704
859
  }
705
860
  ]
706
861
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zigordev/stack",
3
- "version": "1.8.0",
3
+ "version": "1.9.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",