Skip to content

http_response plugin have issues when urls list contains IPv4 and IPv6 addresses #8451

Closed
@zak-pawel

Description

Issue is present only when interface is set to proper value in telegraf.conf

Relevant telegraf.conf for Windows:

[[inputs.http_response]]
  ## List of urls to query.
  urls = ["http://127.0.0.1:15000/hello", "http://[::1]:15000/hello"]

  ## Interface to use when dialing an address
  interface = "Loopback Pseudo-Interface 1"

Relevant telegraf.conf for Linux:

[[inputs.http_response]]
  ## List of urls to query.
  urls = ["http://127.0.0.1:15000/hello", "http://[::1]:15000/hello"]

  ## Interface to use when dialing an address
  interface = "lo"

System info:

  1. Telegraf 1.16.2 (but probably there is problem since interface was added to plugin here: Add support for interface field in http_response input plugin #6006 - so from Telegraf 1.12.0)
  2. Windows 10 Pro and Ubuntu 18

Steps to reproduce:

  1. Start web server which listens on the TCP6 and TCP4 networks. For example:
	http.HandleFunc("/hello", func(writer http.ResponseWriter, request *http.Request) {
		fmt.Fprintf(writer, "hello\n")
	})
	http.ListenAndServe(":15000", nil)
  1. Verify that web server responds successfully for http://127.0.0.1:15000/hello and http://[::1]:15000/hello (using web browser or curl)
  2. Run Telegraf in Windows with given config (be sure that proper name of loopback interface is used).
  3. Run Telegraf in Linux with given config (be sure that proper name of loopback interface is used).

Expected behavior:

  1. Web server starts successfully.
  2. Web server responds successfully for http://127.0.0.1:15000/hello and http://[::1]:15000/hello.
  3. Telegraf for Windows successfully monitors both URLs.
  4. Telegraf for Linux successfully monitors both URLs.

Actual behavior:

  1. Web server starts successfully.
  2. Web server responds successfully for http://127.0.0.1:15000/hello and http://[::1]:15000/hello.
  3. Telegraf for Windows successfully monitors only http://[::1]:15000/hello URL:
http_response,host=win10,method=GET,result=connection_failed,server=http://127.0.0.1:15000/hello result_type="connection_failed",result_code=3i 1606058770000000000
http_response,host=win10,method=GET,result=success,server=http://[::1]:15000/hello,status_code=200 content_length=6i,result_type="success",result_code=0i,response_time=0.0020097,http_response_code=200i 1606058770000000000
  1. Telegraf for Linux successfully monitors only http://127.0.0.1:15000/hello URL:
http_response,host=ubuntu,method=GET,result=success,server=http://127.0.0.1:15000/hello,status_code=200 result_code=0i,response_time=0.02016597,http_response_code=200i,content_length=6i,result_type="success" 1606058900000000000
http_response,host=ubuntu,method=GET,result=connection_failed,server=http://[::1]:15000/hello result_type="connection_failed",result_code=3i 1606058900000000000

Additional info:

Why Telegraf for Windows fails for IPv4 URL http://127.0.0.1:15000/hello and Telegraf for Linux fails for IPv6 URL http://[::1]:15000/hello?
It is because in this line

return &net.TCPAddr{IP: naddr.IP}, nil
plugin chooses first available address for given interface. In my case it is IPv6 for Windows and IPv4 for Linux.

Would it work if any address ordering solution is provided (so the same address would be chosen
independently from OS type)?

No, they would just fail for the same address type. Other address type would still not work. It is because HTTP Client with chosen address is configured per plugin and not per provided URL.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugunexpected problem or unintended behaviorplatform/windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions