package prometheus-app
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=fbcf8bb28c02bfe4f61d2494bc2b70fdedd62f2b41fd1343e6f73d583bf599e4
sha512=9cf49689f6d33138cf41eca585e0d15bd17f670a3334b8235a52cc6c210fdc763fb967b19a91a110759a206aa9223cca1c7064e0eb2e2e6d3d13957ec7a38201
Description
Applications can enable metric reporting using the prometheus-app
opam package.
This depends on cohttp and can serve the metrics collected above over HTTP.
The prometheus-app.unix
ocamlfind library provides the Prometheus_unix
module,
which includes a cmdliner option and pre-configured web-server.
See the examples/example.ml
program for an example, which can be run as:
$ dune exec -- examples/example.exe --listen-prometheus=9090
If run with the option --listen-prometheus=9090, this program serves metrics at
http://localhost:9090/metrics
Tick!
Tick!
...
Unikernels can use Prometheus_app
instead of Prometheus_unix
to avoid the Unix
dependency.
Published: 09 Jun 2021
README
OCaml client library for Prometheus monitoring
To run services reliably, it is useful if they can report various metrics (for example, heap size, queue lengths, number of warnings logged, etc).
A monitoring service can be configured to collect this data regularly. The data can be graphed to help understand the performance of the service over time, or to help debug problems quickly. It can also be used to send alerts if a service is down or behaving poorly.
This repository contains code to report metrics to a Prometheus monitoring server.
Use by libraries
Library authors should define a set of metrics that may be useful. For example, the DataKitCI cache module defines several metrics like this:
module Metrics = struct
open Prometheus
let namespace = "DataKitCI"
let subsystem = "cache"
let builds_started_total =
let help = "Total number of builds started" in
Counter.v_label ~help ~label_name:"name" ~namespace ~subsystem "builds_started_total"
let builds_succeeded_total =
let help = "Total number of builds that succeeded" in
Counter.v_label ~help ~label_name:"name" ~namespace ~subsystem "builds_succeeded_total"
let builds_failed_total =
let help = "Total number of builds that failed" in
Counter.v_label ~help ~label_name:"name" ~namespace ~subsystem "builds_failed_total"
[...]
end
Each of these metrics has a name
label, which allows the reports to be further broken down by the type of thing being built.
When (for example) a build succeeds, the CI does:
Prometheus.Counter.inc_one (Metrics.builds_succeeded_total build_type)
Use by applications
Applications can enable metric reporting using the prometheus-app
opam package. This depends on cohttp and can serve the metrics collected above over HTTP.
The prometheus-app.unix
ocamlfind library provides the Prometheus_unix
module, which includes a cmdliner option and pre-configured web-server. See the examples/example.ml
program for an example, which can be run as:
$ dune exec -- examples/example.exe --listen-prometheus=9090
If run with the option --listen-prometheus=9090, this program serves metrics at
http://localhost:9090/metrics
Tick!
Tick!
...
Unikernels can use Prometheus_app
instead of Prometheus_unix
to avoid the Unix
dependency.
API docs
Generated API documentation is available at https://mirage.github.io/prometheus/.
Licensing
This code is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.
Dependencies (13)
-
logs
>= "0.6.0"
- astring
- asetmap
- cmdliner
-
lwt
>= "2.5.0"
- cohttp-lwt-unix
- cohttp-lwt
-
cohttp
>= "1.0.0"
-
re
>= "1.8.0"
- fmt
-
prometheus
= version
-
dune
>= "1.0"
-
ocaml
>= "4.02.3"
Dev Dependencies (1)
-
alcotest
with-test
Used by (9)
-
current
>= "0.4" & < "0.6.2"
-
current_examples
>= "0.4" & < "0.6.2"
-
current_web
< "0.6.2"
-
datakit
>= "0.9.0"
- datakit-bridge-github
- datakit-ci
-
ocluster
< "0.2"
- prometheus-liquidsoap
-
tezos-node
= "13.0"
Conflicts
None