/
opam
101 lines (79 loc) · 3.14 KB
/
opam
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
opam-version: "2.0"
maintainer: "datakit@docker.com"
authors: ["Thomas Leonard" "David Scott"]
license: "Apache-1.0+"
homepage: "https://github.com/mirage/prometheus"
bug-reports: "https://github.com/mirage/prometheus/issues"
dev-repo: "git+https://github.com/mirage/prometheus.git"
doc: "https://mirage.github.io/prometheus/"
build: [
[ "jbuilder" "subst" "-p" name ] {dev}
[ "jbuilder" "build" "-p" name "-j" jobs ]
]
depends: [
"ocaml" {>= "4.01.0"}
"jbuilder" {>= "1.0+beta10"}
"astring"
"asetmap"
"fmt"
"re"
"lwt" {>= "2.5.0"}
"alcotest" {with-test}
]
synopsis: "Client library for Prometheus monitoring"
description: """
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:
```ocaml
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:
```ocaml
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:
```shell
$ ./_build/examples/example.native --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/>."""
url {
src:
"https://github.com/mirage/prometheus/releases/download/v0.5/prometheus-0.5.tbz"
checksum: "md5=a0ece29e31d030159b89d6a1a4167a76"
}