Skip to content

Instantly share code, notes, and snippets.

@stympy
Last active April 6, 2024 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stympy/9ccb5a809a6731f53b3335fb4e020c2c to your computer and use it in GitHub Desktop.
Save stympy/9ccb5a809a6731f53b3335fb4e020c2c to your computer and use it in GitHub Desktop.
Honeybadger Insights config for Hatchbox.io
#!/bin/bash
if [ "$UID" == "0" ]; then
sudo_cmd=''
else
sudo_cmd='sudo'
fi
bash -c "$(curl -sL https://setup.vector.dev)"
echo -e "\033[34m\n* Installing vector package\033[0m\n"
$sudo_cmd apt-get install vector
echo -e "\033[34m\n* Configuring Vector\033[0m\n"
curl -sL https://gist.github.com/stympy/9ccb5a809a6731f53b3335fb4e020c2c/raw/376333a49fc4a862eded68cfe70c0413b81fa7bc/vector.yaml | sed "s/PUT_YOUR_HB_PROJECT_API_KEY_HERE/${HONEYBADGER_API_KEY}/" | $sudo_cmd tee /etc/vector/vector.yaml
echo -e "\033[34m\n* Starting Vector service\033[0m\n"
$sudo_cmd systemctl restart vector.service && $sudo_cmd systemctl status vector.service && $sudo_cmd systemctl enable vector.service
echo -e "\n\nAll done!\n\nIf the Vector status showed active, you are good to go, and logs should be flowing to Honeybadger Insights! If not, email support@honeybadger.io with the output of this script and we'll take a look.\n"
# Put this in /etc/vector/vector.yaml
sources:
journald:
type: journald
include_matches:
_TRANSPORT:
- stdout
# See the Vector Remap Language reference for more info: https://vrl.dev
transforms:
parse_logs:
type: "remap"
inputs: ["journald"]
source: |
. = {"host": .host, "unit": ._SYSTEMD_USER_UNIT || ._SYSTEMD_UNIT, "message": .message, "timestamp": .timestamp}
structured = parse_json(.message) ?? {}
. = merge!(., structured)
# Print parsed logs to stdout
sinks:
honeybadger:
type: "http"
inputs: ["parse_logs"]
uri: "https://api.honeybadger.io/v1/events"
request:
headers:
X-API-Key: "PUT_YOUR_HB_PROJECT_API_KEY_HERE"
encoding:
codec: "json"
framing:
method: "newline_delimited"
batch:
max_bytes: 1000000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment