Skip to content

Instantly share code, notes, and snippets.

View davidbirdsong's full-sized avatar

david birdsong davidbirdsong

  • san francisco, ca
View GitHub Profile
@davidbirdsong
davidbirdsong / snappy_heka_plugin
Created January 31, 2014 22:57
heka plugin error
[100%] Built target mocks
Scanning dependencies of target hekad
heka/src/github.com/mozilla-services/heka/cmd/hekad/plugin_loader.go:4:3: no buildable Go source files in /dev/shm/loko_build_david.vrTUfh/SRCDIR/heka/build/heka/src/code.google.com/p/snappy-go
@davidbirdsong
davidbirdsong / heka_toto_fail
Created January 31, 2014 23:08
plugin_loader.go bails on our plugin
heka/src/github.com/mozilla-services/heka/cmd/hekad/plugin_loader.go:12:3: no buildable Go source files in /dev/shm/loko_build_david.vrTUfh/SRCDIR/heka/build/heka/src/github.com/zebrafishlabs/golang
@davidbirdsong
davidbirdsong / protobuf_using_decoder_heka
Created February 8, 2014 06:48
decoder based protobuf Marshal
//ev.Event.Value is []byte array from kakfa
messageLen := len(ev.Event.Value)
if messageLen > cap(pack.MsgBytes) {
pack.MsgBytes = make([]byte, messageLen)
}
copy(pack.MsgBytes, ev.Event.Value)
dRunner.InChan() <- pack
}
@davidbirdsong
davidbirdsong / heka_proto_unmarshal
Created February 8, 2014 06:51
heka protobuf directly from proto.Unmarshal
//ev.Event.Value is []byte from kafka
err = proto.Unmarshal(ev.Event.Value, pack.Message)
if err != nil {
ir.LogError(err)
pack.Recycle()
ev.Recycle()
continue
}
pack.Decoded = true
@davidbirdsong
davidbirdsong / json_to_jmx
Created March 4, 2014 21:10
create jmx json file
{% set config = dict(servers=list()) %}
{% for kserver in groups['kafka_' + coloc] %}
{% for query in kafkagraphitequeries %}
{% set q = dict(host=kserver, port= kafka[coloc].jmx_port, outputWriters=kafkagraphiteoutput) %}
{% do config.servers.append(q) %}
{% endfor %}
{% endfor %}
{% config|to_nice_json %}
---
jmxtrans:
logdir: /data/log/jmxtrans
jsondir: /data/appdata/jmxtrans/json
kafkagraphiteoutput:
"@class": "com.googlecode.jmxtrans.model.output.GraphiteWriter"
settings:
host: localhost
@davidbirdsong
davidbirdsong / go_reg
Created March 7, 2014 12:22
go regexp for a whirl
package main
import (
"regexp"
"fmt"
)
var reg string = `^(?P<RemoteIP>\S+) \S+ \S+ \[(?P<Timestamp>[^\]]+)\] "(?P<Method>[A-Z]+) (?P<Url>[^\s]+)[^"]*" (?P<StatusCode>\d+) (?P<RequestSize>\d+)`
var line string = "65.32.144.5 - - [07/Mar/2014:15:36:34 +0400] \"POST /api/listAddresses HTTP/1.1\" 200 290"
func main() {
@davidbirdsong
davidbirdsong / carbon_listener
Last active August 29, 2015 13:57
udp/tcp token payload
[localcarbon_udp]
type = "UdpInput"
address = "127.0.0.1:2203"
decoder = "carbon_line_decoder"
parser_type = "token"
[localcarbon_tcp]
type = "TcpInput"
address = "127.0.0.1:2203"
decoder = "carbon_line_decoder"
@davidbirdsong
davidbirdsong / haproxy_tls_heka
Created March 9, 2014 04:02
switch between tls and raw tcp based on a small inspection
frontend hekad-server
bind :30514
mode tcp
option contstats
tcp-request inspect-delay 10s
tcp-request content accept if { req.ssl_ver gt 0 }
tcp-request content accept if { src 10.0.0.0/8 }
tcp-request content accept if { src 127.0.0.1 }
tcp-request content reject
ngx.req.read_body()
-- do the work to find body file on disk
ngx.req.set_body_file(putfile, true)
res = ngx.location.capture("/location_that_proxies", {method = ngx.HTTP_PUT})