Skip to content

Instantly share code, notes, and snippets.

View atrepca's full-sized avatar

Alex Trepca atrepca

View GitHub Profile
@atrepca
atrepca / gist:7159195
Last active December 4, 2023 21:28
Send Heroku logs to an rsyslog server and save them to separate files by application
  • Add a Heroku drain for your app to forward the logs to your rsyslog server:

      heroku drains:add --app my-prod-app syslog://logging01.prod.mydomain.net:514
    
  • List the drain you just created to get the unique Drain ID:

      heroku drains -x --app my-prod-app
    
  • On the rsyslog server save the logs coming from Heroku to separate files, without duplicating to /var/log/messages (thanks to the & ~). Create a /etc/rsyslog.d/90-heroku.conf file containing:

      if $HOSTNAME startswith 'Drain_ID' then /opt/log/heroku/my-prod-app.log
    

& ~

#!/bin/bash
#
# SOURCE: this is an adaptation of the following gists:
# * https://gist.github.com/rodw/3073987 - original
# * https://gist.github.com/bjtitus/8851816 - modification of the original /w pagination for more than 30 repos
#
# SCOPE: backup an organization's GitHub repositories with issues and wikis
#
# Uses the GitHub API to pull down the list of repos & clone them
#
@atrepca
atrepca / ec2tags.sh
Last active August 29, 2015 14:12
Create custom Puppet fact from AWS EC2 instance tags
#!/bin/bash
# Requirements:
# * aws-cli: https://github.com/aws/aws-cli
# * IAM roles or aws access key and secret in place
TAG_NAME="mytag"
INSTANCE_ID="$(/usr/bin/curl -s http://instance-data/latest/meta-data/instance-id)"
REGION="$(/usr/bin/curl -s http://instance-data/latest/meta-data/placement/availability-zone | /bin/sed -e 's/[a-z]$//')"
TAG_VALUE="$(/usr/local/bin/aws ec2 describe-tags --filters "Name=resource-id,Values=${INSTANCE_ID}" "Name=key,Values=${TAG_NAME}" --region ${REGION} --output=text | /usr/bin/cut -f5)"
echo "mytag_fact=${TAG_VALUE}"
@atrepca
atrepca / kafka.service
Created September 27, 2016 13:53
Kafka Systemd Service Configuration File for Ubuntu 16.04
[Unit]
Description=Apache Kafka server (broker)
Documentation=http://kafka.apache.org/documentation.html
Requires=network.target remote-fs.target
After=network.target remote-fs.target
[Service]
Type=simple
PIDFile=/var/run/kafka.pid
User=kafka