Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: instrument with prometheus #259

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
Comment on lines +106 to +110
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--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]
--restapi Enable REST API for monitoring and control.
Only takes effect if Prometheus is enabled.
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]

?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only takes effect if Prometheus is enabled.

I was thinking to add other functionality later, like change config in runtime without restart. Could be useful if you already have 1M connections and don't want to redo them again.

```

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
Loading