Pro Yearly is on sale from $80 to $50! »

Berlin 2013 - Riemann Workshop - Pierre-Yves Ritschard

0580d500edfdb2e5e80e4732ac8df1ea?s=47 Monitorama
September 20, 2013
540

Berlin 2013 - Riemann Workshop - Pierre-Yves Ritschard

0580d500edfdb2e5e80e4732ac8df1ea?s=128

Monitorama

September 20, 2013
Tweet

Transcript

  1. @pyr

  2. https://github.com/pyr

  3. • Riemann concepts • In-app events • System metrics •

    Just enough clojure • Common use cases Agenda
  4. Event stream processor • Process • Analyze • React

  5. None
  6. {:host “foo1” :service “cpu %” :metric 50.85 :state “ok” :description

    “System CPU gauge”}
  7. Where do events come from • Your app • Collectd

    • Riemann-health • Logstash
  8. import bernhard c = bernhard.Client() c.send({‘host’: “appserver”, ‘service’: “sql query

    time”, ‘metric’: 200})
  9. require ‘riemann/client’ c = Riemann::Client.new c << {host: “appserver”, service:

    “sql query time”, metric: 200}
  10. LoadPlugin write_riemann <Plugin write_riemann> <Node “main”> Host “riemann-host” </Node> </Plugin>

  11. Event lifecycle • Enters riemann • Follows streams • Optionally

    indexed
  12. Looking at events • Queries • Dashboard

  13. require ‘riemann/client’ c = Riemann::Client.new c[‘true’] c[‘service = “cpu”’] c[‘tagged

    “web-servers”’]
  14. Configuration API Features • Percentiles • EWMA • Fixed /

    Moving event windows • Event coalescing • Many more
  15. Configuration • Configuration is code • Code is in clojure

  16. Clojure

  17. Clojure • Functional Lisp • Immutable • Data first, not

    objects first • Lazy • Concurrent
  18. Clojure (defn hello [name] (println “hello” name) (def a-map {:some-key

    “some value”}) (def an-array [0 1 2 :foo]) (def a-set #{:a :b :c}) (def a-pattern #”^(.*)[ \t]+=(.*)[ \t]+$”) (def inline-fn #(+ 3 %)) (def anon-fn (fn [a b] (+ a b)))
  19. Clojure (defn greeter [greeting] (fn [name] (println greeting “, “

    name))) (let [german-greeting (greeter “Hallo”)] (german-greeting “Rich”))
  20. Clojure (let [m {:foo 0 :bar 1} a [3 2

    1 0]] (conj a 4) ;; => (4 3 2 1 0) (assoc m :baz 2)) ;; => {:foo 0 :bar 1 :baz 2}
  21. Clojure (ns my-sql-query-ns (:require [clojure.data.jdbc :as jdbc] [clojure.data.jdbc.sql :as sql]))

    (jdbc/query mysql-db (sql/select * :users)) ;;=> ({:login “root” :uid 0} {:login :daemon :uid 1})
  22. Clojure (def lotsa-ones (repeat 1)) ;; => lazy-seq (take 5

    lotsa-ones) ;; => (1 1 1 1 1) (take 2 (interleave lotsa-ones (repeat 2))) ;; => (1 2)
  23. Clojure (def requests (atom 0)) (swap! requests inc) @request ;;

    => 1 (def user1 (ref 10)) (def user2 (ref 50)) (dosync (alter user1 + 10) (alter user2 - 10)) @user1 ;; => 20 @user2 ;; => 40
  24. Clojure (def users {:alice {:balance 10} :bob {:balance 5}}) (defn

    transaction [from to amount] (-> users (update-in [from :balance] - amount) (update-in [to :balance] + amount)))
  25. Index (def index (default {:ttl 60 :state “ok”} (update-index (index))))

  26. Streams (let [index (default {:ttl 60 :state “ok”} (update-index (index)))]

    (streams index))
  27. Streams (let [index (default {:ttl 60 :state “ok”} (update-index (index)))

    email (mailer {:from “riemann@production”})] (streams index (where (state “critical”) email) ))
  28. Demo!