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

Improvement: add metrics to prom client #4556

Merged
merged 5 commits into from
Sep 1, 2021

Conversation

OGKevin
Copy link
Contributor

@OGKevin OGKevin commented Aug 11, 2021

This pr add pkg/extprom/http/instrument_client.go with code to instrument an HTTP client.
The approach is to add metrics clients to the HTTP config.
Not sure if this is the right approach or if another clever design can be used, this was the most obvious and backward compatible way I could come up with.

fixes: #4545

Signed-off-by: Kevin Hellemun [email protected]

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

Verification

# HELP thanos_rule_query_http_client_in_flight_requests A gauge of in-flight requests.
# TYPE thanos_rule_query_http_client_in_flight_requests gauge
thanos_rule_query_http_client_in_flight_requests 0
# HELP thanos_rule_query_http_client_request_duration_seconds A histogram of request latencies.
# TYPE thanos_rule_query_http_client_request_duration_seconds histogram
thanos_rule_query_http_client_request_duration_seconds_bucket{le="0.005"} 0
thanos_rule_query_http_client_request_duration_seconds_bucket{le="0.01"} 1
thanos_rule_query_http_client_request_duration_seconds_bucket{le="0.025"} 2
thanos_rule_query_http_client_request_duration_seconds_bucket{le="0.05"} 2
thanos_rule_query_http_client_request_duration_seconds_bucket{le="0.1"} 2
thanos_rule_query_http_client_request_duration_seconds_bucket{le="0.25"} 2
thanos_rule_query_http_client_request_duration_seconds_bucket{le="0.5"} 2
thanos_rule_query_http_client_request_duration_seconds_bucket{le="1"} 2
thanos_rule_query_http_client_request_duration_seconds_bucket{le="2.5"} 2
thanos_rule_query_http_client_request_duration_seconds_bucket{le="5"} 2
thanos_rule_query_http_client_request_duration_seconds_bucket{le="10"} 2
thanos_rule_query_http_client_request_duration_seconds_bucket{le="+Inf"} 2
thanos_rule_query_http_client_request_duration_seconds_sum 0.018484452
thanos_rule_query_http_client_request_duration_seconds_count 2
# HELP thanos_rule_query_http_client_request_total 
# TYPE thanos_rule_query_http_client_request_total counter
thanos_rule_query_http_client_request_total{code="200",method="post"} 2

@OGKevin OGKevin force-pushed the 4545-add-metrics-to-prom-client branch from ecdb2e8 to 86ae555 Compare August 13, 2021 12:47
@OGKevin OGKevin force-pushed the 4545-add-metrics-to-prom-client branch 4 times, most recently from 41512ba to 9e7cf44 Compare August 16, 2021 08:26
Add pkg/extprom/http/instrument_client.go with code to instrument an http
client.

thanos-io#4545

Signed-off-by: Kevin Hellemun <[email protected]>
@OGKevin OGKevin force-pushed the 4545-add-metrics-to-prom-client branch from 9e7cf44 to e29d4b9 Compare August 16, 2021 08:27
Signed-off-by: Kevin Hellemun <[email protected]>
Signed-off-by: Kevin Hellemun <[email protected]>
@OGKevin OGKevin marked this pull request as ready for review August 16, 2021 09:52
bwplotka
bwplotka previously approved these changes Aug 17, 2021
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Nice! I love it. LGTM, just one minor nit.

pkg/extprom/http/instrument_client.go Show resolved Hide resolved
pkg/extprom/http/instrument_client.go Outdated Show resolved Hide resolved
By using a standard metric name, this makes templating and dashboard generation
easier. A label has been added to indicate which client the http client metrics
are about.

thanos-io#4545

Signed-off-by: Kevin Hellemun <[email protected]>
@OGKevin
Copy link
Contributor Author

OGKevin commented Aug 23, 2021

The metrics now look like this:

# HELP http_client_in_flight_requests A gauge of in-flight requests.
# TYPE http_client_in_flight_requests gauge
http_client_in_flight_requests{client="alertmanager"} 0
http_client_in_flight_requests{client="query"} 0
# HELP http_client_request_duration_seconds A histogram of request latencies.
# TYPE http_client_request_duration_seconds histogram
http_client_request_duration_seconds_bucket{client="query",le="0.025"} 24
http_client_request_duration_seconds_bucket{client="query",le="0.05"} 24
http_client_request_duration_seconds_bucket{client="query",le="0.1"} 24
http_client_request_duration_seconds_bucket{client="query",le="0.5"} 24
http_client_request_duration_seconds_bucket{client="query",le="1"} 24
http_client_request_duration_seconds_bucket{client="query",le="5"} 24
http_client_request_duration_seconds_bucket{client="query",le="10"} 24
http_client_request_duration_seconds_bucket{client="query",le="+Inf"} 24
http_client_request_duration_seconds_sum{client="query"} 0.105682592
http_client_request_duration_seconds_count{client="query"} 24
# HELP http_client_request_total 
# TYPE http_client_request_total counter
http_client_request_total{client="query",code="200",method="post"} 24

bwplotka
bwplotka previously approved these changes Aug 24, 2021
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Sweet, all good except two nits. Good job!

pkg/extprom/http/instrument_client.go Outdated Show resolved Hide resolved
pkg/extprom/http/instrument_client.go Show resolved Hide resolved
pkg/http/http.go Outdated Show resolved Hide resolved
@bwplotka
Copy link
Member

bwplotka commented Aug 24, 2021

e2e fail looks unrelated, but let's double check. Retrying.

image

@bwplotka bwplotka enabled auto-merge (squash) September 1, 2021 09:29
@bwplotka
Copy link
Member

bwplotka commented Sep 1, 2021

Retried, will monitor if this time e2e fails again or not.

@bwplotka bwplotka merged commit 082c1e8 into thanos-io:main Sep 1, 2021
@OGKevin OGKevin deleted the 4545-add-metrics-to-prom-client branch September 1, 2021 09:47
someshkoli pushed a commit to someshkoli/thanos that referenced this pull request Nov 7, 2021
* Improvement: add metrics to prom client

Add pkg/extprom/http/instrument_client.go with code to instrument an http
client.

thanos-io#4545

Signed-off-by: Kevin Hellemun <[email protected]>

* Add doc blocks.

Signed-off-by: Kevin Hellemun <[email protected]>

* Fix lint issues.

Signed-off-by: Kevin Hellemun <[email protected]>

* Use a standard metric name.

By using a standard metric name, this makes templating and dashboard generation
easier. A label has been added to indicate which client the http client metrics
are about.

thanos-io#4545

Signed-off-by: Kevin Hellemun <[email protected]>

* Add missing labels, help and parse annotation.

Signed-off-by: Kevin Hellemun <[email protected]>
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.

ruler: Add metric that indicates instant query failures
3 participants