package prometheus-app

  1. Overview
  2. Docs
Client library for Prometheus monitoring

Install

Dune Dependency

Authors

Maintainers

Sources

prometheus-0.1.tbz
sha256=0b2c80bb27323dd4eb1f13fab0f0f8d08d144f185692fd0929891f5b119602ff
md5=b0f3f5e3ef839d3b7ef672e5dd060d77

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.

Published: 07 Feb 2017

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 module. This depends on cohttp and can serve the metrics collected above over HTTP. It provides a command-line option, --listen-prometheus=PORT, to enable this.

Licensing

This code is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.

Dependencies (6)

  1. lwt >= "2.5.0"
  2. cohttp >= "0.20.0" & < "0.99"
  3. fmt
  4. prometheus < "0.2"
  5. ocamlfind build
  6. ocaml >= "4.02.3"

Dev Dependencies (1)

  1. alcotest with-test

Conflicts

None

OCaml

Innovation. Community. Security.