{"action":"created","issue":{"url":"https://api.github.com/repos/savoirfairelinux/mod-influxdb/issues/28","labels_url":"https://api.github.com/repos/savoirfairelinux/mod-influxdb/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/savoirfairelinux/mod-influxdb/issues/28/comments","events_url":"https://api.github.com/repos/savoirfairelinux/mod-influxdb/issues/28/events","html_url":"https://github.com/savoirfairelinux/mod-influxdb/issues/28","id":103750696,"number":28,"title":"Field type conflict","user":{"login":"YBinnenweg","id":1544608,"avatar_url":"https://avatars.githubusercontent.com/u/1544608?v=3","gravatar_id":"","url":"https://api.github.com/users/YBinnenweg","html_url":"https://github.com/YBinnenweg","followers_url":"https://api.github.com/users/YBinnenweg/followers","following_url":"https://api.github.com/users/YBinnenweg/following{/other_user}","gists_url":"https://api.github.com/users/YBinnenweg/gists{/gist_id}","starred_url":"https://api.github.com/users/YBinnenweg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YBinnenweg/subscriptions","organizations_url":"https://api.github.com/users/YBinnenweg/orgs","repos_url":"https://api.github.com/users/YBinnenweg/repos","events_url":"https://api.github.com/users/YBinnenweg/events{/privacy}","received_events_url":"https://api.github.com/users/YBinnenweg/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-28T16:24:48Z","updated_at":"2015-08-28T20:50:45Z","closed_at":"2015-08-28T20:50:45Z","body":"Hi,\r\n\r\nWhile playing around with InfluxDB and mod-influxdb to fill it with data from Shinken I've encountered a problem when filling it with ping data.\r\nAs you may or may not know, the type of a field in InfluxDB is defined by the first value written to it. ([source](https://influxdb.com/docs/v0.9/write_protocols/line.html])) And this is where the problems start, because there is no standardized way that mod-influxdb writes data to the database, it's possible to get conflicts. In my case there are a bunch of hosts that are unreachable and thus the ping plugin (check_ping from nagios-plugins) returns a big number, which sets the field type to int64. Now my next host is actually online and returns a float. (24.78ms for example) When it tries to write this data, it gives a field type conflict.\r\nI've come up with an ugly hack to work around this, but because testing of this hack is very limited, I have no idea if it will conflict with other nagios plugins.\r\nIn [module.py at line 105](https://github.com/savoirfairelinux/mod-influxdb/blob/master/module/module.py#L105) replace the for in statement with this one:\r\n```python\r\nfor mapping in fields_mappings:\r\n    if 'value' in mapping:\r\n        value = float(getattr(e, mapping[0], None))\r\n    else:\r\n        value = getattr(e, mapping[0], None)\r\n    if value is not None:\r\n        if 'value' in mapping:\r\n            fields[mapping[1]] = float(value)\r\n        else:\r\n            fields[mapping[1]] = value\r\n```\r\nWhat this does is check if the data that's about to be written is going to be written to the field \"value\". If it is, it makes the value a float.\r\n\r\nI don't think this is a permanent fix for this problem, feel free to suggest something that would work better! (hopefully more compatible too)"},"comment":{"url":"https://api.github.com/repos/savoirfairelinux/mod-influxdb/issues/comments/135884917","html_url":"https://github.com/savoirfairelinux/mod-influxdb/issues/28#issuecomment-135884917","issue_url":"https://api.github.com/repos/savoirfairelinux/mod-influxdb/issues/28","id":135884917,"user":{"login":"aviau","id":2706882,"avatar_url":"https://avatars.githubusercontent.com/u/2706882?v=3","gravatar_id":"","url":"https://api.github.com/users/aviau","html_url":"https://github.com/aviau","followers_url":"https://api.github.com/users/aviau/followers","following_url":"https://api.github.com/users/aviau/following{/other_user}","gists_url":"https://api.github.com/users/aviau/gists{/gist_id}","starred_url":"https://api.github.com/users/aviau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aviau/subscriptions","organizations_url":"https://api.github.com/users/aviau/orgs","repos_url":"https://api.github.com/users/aviau/repos","events_url":"https://api.github.com/users/aviau/events{/privacy}","received_events_url":"https://api.github.com/users/aviau/received_events","type":"User","site_admin":false},"created_at":"2015-08-28T20:50:45Z","updated_at":"2015-08-28T20:50:45Z","body":"Great!\r\n\r\nThank you for reporting back :)"}}