@zigordev/stack 1.8.1 → 1.10.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
@@ -178,9 +178,9 @@ KAFKA_SETUP: |
178
178
 
179
179
  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. In production an app's password lives once, at its own `/<product>/KAFKA_PASSWORD` in Parameter Store. A line of `.env.production.example` names it, such as `KAFKA_PASSWORD_NOTIFICATIONS_API=/notifications/KAFKA_PASSWORD`, and the host's deploy reads it from there. [Record 0028](../docs/adr/0028-the-shared-services-read-each-apps-kafka-password-from-the-apps-own-parameter.md) says why.
180
180
 
181
- `KAFKA_SETUP` holds one user today, `notifications-api`, the notifications service. It reads every app's requests and writes every app's answers, through three prefixed rules that never change when an app joins. On the laptop its password is `local-only-notifications-api`.
181
+ `KAFKA_SETUP` holds two users today. `notifications-api`, the notifications service, reads every app's requests and writes every app's answers, through three prefixed rules that never change when an app joins. `playground-api`, the playground's API, writes its email requests, reads their answers in its own groups, and sets a bad answer aside, through four rules of its own. On the laptop their passwords are `local-only-notifications-api` and `local-only-playground-api`, and in production the playground's lives at `/playground/KAFKA_PASSWORD`.
182
182
 
183
- `KAFKA_SETUP` also holds the four topics of every app that sends email, the template's too, and the service's right to set a bad request aside on each app's requests' dead-letter topic. The notifications service reads the requests topic of every app in its producer list, which ships in its image, wherever it runs. One missing topic stops it reading any, so every producer's topics exist on every broker.
183
+ `KAFKA_SETUP` also holds the four topics of every app that sends email, the template's and the playground's too, and the service's right to set a bad request aside on each app's requests' dead-letter topic. The notifications service reads the requests topic of every app in its producer list, which ships in its image, wherever it runs. One missing topic stops it reading any, so every producer's topics exist on every broker.
184
184
 
185
185
  On the laptop the job reads a second list after `KAFKA_SETUP`: `KAFKA_SETUP_LAPTOP`, in `compose.local.yaml`, for users that only a laptop needs. Production never sets it. It holds one user today, `template-api`, the product template's API, which sends its emails through the notifications service and never deploys. Its topics are in `KAFKA_SETUP`, so in production nobody can write to them. Its throwaway password is `local-only-template-api`.
186
186
 
@@ -52,6 +52,7 @@ services:
52
52
  allow template-api Write topic notifications.outcomes.template-api.dead-letter
53
53
  allow template-api Read group template-api. prefixed
54
54
  KAFKA_PASSWORD_NOTIFICATIONS_API: local-only-notifications-api
55
+ KAFKA_PASSWORD_PLAYGROUND_API: local-only-playground-api
55
56
  KAFKA_PASSWORD_TEMPLATE_API: local-only-template-api
56
57
 
57
58
  lgtm:
package/compose.yaml CHANGED
@@ -421,6 +421,16 @@ services:
421
421
  topic notifications.outcomes.template-api 1
422
422
  topic notifications.outcomes.template-api.dead-letter 1
423
423
  allow notifications-api Write topic notifications.requests.template-api.dead-letter
424
+ topic notifications.requests.playground-api 1
425
+ topic notifications.requests.playground-api.dead-letter 1
426
+ topic notifications.outcomes.playground-api 1
427
+ topic notifications.outcomes.playground-api.dead-letter 1
428
+ allow notifications-api Write topic notifications.requests.playground-api.dead-letter
429
+ user playground-api
430
+ allow playground-api Write topic notifications.requests.playground-api
431
+ allow playground-api Read topic notifications.outcomes.playground-api
432
+ allow playground-api Write topic notifications.outcomes.playground-api.dead-letter
433
+ allow playground-api Read group playground-api. prefixed
424
434
  tmpfs:
425
435
  - /tmp
426
436
  - /opt/kafka/logs:uid=1000,gid=1000
@@ -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.1",
3
+ "version": "1.10.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",
@@ -20,7 +20,7 @@
20
20
  "devDependencies": {
21
21
  "@types/node": "26.6.10",
22
22
  "typescript": "7.0.2",
23
- "vitest": "5.1.1"
23
+ "vitest": "5.1.2"
24
24
  },
25
25
  "publishConfig": {
26
26
  "access": "public"