Skip to content

Instantly share code, notes, and snippets.

View cgswong's full-sized avatar

Stuart Wong cgswong

View GitHub Profile
@cgswong
cgswong / consul-registrator-query.md
Created March 13, 2015 02:27
consul/registrator querying

Query Consul directly to see if Registrator registered the services in Consul: curl http://<Consul server IP address>:8500/v1/catalog/services | python -m json.tool

Provide JSON-formatted output that lists all the instances of a service across a consul/registrator cluster, the IP addresses and nodes associated with the service, and any metadata (which probably won’t exist).

curl http://:8500/v1/catalog/service/nginx-80 | python -m json.tool

@cgswong
cgswong / logstash-logspout.conf
Last active August 29, 2015 14:17
Basic logstash configuration for logspout
input {
tcp {
port => 5000
type => "dockerlog"
}
udp {
port => 5000
type => "dockerlog"
}
}
@cgswong
cgswong / logstash-test.conf
Last active August 29, 2015 14:18
Logstash Test config
# Where to get input
input {
# Get input from syslog
tcp {
port => 5514
type => "syslog"
}
udp {
port => 5514
type => "syslog"
@cgswong
cgswong / kibana.conf
Created May 20, 2015 16:20
nginx configuration for Kibana 4
upstream kibana {
server 127.0.0.1:5601 fail_timeout=0;
}
server {
listen 80;
return 301 https://example.com;
}
server {
@cgswong
cgswong / docker-cleaner.sh
Created May 20, 2015 16:42
Docker container cleanup
#! /bin/bash
echo "Removing exited docker containers..."
docker rm -v $(docker ps -a -f status=exited -q)
echo "Removing untagged images..."
docker rmi $(docker images --no-trunc | grep "<none>" | awk '{print $3}')
echo "Removing unused docker images"
images=($(docker images | awk '{print $1":"$2}'))
@cgswong
cgswong / docker-cleaner.py
Created May 20, 2015 16:43
docker cleaner
#!/usr/bin/env python3
# Copyright 2015 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@cgswong
cgswong / logstash-syslog-filter.conf
Last active December 18, 2021 20:30
Logstash syslog parser
# syslog/relp
grok {
match => { "@message" => "(?:%{INT:syslog6587_msglen} )?<%{POSINT:syslog_pri}>(?:%{NONNEGINT:syslog5424_ver} )?(?:%{SYSLOGTIMESTAMP:syslog_timestamp}|%{TIMESTAMP_ISO8601:syslog_timestamp}) %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?(:)? %{GREEDYDATA:syslog_message}" }
add_field => [ "received_at", "%{@timestamp}" ]
add_field => [ "received_from", "%{host}" ]
add_tag => [ "syslog_standard" ]
tag_on_failure => ["_grokparsefailure-syslog_standard"]
}
@cgswong
cgswong / logstash-http.conf
Created June 16, 2015 17:50
Logstash web log configuration
# #####################################################################
# DESC: Logstash configuration file. Typically forwarding logs to
# Elasticsearch instance.
# #####################################################################
# Where to get input
input {
# Get input from Apache logs
file {
type => "apache-access"
@cgswong
cgswong / logstash-msg.conf
Last active August 29, 2015 14:23
Logstash message queue config
# #####################################################################
# DESC: Logstash configuration file. Typically forwarding logs to
# Elasticsearch instance.
# #####################################################################
# Where to get input
input {
# Get input from Redis queue
redis {
data_type => "list"
@cgswong
cgswong / bootstrap_marathon.sh
Created June 29, 2015 15:47
Marathon startup
#!/bin/bash
# Set locale: this is required by the standard Mesos startup scripts
echo "info: Setting locale to en_US.UTF-8..."
locale-gen en_US.UTF-8 > /dev/null 2>&1
# Start syslog if not started....
echo "info: Starting syslog..."
service rsyslog start > /dev/null 2>&1