forked from influxdata/kapacitor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a raw TCP handler to alert node.
- Loading branch information
Ross McDonald
committed
Sep 7, 2016
1 parent
c4953cf
commit 8e42b9e
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ const defaultLogFileMode = 0600 | |
// | ||
// * log -- log alert data to file. | ||
// * post -- HTTP POST data to a specified URL. | ||
// * tcp -- Send data to a specified address via raw TCP. | ||
// * email -- Send and email with alert data. | ||
// * exec -- Execute a command passing alert data over STDIN. | ||
// * HipChat -- Post alert message to HipChat room. | ||
|
@@ -79,6 +80,7 @@ const defaultLogFileMode = 0600 | |
// .crit(lambda: "value" > 30) | ||
// .post("http://example.com/api/alert") | ||
// .post("http://another.example.com/api/alert") | ||
// .tcp("exampleendpoint.com:5678") | ||
// .email('[email protected]') | ||
// | ||
// | ||
|
@@ -283,6 +285,10 @@ type AlertNode struct { | |
// tick:ignore | ||
PostHandlers []*PostHandler `tick:"Post"` | ||
|
||
// Send the JSON alert data to the specified endpoint via TCP. | ||
// tick:ignore | ||
TcpHandlers []*TcpHandler `tick:"Tcp"` | ||
|
||
// Email handlers | ||
// tick:ignore | ||
EmailHandlers []*EmailHandler `tick:"Email"` | ||
|
@@ -464,6 +470,25 @@ type PostHandler struct { | |
URL string | ||
} | ||
|
||
// Send JSON alert data to a specified address over TCP. | ||
// tick:property | ||
func (a *AlertNode) Tcp(address string) *TcpHandler { | ||
tcp := &TcpHandler{ | ||
AlertNode: a, | ||
Address: address, | ||
} | ||
a.TcpHandlers = append(a.TcpHandlers, tcp) | ||
return tcp | ||
} | ||
|
||
// tick:embedded:AlertNode.Tcp | ||
type TcpHandler struct { | ||
*AlertNode | ||
|
||
// The endpoint address. | ||
Address string | ||
} | ||
|
||
// Email the alert data. | ||
// | ||
// If the To list is empty, the To addresses from the configuration are used. | ||
|