Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,10 @@ func checkTimeInterval(r *Route, timeIntervals map[string]struct{}) error {

// DefaultGlobalConfig returns GlobalConfig with default values.
func DefaultGlobalConfig() GlobalConfig {
var defaultHTTPConfig = commoncfg.DefaultHTTPClientConfig
return GlobalConfig{
ResolveTimeout: model.Duration(5 * time.Minute),
HTTPConfig: &commoncfg.HTTPClientConfig{},
HTTPConfig: &defaultHTTPConfig,

SMTPHello: "localhost",
SMTPRequireTLS: true,
Expand Down
19 changes: 18 additions & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,9 @@ func TestEmptyFieldsAndRegex(t *testing.T) {
var expectedConf = Config{

Global: &GlobalConfig{
HTTPConfig: &commoncfg.HTTPClientConfig{},
HTTPConfig: &commoncfg.HTTPClientConfig{
FollowRedirects: true,
},
ResolveTimeout: model.Duration(5 * time.Minute),
SMTPSmarthost: HostPort{Host: "localhost", Port: "25"},
SMTPFrom: "alertmanager@example.org",
Expand Down Expand Up @@ -755,6 +757,21 @@ func TestEmptyFieldsAndRegex(t *testing.T) {
}
}

func TestGlobalAndLocalHTTPConfig(t *testing.T) {
config, err := LoadFile("testdata/conf.http-config.good.yml")
if err != nil {
t.Fatalf("Error parsing %s: %s", "testdata/conf-http-config.good.yml", err)
}

if config.Global.HTTPConfig.FollowRedirects {
t.Fatalf("global HTTP config should not follow redirects")
}

if !config.Receivers[0].SlackConfigs[0].HTTPConfig.FollowRedirects {
t.Fatalf("global HTTP config should follow redirects")
}
}

func TestSMTPHello(t *testing.T) {
c, err := LoadFile("testdata/conf.good.yml")
if err != nil {
Expand Down
11 changes: 11 additions & 0 deletions config/testdata/conf.http-config.good.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
global:
slack_api_url: 'https://slack.com/webhook'
http_config:
follow_redirects: false
route:
receiver: team-X-slack
receivers:
- name: 'team-X-slack'
slack_configs:
- http_config:
proxy_url: foo
25 changes: 16 additions & 9 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,7 @@ A `http_config` allows configuring the HTTP client that the receiver uses to
communicate with HTTP-based API services.

```yaml
# Note that `basic_auth`, `bearer_token` and `bearer_token_file` options are
# mutually exclusive.
# Note that `basic_auth` and `authorization` options are mutually exclusive.

# Sets the `Authorization` header with the configured username and password.
# password and password_file are mutually exclusive.
Expand All @@ -329,18 +328,26 @@ basic_auth:
[ password: <secret> ]
[ password_file: <string> ]

# Sets the `Authorization` header with the configured bearer token.
[ bearer_token: <secret> ]
# Optional the `Authorization` header configuration.
authorization:
# Sets the authentication type.
[ type: <string> | default: Bearer ]
# Sets the credentials. It is mutually exclusive with
# `credentials_file`.
[ credentials: <secret> ]
# Sets the credentials with the credentials read from the configured file.
# It is mutually exclusive with `credentials`.
[ credentials_file: <filename> ]

# Sets the `Authorization` header with the bearer token read from the configured file.
[ bearer_token_file: <filepath> ]
# Optional proxy URL.
[ proxy_url: <string> ]

# Configure whether HTTP requests follow HTTP 3xx redirects.
[ follow_redirects: <bool> | default = true ]

# Configures the TLS settings.
tls_config:
[ <tls_config> ]

# Optional proxy URL.
[ proxy_url: <string> ]
```

## `<tls_config>`
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/oklog/ulid v1.3.1
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.7.1
github.com/prometheus/common v0.15.0
github.com/prometheus/common v0.18.0
github.com/prometheus/exporter-toolkit v0.5.0
github.com/rs/cors v1.7.0
github.com/satori/go.uuid v1.2.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,8 @@ github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lN
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
github.com/prometheus/common v0.15.0 h1:4fgOnadei3EZvgRwxJ7RMpG1k1pOZth5Pc13tyspaKM=
github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s=
github.com/prometheus/common v0.18.0 h1:WCVKW7aL6LEe1uryfI9dnEc2ZqNB1Fn0ok930v0iL1Y=
github.com/prometheus/common v0.18.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s=
github.com/prometheus/exporter-toolkit v0.5.0 h1:GwrxhCviqOl8Mm0vKqkh7Xy54m+FPlHEJacFs48M3gY=
github.com/prometheus/exporter-toolkit v0.5.0/go.mod h1:OCkM4805mmisBhLmVFw858QYi3v0wKdY6/UxrT0pZVg=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ github.com/prometheus/client_golang/prometheus/internal
github.com/prometheus/client_golang/prometheus/promhttp
# github.com/prometheus/client_model v0.2.0
github.com/prometheus/client_model/go
# github.com/prometheus/common v0.15.0
# github.com/prometheus/common v0.18.0
## explicit
github.com/prometheus/common/config
github.com/prometheus/common/expfmt
Expand Down