question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PrometheusConnect.check_prometheus_connection() does not work

See original GitHub issue

Describe the bug

I can get metrics but PrometheusConnect.check_prometheus_connection() always returns false.

To Reproduce

>>> from prometheus_api_client.utils import parse_datetime
>>> from prometheus_api_client import PrometheusConnect
>>> from datetime import timedelta
>>>
>>> prom = PrometheusConnect(url="http://localhost:8481/select/1/prometheus", disable_ssl=True)
>>> start_time = parse_datetime("10min")
>>> end_time = parse_datetime("now")
>>> chunk_size = timedelta(seconds=60)
>>>
>>> metric_data = prom.get_metric_range_data(
...     'nginx_ingress_controller_requests{service="as01-prd01-oma"}',
...     start_time=start_time,
...     end_time=end_time,
...     chunk_size=chunk_size,
... )
>>> len(metric_data)
2940
>>> prom.check_prometheus_connection()
False
>>>

Expected behavior

PrometheusConnect.check_prometheus_connection() to return True

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
max-rocket-internetcommented, Feb 2, 2021

OK I see what you mean, yes get_current_metric_value is cleaner. Thanks!

0reactions
4n4ndcommented, Feb 1, 2021

oh my bad, i meant to say that you can use get_current_metric_value instead of get_metric_range_data to make it look cleaner

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prometheus Python Client - GitHub
Prometheus client libraries presume a threaded model, where metrics are shared across workers. This doesn't work so well for languages such as Python...
Read more >
prometheus-api-client - PyPI
Connecting and Collecting Metrics from a Prometheus host. The PrometheusConnect module of the library can be used to connect to a Prometheus host....
Read more >
How to clear all metrics it python prometheus client
I am trying to clear all metric instances and i am using .clear() to clear all labels and values. But the problem is...
Read more >
Getting started - Prometheus.io
Configure rules for aggregating scraped data into new time series. Though not a problem in our example, queries that aggregate over thousands of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found