Skip to content

Commit

Permalink
Merge pull request #259 from id/20240905-instrument-with-prometheus
Browse files Browse the repository at this point in the history
feat: instrument with prometheus
  • Loading branch information
id authored Sep 6, 2024
2 parents 0c7ef58 + 304dd56 commit 1a9fbd4
Show file tree
Hide file tree
Showing 6 changed files with 226 additions and 34 deletions.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ Usage: emqtt_bench conn [--help <help>] [-d <dist>] [-h [<host>]]
[-R [<conn_rate>]]
[--force-major-gc-interval [<force_major_gc_interval>]]
[--log_to [<log_to>]]
[--prometheus]
[--restapi <ip>:<port> | <port>]

--help help information
-d, --dist enable distribution port
Expand Down Expand Up @@ -98,7 +100,14 @@ Usage: emqtt_bench conn [--help <help>] [-d <dist>] [-h [<host>]]
--log_to Control where the log output goes. console:
directly to the console null: quietly,
don't output any logs. [default: console]
--prometheus Enable metrics collection via Prometheus.
Usually used with --restapi to enable
scraping endpoint.
--restapi Enable REST API for monitoring and control.
For now only serves /metrics.
Can be set to IP:Port to listen on a specific IP and Port,
or just Port to listen on all interfaces on
that port. [default: disabled]
```
For example, create 50K concurrent connections at the arrival rate of 100/sec:
Expand All @@ -118,6 +127,8 @@ Usage: emqtt_bench sub [--help <help>] [-d <dist>] [-h [<host>]] [-p [<port>]] [
[--load-qst <nst_dets_file>] [--ifaddr <ifaddr>] [--prefix <prefix>] [-s [<shortids>]] [-l <lowmem>]
[--num-retry-connect [<num_retry_connect>]] [-R [<conn_rate>]]
[--force-major-gc-interval [<force_major_gc_interval>]] [--log_to [<log_to>]]
[--prometheus]
[--restapi <ip>:<port> | <port>]
--help help information
-d, --dist enable distribution port
Expand Down Expand Up @@ -161,6 +172,14 @@ Usage: emqtt_bench sub [--help <help>] [-d <dist>] [-h [<host>]] [-p [<port>]] [
0]
--log_to Control where the log output goes. console: directly to the console null: quietly, don't
output any logs. [default: console]
--prometheus Enable metrics collection via Prometheus.
Usually used with --restapi to enable
scraping endpoint.
--restapi Enable REST API for monitoring and control.
For now only serves /metrics.
Can be set to IP:Port to listen on a specific IP and Port,
or just Port to listen on all interfaces on
that port. [default: disabled]
```
For example, create 50K concurrent connections at the arrival rate of 100/sec:
Expand All @@ -181,6 +200,8 @@ Usage: emqtt_bench pub [--help <help>] [-d <dist>] [-h [<host>]] [-p [<port>]] [
[-F [<inflight>]] [-w [<wait_before_publishing>]] [--max-random-wait [<max_random_wait>]]
[--min-random-wait [<min_random_wait>]] [--num-retry-connect [<num_retry_connect>]]
[-R [<conn_rate>]] [--force-major-gc-interval [<force_major_gc_interval>]] [--log_to [<log_to>]]
[--prometheus]
[--restapi <ip>:<port> | <port>]

--help help information
-d, --dist enable distribution port
Expand Down Expand Up @@ -235,6 +256,14 @@ Usage: emqtt_bench pub [--help <help>] [-d <dist>] [-h [<host>]] [-p [<port>]] [
[default: 0]
--log_to Control where the log output goes. console: directly to the console null: quietly,
don't output any logs. [default: console]
--prometheus Enable metrics collection via Prometheus.
Usually used with --restapi to enable
scraping endpoint.
--restapi Enable REST API for monitoring and control.
For now only serves /metrics.
Can be set to IP:Port to listen on a specific IP and Port,
or just Port to listen on all interfaces on
that port. [default: disabled]
```
For example, create 100 connections and each publishes messages at the rate of 100 msg/sec.
Expand Down
5 changes: 4 additions & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@

{deps, [
{getopt, {git, "https://github.com/zmstone/getopt", {tag, "v1.0.2.1"}}},
{emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.9.5"}}}
{emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.11.0"}}},
{prometheus, {git, "https://github.com/emqx/prometheus.erl", {tag, "v4.10.0.2"}}},
{cowboy, "2.9.0"}
]}.

{escript_name, emqtt_bench}.
{escript_main_app, emqtt_bench}.
{escript_incl_apps, [prometheus, quantile_estimator, cowboy]}.
{escript_emu_args, "%%! -smp true +K true +A 16 +P 16000000 +Muacnl 0 +hms 64 -env ERL_MAX_PORTS 16000000 -env ERTS_MAX_PORTS 16000000\n"}.
{escript_shebang, "#!/usr/bin/env escript\n"}.
{provider_hooks, [{post, [{compile, escriptize}]}]}.
Expand Down
4 changes: 2 additions & 2 deletions rebar.config.script
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Profiles = {profiles,[ {escript, []}
, stdlib
, emqtt
, getopt
, gun
, cowlib
, cowboy
, prometheus
| [ quicer || IsQuicSupp ]
] }
, {overlay_vars_values, [ {runner_root_dir, "$(cd $(dirname $(readlink $0 || echo $0))/..; pwd -P)"}
Expand Down
3 changes: 2 additions & 1 deletion src/emqtt_bench.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
{vsn, git},
{registered, []},
{applications, [kernel, stdlib, emqtt, getopt, gun, cowlib]},
{included_applications, [cowboy, prometheus]},
{env, []},
{maintainers,["Feng Lee <[email protected]>"]},
{licenses, ["Apache-2.0"]},
{links, [{"Github", "https://github.com/emqx/emqtt"}]}
{links, [{"Github", "https://github.com/emqx/emqtt-bench"}]}
]}.
Loading

0 comments on commit 1a9fbd4

Please sign in to comment.