-
Notifications
You must be signed in to change notification settings - Fork 25
/
Example.hs
24 lines (17 loc) · 968 Bytes
/
Example.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Monad.IO.Class (liftIO)
import System.Metrics.Prometheus.Concurrent.RegistryT
import System.Metrics.Prometheus.Http.Scrape (serveMetricsT)
import System.Metrics.Prometheus.Metric.Counter (inc)
import System.Metrics.Prometheus.MetricId
main :: IO ()
main = runRegistryT $ do
-- Labels can be defined as lists or added to an empty label set
connectSuccessGauge <- registerGauge "example_connections" (fromList [("login", "success")])
connectFailureGauge <- registerGauge "example_connections" (addLabel "login" "failure" mempty)
connectCounter <- registerCounter "example_connection_total" mempty
latencyHistogram <- registerHistogram "example_round_trip_latency_ms" mempty [10, 20 .. 100]
liftIO $ inc connectCounter -- increment a counter
-- [...] pass metric handles to the rest of the app
serveMetricsT 8080 ["metrics"] -- http://localhost:8080/metric server