├── riemann.config ├── main.clj ├── riemann.config.tmpl ├── README.md └── Dockerfile /riemann.config: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /main.clj: -------------------------------------------------------------------------------- 1 | ; here it goes!! :-)o 2 | 3 | ;print events to the log 4 | (streams prn 5 | #(info %)) 6 | 7 | ; emails francisco for any critical event on http production services 8 | ; (let [email (mailer {:from "francisco.cabrita@gmail.com"})] 9 | ; (streams 10 | ; (where (and (tagged "prod") 11 | ; (service #"http") 12 | ; (state "critical")) 13 | ; (email "francisco.cabrita@gmail.com")))) 14 | -------------------------------------------------------------------------------- /riemann.config.tmpl: -------------------------------------------------------------------------------- 1 | ; -*- mode: clojure; -*- 2 | ; vim: filetype=clojure 3 | 4 | (logging/init {:file "riemann.log"}) 5 | 6 | ; Listen on the local interface over TCP (5555), UDP (5555), and websockets 7 | ; (5556) 8 | (let [host "{{ if .Env.HOST }}{{ .Env.HOST }}{{ else }}0.0.0.0{{ end }}"] 9 | (udp-server {:host host :port {{ if .Env.UDP_PORT }}{{ .Env.UDP_PORT }}{{ else }}5555{{ end }}}) 10 | (tcp-server {:host host :port {{ if .Env.TCP_PORT }}{{ .Env.TCP_PORT }}{{ else }}5555{{ end }}}) 11 | (ws-server {:host host :port {{ if .Env.WSE_PORT }}{{ .Env.WSE_PORT }}{{ else }}5556{{ end }}})) 12 | 13 | ; Expire old events from the index every 5 seconds. 14 | (periodically-expire 5) 15 | 16 | (let [index (index)] 17 | ; Inbound events will be passed to these streams: 18 | (streams 19 | (default :ttl 60 20 | ; Index all events immediately. 21 | index 22 | 23 | ; Log expired events. 24 | (expired 25 | (fn [event] (info "expired" event)))))) 26 | 27 | {{ if .Env.CONFDIR }} 28 | ; Shipping your custom Riemann configurations within docker: 29 | (include "{{ .Env.CONFDIR }}") 30 | {{end}} 31 | 32 | {{ if .Env.VOLDIR }} 33 | ; Mounting a volume with your custom Riemann configurations: 34 | (include "{{ .Env.VOLDIR }}") 35 | {{end}} 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Run it 2 | 3 | Riemann relies on a configuration file ```riemann.config```. 4 | This is the starting point, where global configurations are set. Because I 5 | don't like huge files and I like to keep things simple, I want to define a 6 | directory where I load all my custom Riemann configurations. 7 | 8 | We have two distint ways of doing so... 9 | 10 | Shipping your custom Riemann configurations within docker: 11 | 12 | ```sh 13 | docker run -d \ 14 | -p 5555:5555/udp \ 15 | -p 5555:5555/tcp \ 16 | -p 5556:5556/tcp \ 17 | -e UDP_PORT=5555 \ 18 | -e TCP_PORT=5555 \ 19 | -e WSE_PORT=5556 \ 20 | -e HOST=0.0.0.0 \ 21 | -e CONFDIR=/app/etc \ 22 | include/docker-riemann 23 | ``` 24 | 25 | Or mounting a volume with your custom Riemann configurations: 26 | 27 | ```sh 28 | docker run -d \ 29 | -p 5555:5555/udp \ 30 | -p 5555:5555/tcp \ 31 | -p 5556:5556/tcp \ 32 | -e UDP_PORT=5555 \ 33 | -e TCP_PORT=5555 \ 34 | -e WSE_PORT=5556 \ 35 | -e HOST=0.0.0.0 \ 36 | -e VOLUME="/path-to-volume" \ 37 | -v /path-to-volume:/path-to-volume \ 38 | include/docker-riemann 39 | ``` 40 | 41 | Both ways will configure properly ```riemann.config```. 42 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | MAINTAINER include 3 | 4 | ENV DEBIAN_FRONTEND noninteractive 5 | ENV DOCKERIZE_VERSION "0.0.3" 6 | ENV RIEMANN_VERSION "0.2.10" 7 | 8 | RUN apt-get -yq update && \ 9 | apt-get -yq install default-jre-headless && \ 10 | apt-get clean -y && \ 11 | apt-get autoremove -y 12 | 13 | ADD https://github.com/jwilder/dockerize/releases/download/v${DOCKERIZE_VERSION}/dockerize-linux-amd64-v${DOCKERIZE_VERSION}.tar.gz \ 14 | /dockerize-linux-amd64-v${DOCKERIZE_VERSION}.tar.gz 15 | 16 | ADD http://aphyr.com/riemann/riemann-${RIEMANN_VERSION}.tar.bz2 \ 17 | /riemann-${RIEMANN_VERSION}.tar.bz2 18 | 19 | RUN mkdir -p /app/etc && \ 20 | tar xjvf riemann-${RIEMANN_VERSION}.tar.bz2 -C /app && \ 21 | tar xzvf /dockerize-linux-amd64-v${DOCKERIZE_VERSION}.tar.gz -C /usr/local/bin && \ 22 | rm riemann-*.tar.bz2 dockerize-linux-amd64-v*.tar.gz 23 | 24 | EXPOSE 5555/udp 25 | EXPOSE 5555/tcp 26 | EXPOSE 5556/tcp 27 | 28 | WORKDIR /app/riemann-${RIEMANN_VERSION} 29 | 30 | ADD riemann.config.tmpl /app/riemann-${RIEMANN_VERSION}/etc/riemann.config.tmpl 31 | ADD main.clj /app/etc/main.clj 32 | 33 | ENTRYPOINT [ "dockerize", "-template", "/app/riemann-0.2.10/etc/riemann.config.tmpl:/app/riemann-0.2.10/etc/riemann.config"] 34 | 35 | CMD ["/app/riemann-0.2.10/bin/riemann", "/app/riemann-0.2.10/etc/riemann.config"] 36 | --------------------------------------------------------------------------------