https://github.com/prometheus-erl/prometheus-cowboy
Expose Prometheus metrics using cowboy/cowboy2
https://github.com/prometheus-erl/prometheus-cowboy
cowboy erlang instrumentation monitoring prometheus
Last synced: about 6 hours ago
JSON representation
Expose Prometheus metrics using cowboy/cowboy2
- Host: GitHub
- URL: https://github.com/prometheus-erl/prometheus-cowboy
- Owner: prometheus-erl
- License: mit
- Created: 2017-07-02T07:53:44.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2025-02-25T11:51:41.000Z (2 months ago)
- Last Synced: 2025-03-06T04:42:09.929Z (about 2 months ago)
- Topics: cowboy, erlang, instrumentation, monitoring, prometheus
- Language: Erlang
- Size: 2.26 MB
- Stars: 21
- Watchers: 4
- Forks: 19
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# prometheus_cowboy #
[](https://hex.pm/packages/prometheus_cowboy)
[](https://hex.pm/packages/prometheus_cowboy)
[](https://hexdocs.pm/prometheus_cowboy/)
[](https://github.com/prometheus-erl/prometheus-cowboy/actions/workflows/ci.yml)
[](https://codecov.io/github/prometheus-erl/prometheus-cowboy)## Exporting metrics with handlers
Cowboy 1:
```erlang
Routes = [
{'_', [
{"/metrics/[:registry]", prometheus_cowboy1_handler, []},
{"/", toppage_handler, []}
]}
]
```Cowboy 2:
```erlang
Routes = [
{'_', [
{"/metrics/[:registry]", prometheus_cowboy2_handler, []},
{"/", toppage_handler, []}
]}
]
```## Exporting Cowboy2 metrics
```erlang
{ok, _} = cowboy:start_clear(http, [{port, 0}],
#{env => #{dispatch => Dispatch},
metrics_callback => fun prometheus_cowboy2_instrumenter:observe/1,
stream_handlers => [cowboy_metrics_h, cowboy_stream_h]})
```