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

InfluxDBv1 Write error - "partial write: field type conflict" #4

Closed
jack828 opened this issue Oct 4, 2021 · 2 comments
Closed

InfluxDBv1 Write error - "partial write: field type conflict" #4

jack828 opened this issue Oct 4, 2021 · 2 comments

Comments

@jack828
Copy link
Contributor

jack828 commented Oct 4, 2021

Hey, thanks for the previous package and this shiny new one.

I'm trying to replace my current setup with this and just going thru seeing how well it works with my setup before I delete stuff. I've noticed a few bugs so I've submitted PRs for them (#1, #2, #3)

I'm getting this error:

➜ SPEEDTEST_CONFIG=config.ini python3 speedmon.py
2021-10-04 20:05:37,884 - config_manager:__init__:19 - INFO: Loading config from config.ini
2021-10-04 20:05:37,884 - config_manager:__init__:27 - INFO: Configuration Successfully Loaded
2021-10-04 20:05:37,888 - storage_handler_base:__init__:18 - INFO: Built storage handler influx
2021-10-04 20:05:37,889 - storage_builder:init_storage_handler_from_ini:65 - INFO: No config section defined for INFLUXV2 in INI
2021-10-04 20:05:37,889 - storage_builder:init_storage_handler_from_ini:65 - INFO: No config section defined for GRAPHITE in INI
2021-10-04 20:05:37,889 - influxv1_storage_handler:validate_connection:37 - DEBUG: Testing connection to InfluxDb using provided credentials
2021-10-04 20:05:37,898 - influxv1_storage_handler:validate_connection:39 - DEBUG: Successful connection to InfluxDb
2021-10-04 20:05:37,899 - utils:run_speed_test:65 - DEBUG: Running with args: speedtest -f json
27368096 1949397 2.421 36.593 None
2021-10-04 20:06:03,296 - influxv1_storage_handler:save_results:71 - ERROR: Failed To Write To InfluxDB
Traceback (most recent call last):
  File "/home/jack/Personal/speedmon/speedmon/storage/influxv1/influxv1_storage_handler.py", line 61, in save_results
    self.client.write_points(self.format_results(data))
  File "/home/jack/.local/lib/python3.6/site-packages/influxdb/client.py", line 608, in write_points
    consistency=consistency)
  File "/home/jack/.local/lib/python3.6/site-packages/influxdb/client.py", line 685, in _write_points
    protocol=protocol
  File "/home/jack/.local/lib/python3.6/site-packages/influxdb/client.py", line 419, in write
    headers=headers
  File "/home/jack/.local/lib/python3.6/site-packages/influxdb/client.py", line 378, in request
    raise InfluxDBClientError(err_msg, response.status_code)
influxdb.exceptions.InfluxDBClientError: 400: {"error":"partial write: field type conflict: input field \"download\" on measurement \"speed_test_results\" is type integer, already exists as type float dropped=1"}

I fixed the error by changing format_influxdb_results like so:

    return [
        {
            'measurement': 'speed_test_results',
            'fields': {
-               'download': data.download,
+               'download': float(data.download),
-               'upload': data.upload,
+               'upload': float(data.upload),
-               'ping': data.latency,
+               'ping': float(data.latency),
-               'jitter': data.jitter,
+               'jitter': float(data.jitter),
-               'packetloss': data.packetloss,
+               'packetloss': 0 if data.packetloss == None else data.packetloss,
            },
            'tags': {

But I am not a python programmer so I am not sure why that fixes it to be honest...

config file:

[GENERAL]
Delay = 1
# Leave blank to auto pick server
Servers =

[INFLUXV1]
Name = influx
URL = 192.168.1.7
Port = 8086
Database_name = speedtests2
Username =
Password =
SSL = False
Verify_SSL = False

Using InfluxDB v1.8.0 & python 3.6.9. Clean database freshly created with create database speedtest2.

Let me know if you need more info.

@jack828
Copy link
Contributor Author

jack828 commented Oct 4, 2021

.....and I think I've just answered my own issue - I got this because the database name wasn't being loaded correctly (see #3), therefore it was trying to push data into the database for the old script, which for whatever reason is storing as floats.

Do you think it is worth converting all necessary datatypes to floats for backwards compatability or is there a way I can "un-float" my existing data so I don't lose it?

@barrycarey
Copy link
Owner

@jack828 I just converted it to use floats to remain consistent. This will break and new data written by the tool but I think it ultimately needed to be done before this repo picks up steam and gets more usage.

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

2 participants