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

HttpPost headers don't work when added via environment variables #2280

Closed
petetnt opened this issue Jan 21, 2020 · 4 comments
Closed

HttpPost headers don't work when added via environment variables #2280

petetnt opened this issue Jan 21, 2020 · 4 comments
Assignees
Milestone

Comments

@petetnt
Copy link
Contributor

petetnt commented Jan 21, 2020

In Kapacitor 1.5.*, The documentation mentions in multiple points that HTTPPost node headers could be set via enviroment variables. For example:

https://docs.influxdata.com/kapacitor/v1.5/event_handlers/post/#defining-configuration-options-with-environment-variables

The endpoint, url, and headers configuration options can be defined with environment variables:

KAPACITOR_HTTPPOST_0_ENDPOINT = "example"
KAPACITOR_HTTPPOST_0_URL = "http://example.com/path"
KAPACITOR_HTTPPOST_0_HEADERS_Example1 = "header1"
KAPACITOR_HTTPPOST_0_HEADERS_Example2 = "header2"

https://docs.influxdata.com/kapacitor/v1.5/event_handlers/post/#configuring-and-using-multiple-http-post-endpoints

Multiple HTTP POST endpoint configurations can also be added using environment variables. >
Variables values are grouped together using the number in each variable key.

KAPACITOR_HTTPPOST_0_ENDPOINT = "example0"
KAPACITOR_HTTPPOST_0_URL = "http://example-0.com/path"
KAPACITOR_HTTPPOST_0_HEADERS_Example1 = "header1"
KAPACITOR_HTTPPOST_0_HEADERS_Example2 = "header2"

KAPACITOR_HTTPPOST_1_ENDPOINT = "example1"
KAPACITOR_HTTPPOST_1_URL = "http://example-1.com/path"
KAPACITOR_HTTPPOST_1_HEADERS_Example1 = "header1"
KAPACITOR_HTTPPOST_1_HEADERS_Example2 = "header2"

and others. However from my experience it the headers won't get added though they have been as enviromentment variables while ENDPOINT AND URL work just fine.

Example:

KAPACITOR_HTTPPOST_0_ENDPOINT = "example0"
KAPACITOR_HTTPPOST_0_URL = "http://example-0.com/path"
KAPACITOR_HTTPPOST_0_HEADERS_Example1 = "header1"

TickScript:

|foo
   .httpPost()
   .endpoint('example0')

Excepted:

  • Header "Example1" is added

Actual

  • Header "Example1" is not added

Example 2:

Writing the header inline

KAPACITOR_HTTPPOST_0_ENDPOINT = "example0"
KAPACITOR_HTTPPOST_0_URL = "http://example-0.com/path"

TickScript:

|foo
   .httpPost()
   .header('Example1', 'header1')
   .endpoint('example0')

Excepted

  • Header gets correctly added

Actual

  • Header gets correctly added

Alternatives tried

  • Also tried things like KAPACITOR_HTTPPOST_0_HEADERS_0_Example1 and similar but those work don't either.
@petetnt petetnt changed the title HTTPPOST headers don't work when added via environment variables HttpPost headers don't work when added via environment variables Jan 21, 2020
@russorat
Copy link
Contributor

@petetnt thanks for the issue. We will investigate if something was broken here.

@timhallinflux timhallinflux added this to the 1.5.5 milestone Apr 17, 2020
@docmerlin docmerlin modified the milestones: 1.5.5, 1.5.6 Apr 21, 2020
@kramik1
Copy link

kramik1 commented Feb 26, 2021

I am running into this as well. I am trying to setup kapacitor in k8. I dumped the config that is in the container to see what it has set. The basic-auth settings might shine some light on the proper env variables. I tried KAPACITOR_HTTPPOST_0_BASIC_AUTH_Password and KAPACITOR_HTTPPOST_0_HEADERS_Accept so far.

[[httppost]]
....
[httppost.basic-auth]
username = ""
password = ""

I also tried KAPACITOR_HTTPPOST_0_HTTPPOST_BASIC_AUTH_USERNAME without success.

@kramik1
Copy link

kramik1 commented Feb 27, 2021

OK, so kind of stupid on my part. But reading the toml docs (https://toml.io/en/v1.0.0#inline-table) made it super clear.
Inline tables are only short hand for a new document section. So KAPACITOR_HTTPPOST_0_BASIC_AUTH_PASSWORD works. I am using a configmap for the conf file so that I do not have so many environmental variables and pulling the basic-auth password from a secret. I double checked doing the same for additional headers and I do not see them in the runtime configuration. So the above poster still has his original problem.

@docmerlin
Copy link
Contributor

docmerlin commented Jan 21, 2022

closed by: #2653

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

No branches or pull requests

5 participants