在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):bitnomial/prometheus开源软件地址(OpenSource Url):https://github.com/bitnomial/prometheus开源编程语言(OpenSource Language):Haskell 97.9%开源软件介绍(OpenSource Introduction):Prometheus Haskell ClientA simple and modern, type safe, performance focused, idiomatic Haskell client for Prometheus monitoring. Specifically there is no use of unsafe IO or manual ByteString construction from lists of bytes. Batteries-included web server. A key design element of this library is that the RegistryT monad transformer is only required for registering new time series. Once the time series is registered, new data samples may just be added in the IO monad. Note: Version 0.* supports Prometheus v1.0 and version 2.* supports Prometheus v2.0. Usage Example{-# LANGUAGE OverloadedStrings #-}
module Example where
import Control.Monad.IO.Class (liftIO)
import System.Metrics.Prometheus.Http.Scrape (serveMetricsT)
import System.Metrics.Prometheus.Concurrent.RegistryT
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 Advanced UsageA Concurrency ModelMetrics are "values" and the Registry is the map of "name_labels" to metric "keys". Metrics may be created/registered at any point, not just at start up, in the The metrics are thread safe on their own and do not require locking the entire registry to update them. They use high performance check-and-set atomic primitives. This is because metrics may be updated many times in between scrapes where the Reigstry needs to be lock. You do NOT want to lock all the metrics just to update one. The scraping operation of the server to collect all the metrics locks the registry to ensure no new metrics are being created/keyed in a race with the scrape. Tasks
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论