{"action":"closed","issue":{"url":"https://api.github.com/repos/influxdata/telegraf/issues/1237","repository_url":"https://api.github.com/repos/influxdata/telegraf","labels_url":"https://api.github.com/repos/influxdata/telegraf/issues/1237/labels{/name}","comments_url":"https://api.github.com/repos/influxdata/telegraf/issues/1237/comments","events_url":"https://api.github.com/repos/influxdata/telegraf/issues/1237/events","html_url":"https://github.com/influxdata/telegraf/issues/1237","id":155941415,"number":1237,"title":"MongoDB Input Plugin fails to resolve hostname (Error in input [mongodb]: Unable to connect to MongoDB, no reachable servers)","user":{"login":"wunzeco","id":1915636,"avatar_url":"https://avatars2.githubusercontent.com/u/1915636?v=4","gravatar_id":"","url":"https://api.github.com/users/wunzeco","html_url":"https://github.com/wunzeco","followers_url":"https://api.github.com/users/wunzeco/followers","following_url":"https://api.github.com/users/wunzeco/following{/other_user}","gists_url":"https://api.github.com/users/wunzeco/gists{/gist_id}","starred_url":"https://api.github.com/users/wunzeco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wunzeco/subscriptions","organizations_url":"https://api.github.com/users/wunzeco/orgs","repos_url":"https://api.github.com/users/wunzeco/repos","events_url":"https://api.github.com/users/wunzeco/events{/privacy}","received_events_url":"https://api.github.com/users/wunzeco/received_events","type":"User","site_admin":false},"labels":[{"id":194687826,"url":"https://api.github.com/repos/influxdata/telegraf/labels/bug","name":"bug","color":"ff8564","default":true},{"id":194687829,"url":"https://api.github.com/repos/influxdata/telegraf/labels/help%20wanted","name":"help wanted","color":"32b08c","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2016-05-20T11:19:31Z","updated_at":"2017-10-18T19:33:00Z","closed_at":"2017-10-18T19:33:00Z","author_association":"NONE","body":"## Bug report\n\nAccording to the documentation the `servers` setting of mongdb plugin can take ip or hostname. However, hostname does not get resolved as expected. Hence, an error is seen in telegraf log file.\n\n```\n2016/05/20 10:46:45 Error in input [mongodb]: Unable to connect to MongoDB, no reachable servers\n```\n\nWhen the hostname/fqdn is replaced with an ip, telegraf is able to fetch mongodb metrics upon restart.\n\n```\n2016/05/20 10:46:50 Starting Telegraf (version 0.13.0)\n2016/05/20 10:46:50 Loaded outputs: influxdb\n2016/05/20 10:46:50 Loaded inputs: system cpu diskio swap processes mongodb disk kernel mem\n2016/05/20 10:46:50 Tags enabled: host=ip-10-59-31-46 machine_role=mongodb\n2016/05/20 10:46:50 Agent Config: Interval:10s, Debug:false, Quiet:false, Hostname:\"ip-10-59-31-46\", Flush Interval:10s\n2016/05/20 10:47:00 Not gathering replica set status, member not in replica set\n2016/05/20 10:47:00 Gathered metrics, (10s interval), from 9 inputs in 23.595877ms\n2016/05/20 10:47:10 Not gathering replica set status, member not in replica set\n2016/05/20 10:47:10 Gathered metrics, (10s interval), from 9 inputs in 29.801601ms\n```\n### System info:\n- Telegraf (version 0.13.0)\n- Ubuntu 14.04\n\n[Include Telegraf version, operating system name, and other relevant details]\n### Steps to reproduce:\n\nAssumption: Telegraf is installed \n1. Add config for mongodb plugin using hostname as value of `servers` setting\n\n```\n[[inputs.mongodb]]\n  servers = [ \"mongodb0.dev.example.com:27017\" ]\n```\n1. Restart telegraf, `sudo service telegraf restart`\n### Expected behavior:\n\nIn telegraf.log, I expect to see log messages related to a successful communication with mongodb. For instance \n\n```\n2016/05/20 10:47:00 Not gathering replica set status, member not in replica set\n```\n### Actual behavior:\n\nInstead telegraf complains of not being able to reach servers\n\n```\n2016/05/20 10:46:45 Error in input [mongodb]: Unable to connect to MongoDB, no reachable servers\n```\n### Additional info:\n\nIf mongodb plugin config is changed to use ip as below the error goes away\n\n```\n[[inputs.mongodb]]\n  servers = [ \"10.59.31.46:27017\" ]\n```\n\nBelow is a copy of `telegraf.log`, which shows logs of what I have described above\n\n```\nubuntu@ip-10-59-31-46:~$ cat /var/log/telegraf/telegraf.log\n\n===> when - servers = [ \"mongodb0.dev.example.com:27017\" ] <===\n\n2016/05/20 11:09:16 Starting Telegraf (version 0.13.0)\n2016/05/20 11:09:16 Loaded outputs: influxdb\n2016/05/20 11:09:16 Loaded inputs: diskio mem system cpu disk kernel processes swap mongodb\n2016/05/20 11:09:16 Tags enabled: host=ip-10-59-31-46 machine_role=mongodb\n2016/05/20 11:09:16 Agent Config: Interval:10s, Debug:false, Quiet:false, Hostname:\"ip-10-59-31-46\", Flush Interval:10s\n2016/05/20 11:09:25 Error in input [mongodb]: Unable to connect to MongoDB, no reachable servers\n2016/05/20 11:09:25 Gathered metrics, (10s interval), from 9 inputs in 5.519876389s\n2016/05/20 11:09:30 Output [influxdb] buffer fullness: 22 / 10000 metrics. Total gathered metrics: 22. Total dropped metrics: 0.\n2016/05/20 11:09:30 Output [influxdb] wrote batch of 22 metrics in 8.041306ms\n2016/05/20 11:09:35 Error in input [mongodb]: Unable to connect to MongoDB, no reachable servers\n2016/05/20 11:09:35 Gathered metrics, (10s interval), from 9 inputs in 5.524096152s\n2016/05/20 11:09:40 Output [influxdb] buffer fullness: 12 / 10000 metrics. Total gathered metrics: 34. Total dropped metrics: 0.\n2016/05/20 11:09:40 Output [influxdb] wrote batch of 12 metrics in 4.080961ms\n\n===> when - servers = [ \"10.59.31.46:27017\" ] <===\n\n2016/05/20 11:10:02 Starting Telegraf (version 0.13.0)\n2016/05/20 11:10:02 Loaded outputs: influxdb\n2016/05/20 11:10:02 Loaded inputs: system mongodb cpu diskio mem processes swap disk kernel\n2016/05/20 11:10:02 Tags enabled: host=ip-10-59-31-46 machine_role=mongodb\n2016/05/20 11:10:02 Agent Config: Interval:10s, Debug:false, Quiet:false, Hostname:\"ip-10-59-31-46\", Flush Interval:10s\n2016/05/20 11:10:10 Not gathering replica set status, member not in replica set\n2016/05/20 11:10:10 Gathered metrics, (10s interval), from 9 inputs in 31.0935ms\n2016/05/20 11:10:20 Not gathering replica set status, member not in replica set\n2016/05/20 11:10:20 Gathered metrics, (10s interval), from 9 inputs in 29.842455ms\n2016/05/20 11:10:20 Output [influxdb] buffer fullness: 23 / 10000 metrics. Total gathered metrics: 23. Total dropped metrics: 0.\n2016/05/20 11:10:20 Output [influxdb] wrote batch of 23 metrics in 10.325168ms\n2016/05/20 11:10:30 Not gathering replica set status, member not in replica set\n2016/05/20 11:10:30 Gathered metrics, (10s interval), from 9 inputs in 29.891194ms\n2016/05/20 11:10:30 Output [influxdb] buffer fullness: 13 / 10000 metrics. Total gathered metrics: 36. Total dropped metrics: 0.\n2016/05/20 11:10:30 Output [influxdb] wrote batch of 13 metrics in 6.269971ms\n```\n"}}
{"actor":{"display_login":"danielnelson"}}