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

[1839] Add influxdb subscription path to allow for Kapacitor to run behind a reverse proxy #1931

Merged
merged 4 commits into from
Dec 1, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

### Features
- [#1839](https://github.com/influxdata/kapacitor/pull/1839): Add Subscription path configuration option to allow Kapacitor to run behind a reverse proxy, thanks @aspring
- [#2055](https://github.com/influxdata/kapacitor/pull/2055): Add support for correlate in the Alerta AlertNode, thanks @nermolaev!
- [#2409](https://github.com/influxdata/kapacitor/pull/2409): Optionally use kapacitor alert details as opsgenie description text, thanks @JamesClonk!

Expand Down
11 changes: 11 additions & 0 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6349,6 +6349,7 @@ func TestServer_UpdateConfig(t *testing.T) {
"startup-timeout": "1h0m0s",
"subscription-protocol": "http",
"subscription-mode": "cluster",
"subscription-path": "",
"subscriptions": nil,
"subscriptions-sync-interval": "1m0s",
"timeout": "0s",
Expand Down Expand Up @@ -6381,6 +6382,7 @@ func TestServer_UpdateConfig(t *testing.T) {
"startup-timeout": "1h0m0s",
"subscription-protocol": "http",
"subscription-mode": "cluster",
"subscription-path": "",
"subscriptions": nil,
"subscriptions-sync-interval": "1m0s",
"timeout": "0s",
Expand Down Expand Up @@ -6423,6 +6425,7 @@ func TestServer_UpdateConfig(t *testing.T) {
"startup-timeout": "1h0m0s",
"subscription-protocol": "http",
"subscription-mode": "cluster",
"subscription-path": "",
"subscriptions": nil,
"subscriptions-sync-interval": "1m0s",
"timeout": "0s",
Expand Down Expand Up @@ -6455,6 +6458,7 @@ func TestServer_UpdateConfig(t *testing.T) {
"startup-timeout": "1h0m0s",
"subscription-protocol": "http",
"subscription-mode": "cluster",
"subscription-path": "",
"subscriptions": nil,
"subscriptions-sync-interval": "1m0s",
"timeout": "0s",
Expand Down Expand Up @@ -6498,6 +6502,7 @@ func TestServer_UpdateConfig(t *testing.T) {
"startup-timeout": "1h0m0s",
"subscription-protocol": "https",
"subscription-mode": "cluster",
"subscription-path": "",
"subscriptions": map[string]interface{}{"_internal": []interface{}{"monitor"}},
"subscriptions-sync-interval": "1m0s",
"timeout": "0s",
Expand Down Expand Up @@ -6530,6 +6535,7 @@ func TestServer_UpdateConfig(t *testing.T) {
"startup-timeout": "1h0m0s",
"subscription-protocol": "https",
"subscription-mode": "cluster",
"subscription-path": "",
"subscriptions": map[string]interface{}{"_internal": []interface{}{"monitor"}},
"subscriptions-sync-interval": "1m0s",
"timeout": "0s",
Expand Down Expand Up @@ -6569,6 +6575,7 @@ func TestServer_UpdateConfig(t *testing.T) {
"startup-timeout": "1h0m0s",
"subscription-protocol": "https",
"subscription-mode": "cluster",
"subscription-path": "",
"subscriptions": map[string]interface{}{"_internal": []interface{}{"monitor"}},
"subscriptions-sync-interval": "1m0s",
"timeout": "0s",
Expand Down Expand Up @@ -6601,6 +6608,7 @@ func TestServer_UpdateConfig(t *testing.T) {
"startup-timeout": "1h0m0s",
"subscription-protocol": "https",
"subscription-mode": "cluster",
"subscription-path": "",
"subscriptions": map[string]interface{}{"_internal": []interface{}{"monitor"}},
"subscriptions-sync-interval": "1m0s",
"timeout": "0s",
Expand Down Expand Up @@ -6644,6 +6652,7 @@ func TestServer_UpdateConfig(t *testing.T) {
"startup-timeout": "1h0m0s",
"subscription-protocol": "https",
"subscription-mode": "cluster",
"subscription-path": "",
"subscriptions": map[string]interface{}{"_internal": []interface{}{"monitor"}},
"subscriptions-sync-interval": "1m0s",
"timeout": "0s",
Expand Down Expand Up @@ -6675,6 +6684,7 @@ func TestServer_UpdateConfig(t *testing.T) {
"startup-timeout": "5m0s",
"subscription-protocol": "http",
"subscription-mode": "cluster",
"subscription-path": "",
"subscriptions": nil,
"subscriptions-sync-interval": "1m0s",
"timeout": "0s",
Expand Down Expand Up @@ -6709,6 +6719,7 @@ func TestServer_UpdateConfig(t *testing.T) {
"subscription-protocol": "http",
"subscriptions": nil,
"subscription-mode": "cluster",
"subscription-path": "",
"subscriptions-sync-interval": "1m0s",
"timeout": "0s",
"udp-bind": "",
Expand Down
2 changes: 2 additions & 0 deletions services/influxdb/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type Config struct {
UDPReadBuffer int `toml:"udp-read-buffer" override:"udp-read-buffer"`
StartUpTimeout toml.Duration `toml:"startup-timeout" override:"startup-timeout"`
SubscriptionSyncInterval toml.Duration `toml:"subscriptions-sync-interval" override:"subscriptions-sync-interval"`
SubscriptionPath string `toml:"subscription-path" override:"subscription-path"`
}

func NewConfig() Config {
Expand All @@ -78,6 +79,7 @@ func (c *Config) Init() {
c.SubscriptionProtocol = DefaultSubscriptionProtocol
c.SubscriptionSyncInterval = toml.Duration(DefaultSubscriptionSyncInterval)
c.SubscriptionMode = ClusterMode
c.SubscriptionPath = ""
}

func (c *Config) ApplyConditionalDefaults() {
Expand Down
4 changes: 4 additions & 0 deletions services/influxdb/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ type influxdbCluster struct {
startupTimeout time.Duration
subscriptionSyncInterval time.Duration
subscriptionMode SubscriptionMode
subscriptionPath string
disableSubs bool
runningSubs map[subEntry]bool
useTokens bool
Expand Down Expand Up @@ -485,6 +486,7 @@ func newInfluxDBCluster(c Config, hostname string, ider IDer, httpPort int, useT
startupTimeout: time.Duration(c.StartUpTimeout),
subscriptionSyncInterval: time.Duration(c.SubscriptionSyncInterval),
subscriptionMode: c.SubscriptionMode,
subscriptionPath: c.SubscriptionPath,
ider: ider,
subName: subName,
disableSubs: c.DisableSubscriptions,
Expand Down Expand Up @@ -1005,12 +1007,14 @@ func (c *influxdbCluster) linkSubscriptions(ctx context.Context, subName string)
Scheme: c.protocol,
User: url.UserPassword(httpd.SubscriptionUser, token),
Host: fmt.Sprintf("%s:%d", c.hostname, c.httpPort),
Path: c.subscriptionPath,
}
destination = u.String()
} else {
u := url.URL{
Scheme: c.protocol,
Host: fmt.Sprintf("%s:%d", c.hostname, c.httpPort),
Path: c.subscriptionPath,
}
destination = u.String()
}
Expand Down