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

'invalid number' error when loading Rails page using influx-20 branch #173

Closed
macmartine opened this issue Jul 1, 2021 · 10 comments
Closed

Comments

@macmartine
Copy link

I'm using the influxdb-20 branch. It connects fine and send a little data, but then throws this guy:

InfluxDB2::InfluxError: unable to parse 'rails,format=html,hook=process_action,http_method=GET,location=DashboardController#show,method=DashboardController#show,server=pop-os,status=200 controller=2549i,db=1838i,request_id="5ab55ec7-000a-4d78-a4c5-22fb0035c1a8",started=2021-07-01 22:54:29 UTC,view=47i 1625180071846983424': invalid number

Anything obvious that stands out here, or is this a bug in the gem?

@ChrisBr
Copy link
Collaborator

ChrisBr commented Jul 2, 2021

Thanks @macmartine. I will have a look at this tomorrow, very odd but seems related to the new client.

@macmartine
Copy link
Author

macmartine commented Jul 2, 2021

@ChrisBr I narrowed it down to the 'started' variable in the following payload... Here's the end of the payload that's causing the error:

'rails,format=html,hook=process_action,http_method=GET,location=Setup::AdvocatesController#index,method=Setup::AdvocatesController#index,server=pop-os,status=200 controller=386i,db=59i,request_id="4acb8c77-f05d-4bc9-99af-23a333a83772",started=2021-07-01 23:55:49 UTC,view=19i 1625183749598635008'

If the 'started' variable is removed, all is well.

UPDATE:
Had to add this back, but change 'time_precision' to just 'precision':

But still get: 'undefined method `convert_timestamp' for InfluxDB:Module' .... can't find where that method is/was.

Also had to remove the InfluxDB:: namespace from:

InfluxDB::Rails.logger.error("[InfluxDB::Rails] Unable to write points: #{e.message}")

@ChrisBr
Copy link
Collaborator

ChrisBr commented Jul 3, 2021

@macmartine can you check what type start.utc is because if it's a Time object it should get automatically escaped now.

https://github.com/influxdata/influxdb-client-ruby/blob/3c5ba14273b5b65c53f608eb00827eeb65aceb42/lib/influxdb2/client/point.rb#L195-L217

But still get: 'undefined method `convert_timestamp' for InfluxDB:Module' .... can't find where that method is/was.

Also had to remove the InfluxDB:: namespace from:

convert_timestamp was a method from influxdb-ruby (1.0). In influxdb-client-ruby (2.0) we don't need / have this method anymore and it should get implicitly converted.

@ChrisBr
Copy link
Collaborator

ChrisBr commented Jul 3, 2021

Also which Rails version are you using?

@ChrisBr
Copy link
Collaborator

ChrisBr commented Jul 7, 2021

Any update @macmartine ?

@macmartine
Copy link
Author

@ChrisBr Sorry, I was just experimenting with this and not using it anymore at the moment.
Rails version: 5.2.4.5

Thanks!

@hennevogel
Copy link
Collaborator

hennevogel commented Jul 8, 2021

started=2021-07-01 23:55:49 UTC looks weird, this should be EPOCH instead. Are we missing an .to_i somewhere?

https://docs.influxdata.com/influxdb/v2.0/reference/syntax/line-protocol/#timestamp

@ChrisBr
Copy link
Collaborator

ChrisBr commented Jul 8, 2021

@hennevogel as mentioned, this should be handled by the new client as long as this is a time object.

https://github.com/influxdata/influxdb-client-ruby/blob/3c5ba14273b5b65c53f608eb00827eeb65aceb42/lib/influxdb2/client/point.rb#L195-L217

My suspicion is that this is a String. But as it's coming from Rails it should be a time object.

Karoid added a commit to Karoid/influxdb-rails that referenced this issue Oct 31, 2023
@rubhanazeem
Copy link
Collaborator

rubhanazeem commented Nov 13, 2023

started=2021-07-01 23:55:49 UTC looks weird, this should be EPOCH instead. Are we missing an .to_i somewhere?

https://docs.influxdata.com/influxdb/v2.0/reference/syntax/line-protocol/#timestamp

This should be handled by the client. The client is responsible for converting all the timestamps to integers. Client is not checking the presence of timestamps in tags and fields and just converting it to a string instead of an int. I've opened a PR in client to address this issue influxdata/influxdb-client-ruby#131

@hennevogel
Copy link
Collaborator

Fixed upstream, thanks @rubhanazeem 💐

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

No branches or pull requests

4 participants