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

ES 7+ compatibility #41

Closed
usego opened this issue Jul 19, 2019 · 3 comments
Closed

ES 7+ compatibility #41

usego opened this issue Jul 19, 2019 · 3 comments
Labels
Milestone

Comments

@usego
Copy link

usego commented Jul 19, 2019

I've upgraded ES to 7.2 and noticed that mine metrics against ES failed. After some research I found that metric if failing with:

[2019-07-19 17:50:56,967] root.ERROR MainThread Error while running scheduled job.
Traceback (most recent call last):
  File "/usr/src/app/prometheus_es_exporter/__init__.py", line 210, in scheduled_run
    func()
  File "/usr/src/app/prometheus_es_exporter/__init__.py", line 121, in run_query
    update_gauges(metrics)
  File "/usr/src/app/prometheus_es_exporter/__init__.py", line 89, in update_gauges
    gauge.set(value)
  File "/usr/local/lib/python3.6/site-packages/prometheus_client/metrics.py", line 340, in set
    self._value.set(float(value))
TypeError: float() argument must be a string or a number, not 'dict'

I think the reason is that hits output is changed in ES7 which breaks things. So or additional parameter rest_total_hits_as_int=true should be added to search queries URL, or some ES7 support should be introduced as rest_total_hits_as_int parameter will be removed in ES8.

Please advise how this issue could be fixed

@usego
Copy link
Author

usego commented Jul 20, 2019

Adding ['value'] to parse_response fixes an issue for me:

result.append((metric + ['hits'], {}, response['hits']['total']['value']))

Sorry, could not provide PR as mine python skills are far from be able to do this in normal way to provide backward compatibility with ES6.

@braedon
Copy link
Owner

braedon commented Jul 20, 2019

Thanks for reporting this @usego, I'll have a play and see if I can get the parsing to handle both cases automatically.

@braedon braedon added the bug label Jul 20, 2019
giganteous added a commit to giganteous/prometheus-es-exporter that referenced this issue Jul 25, 2019
ES7 returns a dict, test if it is a dict, then store its 'value' key.
@braedon braedon added this to the patch-0.5.2 milestone Aug 6, 2019
@braedon
Copy link
Owner

braedon commented Aug 6, 2019

Fixed in 0.5.2

@braedon braedon closed this as completed Aug 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants