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

Fixed adding the same metric family more than once when there are many mBeans #24

Merged
merged 1 commit into from
Jan 5, 2020

Conversation

DamianSz7
Copy link

In current version, when there is more than one connector (e.g. AJP and HTTP connector), metrics for each connector is added as many times as number of connectors. This lead to the /metrics endpoint being unparsable for the Prometheus.

Consider the below example of this issue:

# HELP tomcat_threads_total Number threads in this pool.
# TYPE tomcat_threads_total gauge
tomcat_threads_total{name="ajp-nio-8109",} 10.0
tomcat_threads_total{name="http-nio-8180",} 18.0
# HELP tomcat_threads_active_total Number of active threads in this pool.
# TYPE tomcat_threads_active_total gauge
tomcat_threads_active_total{name="ajp-nio-8109",} 0.0
tomcat_threads_active_total{name="http-nio-8180",} 7.0
# HELP tomcat_threads_max Maximum number of threads allowed in this pool.
# TYPE tomcat_threads_max gauge
tomcat_threads_max{name="ajp-nio-8109",} 200.0
tomcat_threads_max{name="http-nio-8180",} 200.0
# HELP tomcat_connections_active_total Number of connections served by this pool.
# TYPE tomcat_connections_active_total gauge
tomcat_connections_active_total{name="ajp-nio-8109",} 1.0
tomcat_connections_active_total{name="http-nio-8180",} 8.0
# HELP tomcat_connections_active_max Maximum number of concurrent connections served by this pool.
# TYPE tomcat_connections_active_max gauge
tomcat_connections_active_max{name="ajp-nio-8109",} 10000.0
tomcat_connections_active_max{name="http-nio-8180",} 10000.0
# HELP tomcat_threads_total Number threads in this pool.
# TYPE tomcat_threads_total gauge
tomcat_threads_total{name="ajp-nio-8109",} 10.0
tomcat_threads_total{name="http-nio-8180",} 18.0
# HELP tomcat_threads_active_total Number of active threads in this pool.
# TYPE tomcat_threads_active_total gauge
tomcat_threads_active_total{name="ajp-nio-8109",} 0.0
tomcat_threads_active_total{name="http-nio-8180",} 7.0
# HELP tomcat_threads_max Maximum number of threads allowed in this pool.
# TYPE tomcat_threads_max gauge
tomcat_threads_max{name="ajp-nio-8109",} 200.0
tomcat_threads_max{name="http-nio-8180",} 200.0
# HELP tomcat_connections_active_total Number of connections served by this pool.
# TYPE tomcat_connections_active_total gauge
tomcat_connections_active_total{name="ajp-nio-8109",} 1.0
tomcat_connections_active_total{name="http-nio-8180",} 8.0
# HELP tomcat_connections_active_max Maximum number of concurrent connections served by this pool.
# TYPE tomcat_connections_active_max gauge
tomcat_connections_active_max{name="ajp-nio-8109",} 10000.0
tomcat_connections_active_max{name="http-nio-8180",} 10000.0
# HELP tomcat_requestprocessor_received_bytes Number of bytes received by this request processor
# TYPE tomcat_requestprocessor_received_bytes gauge
tomcat_requestprocessor_received_bytes{name="http-nio-8180",} 0.0
tomcat_requestprocessor_received_bytes{name="ajp-nio-8109",} 0.0
# HELP tomcat_requestprocessor_sent_bytes Number of bytes sent by this request processor
# TYPE tomcat_requestprocessor_sent_bytes gauge
tomcat_requestprocessor_sent_bytes{name="http-nio-8180",} 0.0
tomcat_requestprocessor_sent_bytes{name="ajp-nio-8109",} 0.0
# HELP tomcat_requestprocessor_time_seconds The total time spend by this request processor
# TYPE tomcat_requestprocessor_time_seconds gauge
tomcat_requestprocessor_time_seconds{name="http-nio-8180",} 1.249
tomcat_requestprocessor_time_seconds{name="ajp-nio-8109",} 0.0
# HELP tomcat_requestprocessor_request_count The number of request served by this request processor
# TYPE tomcat_requestprocessor_request_count counter
tomcat_requestprocessor_request_count{name="http-nio-8180",} 11.0
tomcat_requestprocessor_request_count{name="ajp-nio-8109",} 0.0
# HELP tomcat_requestprocessor_error_count The number of error request served by this request processor
# TYPE tomcat_requestprocessor_error_count counter
tomcat_requestprocessor_error_count{name="http-nio-8180",} 0.0
tomcat_requestprocessor_error_count{name="ajp-nio-8109",} 0.0

As you can see, five metric families are added twice, each of them having two metric instances inside.
These metric families are: tomcat_threads_total, tomcat_threads_active_total, tomcat_threads_max, tomcat_connections_active_total and tomcat_connections_active_max.

@nlighten nlighten merged commit 27ed725 into nlighten:master Jan 5, 2020
@nlighten
Copy link
Owner

nlighten commented Jan 5, 2020

thnx. Just released version 0.0.13 that includes this pull request. Should appear in the maven repo soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants