mirror of
https://github.com/google/alertmanager-irc-relay.git
synced 2024-11-30 15:09:26 +01:00
Merge pull request #11 from filippog/alerts-channel
Make alert channel size configurable (and bigger)
This commit is contained in:
commit
1ef886d2e7
@ -63,6 +63,9 @@ msg_template: "Alert {{ .Labels.alertname }} on {{ .Labels.instance }} is {{ .St
|
|||||||
# Note: When sending only one message per alert group the default
|
# Note: When sending only one message per alert group the default
|
||||||
# msg_template is set to
|
# msg_template is set to
|
||||||
# "Alert {{ .GroupLabels.alertname }} for {{ .GroupLabels.job }} is {{ .Status }}"
|
# "Alert {{ .GroupLabels.alertname }} for {{ .GroupLabels.job }} is {{ .Status }}"
|
||||||
|
|
||||||
|
# Set the internal buffer size for alerts received but not yet sent to IRC.
|
||||||
|
alert_buffer_size: 2048
|
||||||
```
|
```
|
||||||
|
|
||||||
Running the bot (assuming *$GOPATH* and *$PATH* are properly setup for go):
|
Running the bot (assuming *$GOPATH* and *$PATH* are properly setup for go):
|
||||||
|
56
config.go
56
config.go
@ -31,37 +31,39 @@ type IRCChannel struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
HTTPHost string `yaml:"http_host"`
|
HTTPHost string `yaml:"http_host"`
|
||||||
HTTPPort int `yaml:"http_port"`
|
HTTPPort int `yaml:"http_port"`
|
||||||
IRCNick string `yaml:"irc_nickname"`
|
IRCNick string `yaml:"irc_nickname"`
|
||||||
IRCNickPass string `yaml:"irc_nickname_password"`
|
IRCNickPass string `yaml:"irc_nickname_password"`
|
||||||
IRCRealName string `yaml:"irc_realname"`
|
IRCRealName string `yaml:"irc_realname"`
|
||||||
IRCHost string `yaml:"irc_host"`
|
IRCHost string `yaml:"irc_host"`
|
||||||
IRCPort int `yaml:"irc_port"`
|
IRCPort int `yaml:"irc_port"`
|
||||||
IRCHostPass string `yaml:"irc_host_password"`
|
IRCHostPass string `yaml:"irc_host_password"`
|
||||||
IRCUseSSL bool `yaml:"irc_use_ssl"`
|
IRCUseSSL bool `yaml:"irc_use_ssl"`
|
||||||
IRCVerifySSL bool `yaml:"irc_verify_ssl"`
|
IRCVerifySSL bool `yaml:"irc_verify_ssl"`
|
||||||
IRCChannels []IRCChannel `yaml:"irc_channels"`
|
IRCChannels []IRCChannel `yaml:"irc_channels"`
|
||||||
MsgTemplate string `yaml:"msg_template"`
|
MsgTemplate string `yaml:"msg_template"`
|
||||||
MsgOnce bool `yaml:"msg_once_per_alert_group"`
|
MsgOnce bool `yaml:"msg_once_per_alert_group"`
|
||||||
UsePrivmsg bool `yaml:"use_privmsg"`
|
UsePrivmsg bool `yaml:"use_privmsg"`
|
||||||
|
AlertBufferSize int `yaml:"alert_buffer_size"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadConfig(configFile string) (*Config, error) {
|
func LoadConfig(configFile string) (*Config, error) {
|
||||||
config := &Config{
|
config := &Config{
|
||||||
HTTPHost: "localhost",
|
HTTPHost: "localhost",
|
||||||
HTTPPort: 8000,
|
HTTPPort: 8000,
|
||||||
IRCNick: "alertmanager-irc-relay",
|
IRCNick: "alertmanager-irc-relay",
|
||||||
IRCNickPass: "",
|
IRCNickPass: "",
|
||||||
IRCRealName: "Alertmanager IRC Relay",
|
IRCRealName: "Alertmanager IRC Relay",
|
||||||
IRCHost: "example.com",
|
IRCHost: "example.com",
|
||||||
IRCPort: 7000,
|
IRCPort: 7000,
|
||||||
IRCHostPass: "",
|
IRCHostPass: "",
|
||||||
IRCUseSSL: true,
|
IRCUseSSL: true,
|
||||||
IRCVerifySSL: true,
|
IRCVerifySSL: true,
|
||||||
IRCChannels: []IRCChannel{},
|
IRCChannels: []IRCChannel{},
|
||||||
MsgOnce: false,
|
MsgOnce: false,
|
||||||
UsePrivmsg: false,
|
UsePrivmsg: false,
|
||||||
|
AlertBufferSize: 2048,
|
||||||
}
|
}
|
||||||
|
|
||||||
if configFile != "" {
|
if configFile != "" {
|
||||||
|
@ -35,17 +35,18 @@ func TestNoConfig(t *testing.T) {
|
|||||||
|
|
||||||
func TestLoadGoodConfig(t *testing.T) {
|
func TestLoadGoodConfig(t *testing.T) {
|
||||||
expectedConfig := &Config{
|
expectedConfig := &Config{
|
||||||
HTTPHost: "test.web",
|
HTTPHost: "test.web",
|
||||||
HTTPPort: 8888,
|
HTTPPort: 8888,
|
||||||
IRCNick: "foo",
|
IRCNick: "foo",
|
||||||
IRCHost: "irc.example.com",
|
IRCHost: "irc.example.com",
|
||||||
IRCPort: 1234,
|
IRCPort: 1234,
|
||||||
IRCHostPass: "hostsecret",
|
IRCHostPass: "hostsecret",
|
||||||
IRCUseSSL: true,
|
IRCUseSSL: true,
|
||||||
IRCChannels: []IRCChannel{IRCChannel{Name: "#foobar"}},
|
IRCChannels: []IRCChannel{IRCChannel{Name: "#foobar"}},
|
||||||
MsgTemplate: defaultMsgTemplate,
|
MsgTemplate: defaultMsgTemplate,
|
||||||
MsgOnce: false,
|
MsgOnce: false,
|
||||||
UsePrivmsg: false,
|
UsePrivmsg: false,
|
||||||
|
AlertBufferSize: 666,
|
||||||
}
|
}
|
||||||
expectedData, err := yaml.Marshal(expectedConfig)
|
expectedData, err := yaml.Marshal(expectedConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
2
main.go
2
main.go
@ -37,7 +37,7 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
alertMsgs := make(chan AlertMsg, 10)
|
alertMsgs := make(chan AlertMsg, config.AlertBufferSize)
|
||||||
|
|
||||||
ircNotifier, err := NewIRCNotifier(config, alertMsgs)
|
ircNotifier, err := NewIRCNotifier(config, alertMsgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user