Skip to content

Error gettting values when number is between quotes (string) #2

@viper0131

Description

@viper0131

Hi,

I'm trying to parse a json object that contains:
"NumberOfUsers":"30"

The number is between quotes. I can't change it, it an off the shelf app that generates this json.

In example.yaml I have the following metrics definition:

- name: NumberOfUsers
  description: Number of users
  path: $.NumberOfUsers

When I curl the endpoint it throws the following error:

2018-01-21 15:58:35,551 - root - DEBUG - metric_name: test_NumberOfUsers, value for '$.NumberOfUsers'
2018-01-21 15:58:35,551 - root - DEBUG - metric_name: test_NumberOfUsers, value for '$.NumberOfUsers' : 30
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/SocketServer.py", line 596, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/local/lib/python2.7/SocketServer.py", line 331, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/local/lib/python2.7/SocketServer.py", line 652, in __init__
    self.handle()
  File "/usr/local/lib/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/usr/local/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
    method()
  File "/usr/local/lib/python2.7/site-packages/prometheus_client/exposition.py", line 94, in do_GET
    output = generate_latest(registry)
  File "/usr/local/lib/python2.7/site-packages/prometheus_client/exposition.py", line 80, in generate_latest
    output.append('{0}{1} {2}\n'.format(name, labelstr, core._floatToGoString(value)))
  File "/usr/local/lib/python2.7/site-packages/prometheus_client/core.py", line 823, in _floatToGoString
    elif math.isnan(d):
TypeError: a float is required

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions