package prometheus-app
Client library for Prometheus monitoring
Install
Dune Dependency
Authors
Maintainers
Sources
prometheus-0.5.tbz
sha256=aa137a5ecb0238551b18d7b59b42eb4ac594965373bf1a32c0acdec189a41345
md5=a0ece29e31d030159b89d6a1a4167a76
doc/src/prometheus-app.unix/prometheus_unix.ml.html
Source file prometheus_unix.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
open Prometheus module Unix_runtime = struct let start_time = Unix.gettimeofday () let simple_metric ~metric_type ~help name fn = let info = { MetricInfo. name = MetricName.v name; help; metric_type; label_names = []; } in let collect () = LabelSetMap.singleton [] [Sample_set.sample (fn ())] in info, collect let process_start_time_seconds = simple_metric ~metric_type:Counter "process_start_time_seconds" (fun () -> start_time) ~help:"Start time of the process since unix epoch in seconds." let metrics = [ process_start_time_seconds; ] end type config = int option module Server = Prometheus_app.Cohttp(Cohttp_lwt_unix.Server) let serve = function | None -> [] | Some port -> let mode = `TCP (`Port port) in let callback = Server.callback in let thread = Cohttp_lwt_unix.Server.create ~mode (Cohttp_lwt_unix.Server.make ~callback ()) in [thread] let listen_prometheus = let open Cmdliner in let doc = Arg.info ~docs:"MONITORING OPTIONS" ~docv:"PORT" ~doc: "Port on which to provide Prometheus metrics over HTTP." ["listen-prometheus"] in Arg.(value @@ opt (some int) None doc) let opts = listen_prometheus let () = let add (info, collector) = CollectorRegistry.(register default) info collector in List.iter add Unix_runtime.metrics
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>