Skip to content

Instantly share code, notes, and snippets.

View fsampaio's full-sized avatar

Fernando Sampaio fsampaio

View GitHub Profile
when CLIENT_ACCEPTED {
set hsl [HSL::open -proto TCP -pool ##DST-POOLNAME##]
# log local0. "[IP::client_addr]:[TCP::client_port]: New hsl: $hsl"
}
when HTTP_REQUEST {
HTTP::header insert X-Forwarded-For [IP::client_addr]
# Check for POST requests
if {[HTTP::method] eq "POST"}{
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
@fsampaio
fsampaio / me.json
Last active October 8, 2017 04:17
{
"basics": {
"name": "Fernando Sampaio",
"label": "Systems Engineer|Devops",
"location": {
"city": "Sao Paulo",
"countryCode": "BR"
},
"profiles": [
{
log_format access_json '{ "@timestamp": "$time_iso8601", '
'"remotehost": "$remote_addr", '
'"@version": "1", '
'"user": "$remote_user", '
'"bytes": "$body_bytes_sent", '
'"duration": "$request_time", '
'"upstream_response_time": "$upstream_response_time", '
'"upstream_cache_status": "$upstream_cache_status", '
'"status": "$status", '
@fsampaio
fsampaio / gist:18a76641923b2215ff77
Created November 11, 2015 20:13
haproxy chef search
template '/etc/haproxy/haproxy.cfg' do
source 'haproxy.cfg.erb'
owner 'root'
group 'root'
variables({
nodes_site: search(:node, 'role:web-site').sort_by{ |n| n.name },
nodes_cache: search(:node, 'role:web-cache').sort_by{ |n| n.name },
nodes_blog: search(:node, 'role:web-blog').sort_by{ |n| n.name },
nodes_images: search(:node, 'role:web-images').sort_by{ |n| n.name },
nodes_adm: search(:node, 'role:web-adm').sort_by{ |n| n.name },
@fsampaio
fsampaio / gist:8fac879562af2938ddc4
Created November 11, 2015 13:37
PHP Error Logstash - GROK
if [type] == "php-error" {
grok {
match => [ "message", "\[%{MONTHDAY:day}-%{MONTH:month}-%{YEAR:year} %{TIME:time} %{WORD:zone}/%{WORD:country}\] PHP %{DATA:level}\: %{GREEDYDATA:error}" ]
add_field => { "timestamp" => "%{day}-%{month}-%{year} %{time} %{zone}/%{country}" }
add_tag => [ "%{level}" ]
remove_field => [ "day", "month", "year", "time", "zone", "country" ]
}
multiline {
pattern => "(Stack trace:)|(^#.+)|(^\"\")|( thrown+)|(^\s)"
what => "previous"
@fsampaio
fsampaio / gist:428b1c42e8ae316e94fd
Created November 11, 2015 13:36
Nginx saving log in JSON format.
log_format access_json '{ "@timestamp": "$time_iso8601", '
'"remotehost": "$remote_addr", '
'"@version": "1", '
'"user": "$remote_user", '
'"bytes": "$body_bytes_sent", '
'"duration": "$request_time", '
'"upstream_response_time": "$upstream_response_time", '
'"status": "$status", '
'"vhost": "$host", '
'"pipelined": "$pipe", '
@fsampaio
fsampaio / gist:7562917
Created November 20, 2013 13:09
My mapping in elasticsearch.
curl -XPUT http://HOST:9200/_template/logstash_per_index -d '
{
"template" : "logstash*",
"mappings" : {
"logs" : {
"properties": {
"@timestamp":{"type":"date",
"format":"dateOptionalTime"},
"@version":{"type":"string"},
"vhost":{"type":"string"},
@fsampaio
fsampaio / logformat
Created November 20, 2013 13:08
Apache LogFormat in json to use in logstash
LogFormat "{ \
\"@timestamp\": \"%{%Y-%m-%dT%H:%M:%S%z}t\", \
\"@version\": \"1\", \
\"vhost\":[\"%v\"], \
\"remotehost\": \"%h\", \
\"xforwarded\": \"%{X-Forwarded-For}i\", \
\"user\": \"%u\", \
\"duration\": %D, \
\"status\": %>s, \
\"request\": \"%U%q\", \