Goofing around with a POC Go -> Logstash setup
This commit is contained in:
parent
fa0de5c394
commit
7673a09604
1
logstash/.gitignore
vendored
Normal file
1
logstash/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/agent/lib/
|
2
logstash/Makefile
Normal file
2
logstash/Makefile
Normal file
@ -0,0 +1,2 @@
|
||||
run-crispy:
|
||||
go run crispy/main.go
|
19
logstash/agent/Makefile
Normal file
19
logstash/agent/Makefile
Normal file
@ -0,0 +1,19 @@
|
||||
LOGSTASH_VERSION ?= 1.1.13
|
||||
|
||||
all: lib/logstash.jar
|
||||
|
||||
|
||||
lib/logstash.jar: lib/logstash-$(LOGSTASH_VERSION)-flatjar.jar
|
||||
pushd lib && ln -sv $(notdir $^) $(notdir $@) ; popd
|
||||
|
||||
|
||||
lib/logstash-$(LOGSTASH_VERSION)-flatjar.jar: lib
|
||||
pushd lib && \
|
||||
curl -L -O http://logstash.objects.dreamhost.com/release/logstash-$(LOGSTASH_VERSION)-flatjar.jar ; \
|
||||
popd
|
||||
|
||||
lib:
|
||||
mkdir -p $@
|
||||
|
||||
run-agent: all
|
||||
java -jar lib/logstash.jar agent -f conf/shipper.conf
|
14
logstash/agent/conf/shipper.conf
Normal file
14
logstash/agent/conf/shipper.conf
Normal file
@ -0,0 +1,14 @@
|
||||
input {
|
||||
tcp {
|
||||
message_format => "json"
|
||||
port => 55784
|
||||
type => "fried"
|
||||
}
|
||||
}
|
||||
|
||||
output {
|
||||
stdout {
|
||||
debug => true
|
||||
debug_format => "json"
|
||||
}
|
||||
}
|
32
logstash/crispy/main.go
Normal file
32
logstash/crispy/main.go
Normal file
@ -0,0 +1,32 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
server := newCrispyServer()
|
||||
http.Handle("/", server)
|
||||
log.Printf("Serving on :9764 with %+v\n", server)
|
||||
log.Fatal(http.ListenAndServe(":9764", nil))
|
||||
}
|
||||
|
||||
type crispyServer struct {
|
||||
logstasher *log.Logger
|
||||
}
|
||||
|
||||
func newCrispyServer() *crispyServer {
|
||||
return &crispyServer{
|
||||
logstasher: newLogstashLogger(),
|
||||
}
|
||||
}
|
||||
|
||||
func (me *crispyServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
me.logstasher.Printf("%+v\n", r)
|
||||
}
|
||||
|
||||
func newLogstashLogger() *log.Logger {
|
||||
return log.New(os.Stderr, "", 0)
|
||||
}
|
Loading…
Reference in New Issue
Block a user