Created
November 7, 2013 11:28
-
-
Save mavnn/7353155 to your computer and use it in GitHub Desktop.
Pipe logs to Riemann
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module RiemannStore = | |
| open System | |
| open System.Configuration | |
| open Riemann | |
| let client = new Client(riemannServer, riemannPort) | |
| let state entry = | |
| match entry.Level with | |
| | Debug -> "ok" | |
| | Warn -> "warning" | |
| | Error -> "error" | |
| let description entry = | |
| seq { | |
| yield sprintf "Message: %s" entry.Data.Message | |
| yield sprintf "Host: %s" entry.Source.Host | |
| yield sprintf "Timestamp: %s" <| entry.Timestamp.ToString() | |
| match entry.Data.Exception with | |
| | Some e -> | |
| yield "" | |
| yield e.Message | |
| yield e.StackTrace | |
| | None -> () | |
| } |> String.concat "\n" | |
| let logEntry entry = | |
| using (client.Tag(entry.Source.Host)) | |
| (fun _ -> client.SendEvent("log " + entry.Source.Category, state entry, description entry, float32 1.0)) | |
| let createRiemannStore = | |
| { Store.Set = logEntry | |
| Store.Flush = ignore } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment