Skip to content

Instantly share code, notes, and snippets.

@amokrushin
Forked from barroco/raven-shell
Created June 7, 2021 12:43
Show Gist options
  • Select an option

  • Save amokrushin/d01c84661678847570236bc154d4528b to your computer and use it in GitHub Desktop.

Select an option

Save amokrushin/d01c84661678847570236bc154d4528b to your computer and use it in GitHub Desktop.
Send Sentry error from shell using curl
#!/bin/sh
SENTRY_KEY=
SENTRY_PROJECTID=
SENTRY_HOST=
SCRIPT_ARGUMENTS=$@
MESSAGE=$1
EVENT_ID=`openssl rand -hex 32`
EVENT_TIMESTAMP=$(date --utc +"%Y-%m-%dT%H:%M:%S")
SENTRY_TIMESTAMP=$(date +%s)
curl --data "{
\"event_id\": \"$EVENT_ID\",
\"culprit\": \"$0\",
\"timestamp\": \"$EVENT_TIMESTAMP\",
\"message\": \"$MESSAGE\",
\"tags\": {
\"shell\": \"$SHELL\",
\"server_name\": \"`hostname`\",
\"path\": \"`pwd`\"
},
\"exception\": [{
\"type\": \"ScriptError\",
\"value\": \"$MESSAGE\",
\"module\": \"__builtins__\"
}],
\"extra\": {
\"sys.argv\": \"$SCRIPT_ARGUMENTS\"
}
}" \
-H "Content-Type: application/json" \
-H "X-Sentry-Auth: Sentry sentry_version=7, sentry_timestamp=$SENTRY_TIMESTAMP, \
sentry_key=$SENTRY_KEY, sentry_client=test-curl/0.1" \
"https://$SENTRY_KEY@$SENTRY_HOST/api/$SENTRY_PROJECTID/store/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment