Closed antitbone closed 2 years ago
Hi,
I believe you are trying to use a string, when you should be using a map like this:
cookie_auth_body = {"username" = "XXX", "password" = "XXX, "services" = ["platform"]}
Can you give that a try? we may need to update the example config.
The error remains the same.
2022-05-23T06:19:13Z E! [telegraf] Error running agent: Error loading config file /etc/telegraf/telegraf.conf: Error parsing data: line 11: invalid TOML syntax
I deleted any configuration other than the lines below.
[[inputs.http]]
urls = [
"https://isilon:8080/platform/1/snapshot/snapshots-summary"
]
cookie_auth_url = "https://isilon:8080/session/1/session"
cookie_auth_method = "POST"
cookie_auth_headers = '{"Content-Type": "application/json"}'
cookie_auth_body = {"username": "XXXX", "password": "XXXX", "services": ["platform"]}
cookie_auth_renewal = "6h"
name_override = "snapshots"
insecure_skip_verify = true
data_format = "json"
[inputs.http.tags]
isilon_host = "isilon"
[[outputs.influxdb]]
urls = ["http://influx:8086"]
database = "isilon"
username = "isilon"
password = "XXX"
skip_database_creation = true
[outputs.influxdb.tagpass]
isilon_host = ["isilon"]
{"username": "XXXX", "password": "XXXX", "services": ["platform"]}
Ah if I had slowed down a bit more I would have noticed that these are not all strings. It is assumed that the body is a string key and value and that platform is not a string, but an array.
Hello! I am closing this issue due to inactivity. I hope you were able to resolve your problem, if not please try posting this question in our Community Slack or Community Page. Thank you!
A very late response.
With the TOML syntax the parameter cookie_auth_headers is valid.
cookie_auth_headers = { Content-Type = "application/json"}
cookie_auth_body = '{"username": "XXX", "password": "XXX", "services": ["platform"]}'
The plugin.http documentation can be updated to not mislead: https://github.com/influxdata/telegraf/blob/379b8ea04e8df8017611316cb9069cdf8f1512b9/plugins/inputs/http/sample.conf#L50 https://github.com/influxdata/telegraf/blob/379b8ea04e8df8017611316cb9069cdf8f1512b9/plugins/inputs/http/README.md?plain=1#L61
# cookie_auth_headers = '{"Content-Type": "application/json", "X-MY-HEADER":"hello"}'
A second problem occurs with authentication. Dell isilon array returns http code 201.
2022-07-01T12:47:20Z E! [telegraf] Error running agent: could not initialize input inputs.http: cookie auth renewal received status code: 201 (Created)
StatusOK = 200 // RFC 7231, 6.3.1
StatusCreated = 201 // RFC 7231, 6.3.2
But the test only accepts code 200 https://github.com/influxdata/telegraf/blob/379b8ea04e8df8017611316cb9069cdf8f1512b9/plugins/common/cookie/cookie.go#L113-L118
Hi,
The plugin.http documentation can be updated to not mislead:
Can you confirm you are suggesting this change:
--- cookie_auth_headers = '{"Content-Type": "application/json", "X-MY-HEADER":"hello"}'
+++ cookie_auth_headers = { Content-Type = "application/json" }
But the test only accepts code 200
I think checking for 201 is something we could change. Let me know about the doc change.
I suggest this change
--- cookie_auth_headers = '{"Content-Type": "application/json", "X-MY-HEADER":"hello"}'
+++ cookie_auth_headers = { Content-Type = "application/json", X-MY-HEADER = "hello" }
@antitbone can you take a look at https://github.com/influxdata/telegraf/pull/11472?
Thanks!
Relevant telegraf.conf
Logs from Telegraf
System info
telegraf-1.22.4
the "cookie_auth_headers" parameter does not seem to work
The error also occurs with the default parameter: