Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sile/logi_prometheus
Prometheus metrics collector for logi
https://github.com/sile/logi_prometheus
erlang logger prometheus
Last synced: 12 days ago
JSON representation
Prometheus metrics collector for logi
- Host: GitHub
- URL: https://github.com/sile/logi_prometheus
- Owner: sile
- License: mit
- Created: 2017-10-07T09:54:57.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-01T09:55:28.000Z (over 6 years ago)
- Last Synced: 2024-05-01T23:47:24.369Z (8 months ago)
- Topics: erlang, logger, prometheus
- Language: Erlang
- Size: 17.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
logi_prometheus
================[![hex.pm version](https://img.shields.io/hexpm/v/logi_prometheus.svg)](https://hex.pm/packages/logi_prometheus)
[![Build Status](https://travis-ci.org/sile/logi_prometheus.svg?branch=master)](https://travis-ci.org/sile/logi_prometheus)
[![Code Coverage](https://codecov.io/gh/sile/logi_prometheus/branch/master/graph/badge.svg)](https://codecov.io/gh/sile/logi_prometheus/branch/master)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)[Prometheus][prometheus] metrics collector for [logi].
[Documentation](https://hexdocs.pm/logi_prometheus/)
`logi_prometheus` provides counters that count the number of log messages as follows:
```
logi_messages_total{logger="logger_name",severity="info",application="app_name",module="mod_name"} 1
```It is useful for detecting anomalies of your application by using [alerting rules].
[logi]: https://github.com/sile/logi
[prometheus]: https://prometheus.io/
[alerting rules]: https://prometheus.io/docs/alerting/rules/Examples
--------Basic usage.
```erlang
%% Installs `metrics_sink` to the default channel
> Sink = logi_prometheus_sink:new(metrics_sink, [{registry, example_registry}]).
> {ok, _} = logi_channel:install_sink(Sink, info).%% Logs a message
> logi:info("foo").%% Prints metrics
> io:format(prometheus_text_format:format(example_registry)).
# TYPE logi_messages_total counter
# HELP logi_messages_total Messages count
logi_messages_total{sink="metrics_sink",severity="info",application="stdlib",module="erl_eval"} 1
```By using [prometheus_httpd], you can easily expose metrics collected by `logi_prometheus_sink`.
[prometheus_httpd]: https://github.com/deadtrickster/prometheus-httpd
```erlang
%% Installs `metrics_sink` to the default channel
> Sink = logi_prometheus_sink:new(metrics_sink).
> {ok, _} = logi_channel:install_sink(Sink, info).%% Starts metrics exporter (i.e., HTTP server)
> prometheus_httpd:start().%% Retrieves current metrics
> httpc:request("http://localhost:8081/metrics").
```