Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 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
5 changes: 5 additions & 0 deletions pillar/dev/secrets/sentry.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
secrets:
sentry:
project_id: 0123456789012345
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

'backup-server':
- match: nodegroup
Expand Down
26 changes: 16 additions & 10 deletions salt/base/auto-highstate.sls
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
{% set dms_token = salt["pillar.get"]("deadmanssnitch:token") %}
{% set sentry_enabled = salt["pillar.get"]("secrets:sentry:project_id") and salt["pillar.get"]("secrets:sentry:project_key") and salt["pillar.get"]("secrets:sentry:ingest_url") %}

curl:
pkg.installed

/usr/local/bin/sentry-checkin.sh:
file.managed:
- source: salt://base/scripts/sentry-checkin.sh
- mode: '0755'
- user: root
- group: root

{% 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

MINION_ID=$(salt-call --local grains.get id --out=newline_values_only)
SENTRY_INGEST_URL=$(salt-call pillar.get secrets:sentry:ingest_url --out=newline_values_only)
SENTRY_PROJECT_ID=$(salt-call pillar.get secrets:sentry:project_id --out=newline_values_only)
SENTRY_PROJECT_KEY=$(salt-call pillar.get secrets:sentry:project_key --out=newline_values_only)

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
Loading