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

cluster: support alertmanager configuration Listen Host #1665

Merged
merged 3 commits into from
Dec 13, 2021
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
2 changes: 1 addition & 1 deletion embed/templates/scripts/run_alertmanager.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ exec bin/alertmanager/alertmanager \
--cluster.peer="{{$am.IP}}:{{$am.ClusterPort}}" \
{{- end}}
{{- end}}
--cluster.listen-address="{{.IP}}:{{.ClusterPort}}"
--cluster.listen-address="{{.ListenHost}}:{{.ClusterPort}}"
3 changes: 2 additions & 1 deletion pkg/cluster/spec/alertmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type AlertmanagerSpec struct {
IgnoreExporter bool `yaml:"ignore_exporter,omitempty"`
WebPort int `yaml:"web_port" default:"9093"`
ClusterPort int `yaml:"cluster_port" default:"9094"`
ListenHost string `yaml:"listen_host,omitempty" validate:"listen_host:editable"`
DeployDir string `yaml:"deploy_dir,omitempty"`
DataDir string `yaml:"data_dir,omitempty"`
LogDir string `yaml:"log_dir,omitempty"`
Expand Down Expand Up @@ -144,7 +145,7 @@ func (i *AlertManagerInstance) InitConfig(
enableTLS := gOpts.TLSEnabled
// Transfer start script
spec := i.InstanceSpec.(*AlertmanagerSpec)
cfg := scripts.NewAlertManagerScript(spec.Host, paths.Deploy, paths.Data[0], paths.Log, enableTLS).
cfg := scripts.NewAlertManagerScript(spec.Host, spec.ListenHost, paths.Deploy, paths.Data[0], paths.Log, enableTLS).
WithWebPort(spec.WebPort).WithClusterPort(spec.ClusterPort).WithNumaNode(spec.NumaNode).
AppendEndpoints(AlertManagerEndpoints(alertmanagers, deployUser, enableTLS))

Expand Down
1 change: 1 addition & 0 deletions pkg/cluster/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@ func AlertManagerEndpoints(alertmanager []*AlertmanagerSpec, user string, enable

script := scripts.NewAlertManagerScript(
spec.Host,
spec.ListenHost,
deployDir,
dataDir,
logDir,
Expand Down
7 changes: 6 additions & 1 deletion pkg/cluster/template/scripts/alertmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
// AlertManagerScript represent the data to generate AlertManager start script
type AlertManagerScript struct {
IP string
ListenHost string
WebPort int
ClusterPort int
DeployDir string
Expand All @@ -36,9 +37,13 @@ type AlertManagerScript struct {
}

// NewAlertManagerScript returns a AlertManagerScript with given arguments
func NewAlertManagerScript(ip, deployDir, dataDir, logDir string, enableTLS bool) *AlertManagerScript {
func NewAlertManagerScript(ip, listenHost, deployDir, dataDir, logDir string, enableTLS bool) *AlertManagerScript {
if listenHost == "" {
listenHost = ip
}
return &AlertManagerScript{
IP: ip,
ListenHost: listenHost,
WebPort: 9093,
ClusterPort: 9094,
DeployDir: deployDir,
Expand Down