Skip to content

Instantly share code, notes, and snippets.

@tegud
tegud / dynamic-log-level.js
Created May 15, 2018 18:35
dynamic log level
const requestContext = require("../request-context");
function getHeaderName(config) {
if (!config.dynamicLogLevel || !config.dynamicLogLevel.header) {
return "x-log-level";
}
return config.dynamicLogLevel.header;
}
@tegud
tegud / metrics-template.json
Created February 19, 2016 12:37
Template for using Elasticsearch as a Time Series Database
{
"metrics" : {
"order" : 0,
"template" : "metrics-*",
"settings" : {
"index" : {
"refresh_interval" : "5s"
}
},
"mappings" : {
@tegud
tegud / test.rake
Last active September 4, 2015 10:08
Test Config
namespace :tests do
task :test_config do
puts "TESTING CONFIG..."
name = ENV['IMAGE_NAME'] || raise('You must specify an IMAGE_NAME')
tag = ENV['GO_PIPELINE_LABEL'] || raise('No label specified')
docker_hub_user_or_registry = ENV['DOCKER_REGISTRY'] || ENV['DOCKER_HUB_USER'] || raise('No registry or docker hub user specified')
docker_file_location = ENV['DOCKER_FILE_LOCATION'] || "."
full_image_id = "#{docker_hub_user_or_registry}/#{name}:#{tag}"
@tegud
tegud / Dockerfile
Created September 4, 2015 10:01
Dockerfile with entrypoint
FROM logstash:1.5.4
RUN /opt/logstash/bin/plugin install logstash-filter-translate
RUN /opt/logstash/bin/plugin install logstash-filter-json_encode
RUN mkdir -p /geoip \
&& curl -SLo /geoip/GeoLiteCity.dat.gz http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz \
&& curl -SLo /geoip/GeoIPASNum.dat.gz http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz \
&& gunzip /geoip/*.gz \
&& rm -f /geoip/*.gz
@tegud
tegud / build-image.rb
Last active September 3, 2015 21:18
Rake Build Image with Tests
task :default => [ :build_image ]
task :build_image do
name = ENV['IMAGE_NAME'] || raise('You must specify an IMAGE_NAME')
tag = ENV['GO_PIPELINE_LABEL'] || raise('No label specified')
docker_hub_user_or_registry = ENV['DOCKER_REGISTRY'] || ENV['DOCKER_HUB_USER'] || raise('No registry or docker hub user specified')
docker_file_location = ENV['DOCKER_FILE_LOCATION'] || "."
full_image_id = "#{docker_hub_user_or_registry}/#{name}:#{tag}"
local_image_id = "#{name}:#{tag}"
@tegud
tegud / rake.rb
Last active September 3, 2015 19:54
Rake Build Image
task :build_image do
name = ENV['IMAGE_NAME'] || raise('You must specify an IMAGE_NAME')
tag = ENV['GO_PIPELINE_LABEL'] || raise('No label specified')
docker_hub_user_or_registry = ENV['DOCKER_REGISTRY'] || ENV['DOCKER_HUB_USER'] || raise('No registry or docker hub user specified')
docker_file_location = ENV['DOCKER_FILE_LOCATION'] || "."
full_image_id = "#{docker_hub_user_or_registry}/#{name}:#{tag}"
Dir.chdir("../../#{docker_file_location}")
@tegud
tegud / build docker.cmd
Last active September 1, 2015 13:17
Build Docker
full_image_id = "#{registry_or_docker_hub_user}/#{name}:#{tag}"
// Example: docker-registry.laterooms.com:5000/tlrg-logstash-central:7e88f94a87d90312ad315d15ab4f34a90b1daf97
sudo docker build -t #{full_image_id} .
@tegud
tegud / Dockerfile
Created September 1, 2015 13:05
Basic Dockerfile
FROM logstash:1.5.3
RUN /opt/logstash/bin/plugin install logstash-filter-translate
RUN /opt/logstash/bin/plugin install logstash-filter-json_encode
@tegud
tegud / docker-compose-logstash-1.4.2.yml
Created August 28, 2015 15:36
Docker Compose file for Logstash 1.4.2
logstash:
image: pblittle/docker-logstash
volumes:
- ./logstash-config:/opt/logstash/conf.d/
- /var/log/logstash:/var/log/logstash
- ./geoip:/opt/logstash/vendor/geoip/
- ./ssl:/opt/ssl/
@tegud
tegud / conditional-categorise.rb
Created January 25, 2015 15:07
Example of categorising urls via logstash conditionals
if [url_path] =~ /^\/status$/ {
mutate { add_tag => "health-check" }
} else if [url_path] =~ /^\/beacon\// {
mutate { add_tag => "beacon" }
} else {
mutate { add_tag => "content" }
}