-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare directory for mod_prometheus
- Loading branch information
Showing
8 changed files
with
1,276 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
mod_prometheus - Prometheus metrics | ||
=================================== | ||
|
||
- Requires: ejabberd git commit xxx or higher | ||
- Author: [Pouriya Jahanbakhsh](https://github.com/pouriya) | ||
|
||
This module provides a web page with metrics suitable | ||
for [Prometheus](https://prometheus.io/), | ||
using the [prometheus](https://github.com/deadtrickster/prometheus.erl) erlang library. | ||
|
||
|
||
Options | ||
------- | ||
|
||
The configurable options are: | ||
|
||
- `mnesia: true | false` | ||
|
||
Enable mnesia metrics or not. | ||
Default: `false` | ||
|
||
- `vm: [metric: true | false, ...]` | ||
|
||
Enable some Erlang Virtual Machine metrics. | ||
Available ones are: | ||
`memory`, `system_info`, `statistics`, `distribution`, `microstate_accounting`. | ||
For details please consult | ||
[prometheus.erl collectors](https://github.com/deadtrickster/prometheus.erl?tab=readme-ov-file#erlang-vm--otp-collectors). | ||
Default: `[]` | ||
|
||
- `hooks: [Hook]` | ||
|
||
List of hooks to investigate. | ||
Default is an empty list: `[]` | ||
|
||
Each Hook is: | ||
- `hook: atom()`: the name of the hook | ||
- `type: counter | histogram` | ||
- `help: "Explanation"` | ||
- `stanza_label: true | false` | ||
- `host_label: true | false` | ||
- `collect: all | [Callback]` | ||
where each Callback is: | ||
- `module: atom()` | ||
- `function: atom()` | ||
- `help: "Explanation"` | ||
- `buckets: [integer()]` | ||
|
||
Quick Start Guide | ||
----------------- | ||
|
||
### Install module | ||
|
||
1. Start ejabberd | ||
|
||
1. Download dependencies, compile and install this module: | ||
```sh | ||
ejabberdctl module_install mod_prometheus | ||
``` | ||
1. Check ejabberd provides metrics in the URL: `http://localhost:5289/metrics/` | ||
|
||
### Start Prometheus and Grafana | ||
|
||
Start Prometheus and Grafana, for example using Podman or Docker: | ||
|
||
```sh | ||
cd example | ||
podman-compose up | ||
# or | ||
# docker-compose up | ||
``` | ||
|
||
### Test Prometheus | ||
|
||
1. Open in web browser `http://localhost:9090/` | ||
|
||
1. Enter example query: `erlang_mnesia_tablewise_size{table="muc_online_room"}` | ||
|
||
### Setup Grafana | ||
|
||
1. Open in web browser `http://localhost:3000/` | ||
|
||
1. Login with username `admin` and password `admin` | ||
|
||
1. Add data source: Prometheus | ||
- Connection: `http://host.docker.internal:9090` (or `http://prometheus:9090`, or something similar) | ||
- Click `Save & test` | ||
|
||
1. Create your first dashboard | ||
- Import dashboard | ||
- Upload dashboard JSON file: you can try `ejabberd-dash.json` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
listen: | ||
- | ||
port: 5289 | ||
ip: "::" | ||
module: ejabberd_http | ||
request_handlers: | ||
/metrics: mod_prometheus | ||
|
||
modules: | ||
mod_prometheus: | ||
mnesia: true | ||
vm: | ||
memory: true | ||
system_info: true | ||
statistics: false | ||
distribution: false | ||
microstate_accounting: false | ||
hooks: | ||
# Histogram for a hook: | ||
- hook: user_send_packet | ||
type: histogram | ||
help: "Handling of sent messages duration in millisecond" | ||
stanza_label: true | ||
host_label: true | ||
# Counter for a hook: | ||
- hook: user_send_packet | ||
type: counter | ||
help: "Number of sent messages" | ||
# Histograms only for some callbacks of a hook: | ||
- hook: user_send_packet | ||
type: histogram | ||
host_label: true | ||
collect: | ||
- module: mod_carboncopy | ||
function: user_send_packet | ||
help: "Handling of carbon copied messages in millisecond" | ||
- module: mod_mam | ||
function: user_send_packet | ||
help: "Handling of MAM messages in millisecond" | ||
buckets: | ||
- 10 | ||
- 100 | ||
- 750 | ||
- 1000 | ||
- 1500 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: '3.7' | ||
|
||
services: | ||
|
||
prometheus: | ||
image: docker.io/prom/prometheus | ||
container_name: prometheus | ||
ports: | ||
- "9090:9090" | ||
volumes: | ||
- ./prometheus.yml:/etc/prometheus/prometheus.yml | ||
|
||
grafana: | ||
image: docker.io/grafana/grafana-enterprise | ||
container_name: grafana | ||
ports: | ||
- "3000:3000" |
Oops, something went wrong.