Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
813055a
feat: replace dms with sentry monitors
JacobCoffee Jun 2, 2025
ec0cda0
chore: add more helpful debugging if error
JacobCoffee Jun 3, 2025
e86175f
fix: remove fqdn separators, use key and ids instead of names
JacobCoffee Jun 3, 2025
602a03d
feat: use script to run highstate if sentry key present
JacobCoffee Jun 3, 2025
b9da2e2
chore: less of a git diff
JacobCoffee Jun 3, 2025
cd93ea1
fix: dont use local
JacobCoffee Jun 3, 2025
0bca8db
chore: less of a git diff
JacobCoffee Jun 3, 2025
b62711a
chore: undo (inactive) token commit
JacobCoffee Jun 3, 2025
62984d3
docs: notate what scopes are needed for monitor upserts
JacobCoffee Jun 3, 2025
61eb5d6
fix: resolve issue with duplicate monitor creation by locking file
JacobCoffee Jun 3, 2025
cb11aa2
fix: the script needs curl but its not on vagrant
JacobCoffee Jun 3, 2025
af7142a
Merge branch 'main' into sentry-monitors
JacobCoffee Jun 3, 2025
1456a65
feat: simplify
JacobCoffee Jun 4, 2025
4351d0e
chore: uv run tox -e lint
JacobCoffee Jun 10, 2025
130b807
feat: use tempalte instead of making 4 salt-calls!
JacobCoffee Jun 10, 2025
034cb26
chore: removing nesting in pillar data
JacobCoffee Jun 10, 2025
e881dd8
Merge branch 'main' into sentry-monitors
JacobCoffee Jun 10, 2025
83d93cf
fix: make sure we dont run sentry things if disabled
JacobCoffee Jun 10, 2025
fc7c48f
chore: clean up DMS
JacobCoffee Jun 10, 2025
4003034
docs: add sentry
JacobCoffee Jun 10, 2025
9a736fe
fix(docs): trim wording
JacobCoffee Jun 10, 2025
9368b07
chore: turn off secrets.sentry if in dev by default, add note
JacobCoffee Jun 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/guides/migration-recipe.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ index 68387c9..7a8ace1 100644
sudo service nginx stop
```
```{note}
Don't forget to pause service checks for both the old and new hosts in things like Dead Man's Snitch, Pingdom, etc.
Don't forget to pause service checks for both the old and new hosts in things like Sentry monitors, Pingdom, etc.
```
4. Ensure that any additional volumes are mounted and in the correct location:
- Check what disks are currently mounted and where: `df`
Expand Down
5 changes: 5 additions & 0 deletions docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ Pingdom
`Pingdom <https://www.pingdom.com>`_ provides monitoring and complains to us
when services are down.

Sentry
`Sentry <https://sentry.io>`_ is used for error reporting and monitoring of
many services. It also provides Salt highstate cron monitoring, which
notifies us when runs fail over a certain threshold.

PagerDuty
`PagerDuty <https://www.pagerduty.com>`_ is used for on-call rotation for PSF
Infrastructure employees on the front-line, and volunteers as backup.
Expand Down
3 changes: 3 additions & 0 deletions pillar/dev/secrets/sentry.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
project_id: 123456789012345
project_key: deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef
ingest_url: deadbeef.ingest
1 change: 1 addition & 0 deletions pillar/dev/top.sls
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ base:
- tls
- users.*
- postgres.clusters
# - secrets.sentry # Uncomment and update sentry secrets if you want to work in dev

'backup-server':
- match: nodegroup
Expand Down
48 changes: 0 additions & 48 deletions salt/_extensions/pillar/dms.py

This file was deleted.

29 changes: 19 additions & 10 deletions salt/base/auto-highstate.sls
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
{% set dms_token = salt["pillar.get"]("deadmanssnitch:token") %}
{% set sentry_enabled = salt["pillar.get"]("project_id") and salt["pillar.get"]("project_key") and salt["pillar.get"]("ingest_url") %}

{% if sentry_enabled %}
curl:
pkg.installed

/usr/local/bin/sentry-checkin.sh:
file.managed:
- source: salt://base/scripts/sentry-checkin.sh.jinja
- template: jinja
- mode: '0755'
- user: root
- group: root
{% endif %}

{% if dms_token %}
15m-interval-highstate:
cron.present:
- identifier: 15m-interval-highstate
- name: "timeout 5m salt-call state.highstate >> /var/log/salt/cron-highstate.log 2>&1; curl https://nosnch.in/{{ dms_token }} &> /dev/null"
- minute: '*/15'
{% else %}
15m-interval-highstate:
cron.present:
- identifier: 15m-interval-highstate
- name: "timeout 5m salt-call state.highstate >> /var/log/salt/cron-highstate.log 2>&1"
- name: "{% if sentry_enabled %}/usr/local/bin/sentry-checkin.sh {% endif %}timeout 5m salt-call state.highstate >> /var/log/salt/cron-highstate.log 2>&1"
- minute: '*/15'
{% endif %}
{% if sentry_enabled %}
- require:
- file: /usr/local/bin/sentry-checkin.sh
{% endif %}

/etc/logrotate.d/salt:
{% if grains["oscodename"] == "xenial" %}
Expand Down
27 changes: 27 additions & 0 deletions salt/base/scripts/sentry-checkin.sh.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

MINION_ID="{{ grains['id'] }}"
SENTRY_INGEST_URL="{{ pillar.get('ingest_url', '') }}"
SENTRY_PROJECT_ID="{{ pillar.get('project_id', '') }}"
SENTRY_PROJECT_KEY="{{ pillar.get('project_key', '') }}"

MONITOR_SLUG="salt-highstate-${MINION_ID//./}"

if [ -n "$SENTRY_INGEST_URL" ] && [ -n "$SENTRY_PROJECT_ID" ] && [ -n "$SENTRY_PROJECT_KEY" ]; then
curl -X POST "https://${SENTRY_INGEST_URL}/api/${SENTRY_PROJECT_ID}/cron/${MONITOR_SLUG}/${SENTRY_PROJECT_KEY}/" \
--header 'Content-Type: application/json' \
--data-raw '{"monitor_config": {"schedule": {"type": "crontab", "value": "*/15 * * * *"}, "checkin_margin": 5, "max_runtime": 30, "timezone": "UTC"}, "status": "in_progress"}' &> /dev/null

"$@"
COMMAND_EXIT=$?

if [ $COMMAND_EXIT -eq 0 ]; then
curl "https://${SENTRY_INGEST_URL}/api/${SENTRY_PROJECT_ID}/cron/${MONITOR_SLUG}/${SENTRY_PROJECT_KEY}/?status=ok" &> /dev/null
else
curl "https://${SENTRY_INGEST_URL}/api/${SENTRY_PROJECT_ID}/cron/${MONITOR_SLUG}/${SENTRY_PROJECT_KEY}/?status=error" &> /dev/null
fi

exit $COMMAND_EXIT
else
exit 1
fi