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

Remove hip chat #2537

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
21 changes: 2 additions & 19 deletions alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
alertservice "github.com/influxdata/kapacitor/services/alert"
"github.com/influxdata/kapacitor/services/bigpanda"
"github.com/influxdata/kapacitor/services/discord"
"github.com/influxdata/kapacitor/services/hipchat"
"github.com/influxdata/kapacitor/services/httppost"
"github.com/influxdata/kapacitor/services/kafka"
"github.com/influxdata/kapacitor/services/mqtt"
Expand Down Expand Up @@ -317,24 +316,8 @@ func newAlertNode(et *ExecutingTask, n *pipeline.AlertNode, d NodeDiagnostic) (a
n.IsStateChangesOnly = true
}

for _, hc := range n.HipChatHandlers {
c := hipchat.HandlerConfig{
Room: hc.Room,
Token: hc.Token,
}
h := et.tm.HipChatService.Handler(c, ctx...)
an.handlers = append(an.handlers, h)
}
if len(n.HipChatHandlers) == 0 && (et.tm.HipChatService != nil && et.tm.HipChatService.Global()) {
c := hipchat.HandlerConfig{}
h := et.tm.HipChatService.Handler(c, ctx...)
an.handlers = append(an.handlers, h)
}
// If HipChat has been configured with state changes only set it.
if et.tm.HipChatService != nil &&
et.tm.HipChatService.Global() &&
et.tm.HipChatService.StateChangesOnly() {
n.IsStateChangesOnly = true
if len(n.HipChatHandlers) > 1 {
d.Error("HipChat support has been removed please update your scripts and config", errors.New("HipChat support removed"))
}

for _, k := range n.KafkaHandlers {
Expand Down
86 changes: 7 additions & 79 deletions integrations/streamer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ import (
"github.com/influxdata/kapacitor/services/bigpanda"
"github.com/influxdata/kapacitor/services/bigpanda/bigpandatest"
"github.com/influxdata/kapacitor/services/diagnostic"
"github.com/influxdata/kapacitor/services/hipchat"
"github.com/influxdata/kapacitor/services/hipchat/hipchattest"
"github.com/influxdata/kapacitor/services/httppost"
"github.com/influxdata/kapacitor/services/httppost/httpposttest"
k8s "github.com/influxdata/kapacitor/services/k8s/client"
Expand Down Expand Up @@ -88,7 +86,7 @@ import (
"github.com/influxdata/kapacitor/services/zenoss/zenosstest"
"github.com/influxdata/kapacitor/udf"
"github.com/influxdata/kapacitor/udf/agent"
udf_test "github.com/influxdata/kapacitor/udf/test"
"github.com/influxdata/kapacitor/udf/test"
"github.com/influxdata/wlog"
"github.com/k-sone/snmpgo"
)
Expand Down Expand Up @@ -9046,76 +9044,6 @@ stream
}
}

func TestStream_AlertHipChat(t *testing.T) {
ts := hipchattest.NewServer()
defer ts.Close()

var script = `
stream
|from()
.measurement('cpu')
.where(lambda: "host" == 'serverA')
.groupBy('host')
|window()
.period(10s)
.every(10s)
|count('value')
|alert()
.id('kapacitor/{{ .Name }}/{{ index .Tags "host" }}')
.info(lambda: "count" > 6.0)
.warn(lambda: "count" > 7.0)
.crit(lambda: "count" > 8.0)
.hipChat()
.room('1234567')
.token('testtoken1234567')
.hipChat()
.room('Test Room')
.token('testtokenTestRoom')
`
tmInit := func(tm *kapacitor.TaskMaster) {

c := hipchat.NewConfig()
c.Enabled = true
c.URL = ts.URL
c.Room = "1231234"
c.Token = "testtoken1231234"
sl := hipchat.NewService(c, diagService.NewHipChatHandler())
tm.HipChatService = sl
}
testStreamerNoOutput(t, "TestStream_Alert", script, 13*time.Second, tmInit)

exp := []interface{}{
hipchattest.Request{
URL: "/1234567/notification?auth_token=testtoken1234567",
PostData: hipchattest.PostData{
From: "kapacitor",
Message: "kapacitor/cpu/serverA is CRITICAL",
Color: "red",
Notify: true,
},
},
hipchattest.Request{
URL: "/Test%20Room/notification?auth_token=testtokenTestRoom",
PostData: hipchattest.PostData{
From: "kapacitor",
Message: "kapacitor/cpu/serverA is CRITICAL",
Color: "red",
Notify: true,
},
},
}

ts.Close()
var got []interface{}
for _, g := range ts.Requests() {
got = append(got, g)
}

if err := compareListIgnoreOrder(got, exp, nil); err != nil {
t.Error(err)
}
}

func TestStream_AlertAlerta(t *testing.T) {
ts := alertatest.NewServer()
defer ts.Close()
Expand Down Expand Up @@ -10727,9 +10655,9 @@ Value: {{ index .Fields "count" }}
"Mime-Version": []string{"1.0"},
"Content-Type": []string{"text/html; charset=UTF-8"},
"Content-Transfer-Encoding": []string{"quoted-printable"},
"To": []string{"user1@example.com, user2@example.com"},
"From": []string{"test@example.com"},
"Subject": []string{"kapacitor.cpu.serverA is CRITICAL"},
"To": []string{"user1@example.com, user2@example.com"},
"From": []string{"test@example.com"},
"Subject": []string{"kapacitor.cpu.serverA is CRITICAL"},
},
Body: `
<b>kapacitor.cpu.serverA is CRITICAL</b>
Expand All @@ -10743,9 +10671,9 @@ Value: 10
"Mime-Version": []string{"1.0"},
"Content-Type": []string{"text/html; charset=UTF-8"},
"Content-Transfer-Encoding": []string{"quoted-printable"},
"To": []string{"user1@example.com, user2@example.com"},
"From": []string{"test@example.com"},
"Subject": []string{"kapacitor.cpu.serverA is CRITICAL"},
"To": []string{"user1@example.com, user2@example.com"},
"From": []string{"test@example.com"},
"Subject": []string{"kapacitor.cpu.serverA is CRITICAL"},
},
Body: `
<b>kapacitor.cpu.serverA is CRITICAL</b>
Expand Down
54 changes: 2 additions & 52 deletions pipeline/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -1101,58 +1101,7 @@ func (pd2 *PagerDuty2Handler) Link(url string, text ...string) *PagerDuty2Handle
return pd2
}

// Send the alert to HipChat.
// For step-by-step instructions on setting up Kapacitor with HipChat, see the [Event Handler Setup Guide](https://docs.influxdata.com//kapacitor/latest/guides/event-handler-setup/#hipchat-setup).
// To allow Kapacitor to post to HipChat,
// go to the URL https://www.hipchat.com/docs/apiv2 for
// information on how to get your room id and tokens.
//
// Example:
// [hipchat]
// enabled = true
// url = "https://orgname.hipchat.com/v2/room"
// room = "4189212"
// token = "9hiWoDOZ9IbmHsOTeST123ABciWTIqXQVFDo63h9"
//
// In order to not post a message every alert interval
// use AlertNode.StateChangesOnly so that only events
// where the alert changed state are posted to the room.
//
// Example:
// stream
// |alert()
// .hipChat()
//
// Send alerts to HipChat room in the configuration file.
//
// Example:
// stream
// |alert()
// .hipChat()
// .room('Kapacitor')
//
// Send alerts to HipChat room 'Kapacitor'
//
//
// If the 'hipchat' section in the configuration has the option: global = true
// then all alerts are sent to HipChat without the need to explicitly state it
// in the TICKscript.
//
// Example:
// [hipchat]
// enabled = true
// url = "https://orgname.hipchat.com/v2/room"
// room = "Test Room"
// token = "9hiWoDOZ9IbmHsOTeST123ABciWTIqXQVFDo63h9"
// global = true
// state-changes-only = true
//
// Example:
// stream
// |alert()
//
// Send alert to HipChat using default room 'Test Room'.
// tick:property
// HipChat is removed but this has to be kept as is to not break current alert marshalling
func (n *AlertNodeData) HipChat() *HipChatHandler {
hipchat := &HipChatHandler{
AlertNodeData: n,
Expand All @@ -1161,6 +1110,7 @@ func (n *AlertNodeData) HipChat() *HipChatHandler {
return hipchat
}

// HipchatHandler has been removed but this struct is kept around for compatibility purposes.
// tick:embedded:AlertNode.HipChat
type HipChatHandler struct {
*AlertNodeData `json:"-"`
Expand Down
1 change: 1 addition & 0 deletions pipeline/tick/alert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ func TestAlertTelegram(t *testing.T) {
PipelineTickTestHelper(t, pipe, want)
}

// TestAlertHipchat must be kept to ensure we don't break marshaling of current alerts
func TestAlertHipchat(t *testing.T) {
pipe, _, from := StreamFrom()
handler := from.Alert().HipChat()
Expand Down
1 change: 0 additions & 1 deletion server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/influxdata/kapacitor/services/ec2"
"github.com/influxdata/kapacitor/services/file_discovery"
"github.com/influxdata/kapacitor/services/gce"
"github.com/influxdata/kapacitor/services/hipchat"
"github.com/influxdata/kapacitor/services/httpd"
"github.com/influxdata/kapacitor/services/httppost"
"github.com/influxdata/kapacitor/services/influxdb"
Expand Down
1 change: 0 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
"github.com/influxdata/kapacitor/services/ec2"
"github.com/influxdata/kapacitor/services/file_discovery"
"github.com/influxdata/kapacitor/services/gce"
"github.com/influxdata/kapacitor/services/hipchat"
"github.com/influxdata/kapacitor/services/httpd"
"github.com/influxdata/kapacitor/services/httppost"
"github.com/influxdata/kapacitor/services/influxdb"
Expand Down
57 changes: 28 additions & 29 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"time"

"github.com/davecgh/go-spew/spew"
"github.com/dgrijalva/jwt-go"
"github.com/google/go-cmp/cmp"
iclient "github.com/influxdata/influxdb/client/v2"
"github.com/influxdata/influxdb/influxql"
Expand All @@ -44,7 +43,6 @@ import (
"github.com/influxdata/kapacitor/services/auth/meta"
"github.com/influxdata/kapacitor/services/bigpanda/bigpandatest"
"github.com/influxdata/kapacitor/services/discord/discordtest"
"github.com/influxdata/kapacitor/services/hipchat/hipchattest"
"github.com/influxdata/kapacitor/services/httppost"
"github.com/influxdata/kapacitor/services/httppost/httpposttest"
"github.com/influxdata/kapacitor/services/k8s"
Expand All @@ -60,6 +58,7 @@ import (
"github.com/influxdata/kapacitor/services/pagerduty2"
"github.com/influxdata/kapacitor/services/pagerduty2/pagerduty2test"
"github.com/influxdata/kapacitor/services/pushover/pushovertest"
"github.com/influxdata/kapacitor/services/removed/hipchat/hipchattest"
"github.com/influxdata/kapacitor/services/sensu/sensutest"
"github.com/influxdata/kapacitor/services/servicenow"
"github.com/influxdata/kapacitor/services/servicenow/servicenowtest"
Expand Down Expand Up @@ -6763,12 +6762,12 @@ func TestServer_UpdateConfig(t *testing.T) {
Elements: []client.ConfigElement{{
Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/alerta/"},
Options: map[string]interface{}{
"enabled": false,
"environment": "",
"origin": "",
"token": false,
"token-prefix": "",
"url": "http://alerta.example.com",
"enabled": false,
"environment": "",
"origin": "",
"token": false,
"token-prefix": "",
"url": "http://alerta.example.com",
"insecure-skip-verify": false,
"timeout": "0s",
},
Expand All @@ -6780,12 +6779,12 @@ func TestServer_UpdateConfig(t *testing.T) {
expDefaultElement: client.ConfigElement{
Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/alerta/"},
Options: map[string]interface{}{
"enabled": false,
"environment": "",
"origin": "",
"token": false,
"token-prefix": "",
"url": "http://alerta.example.com",
"enabled": false,
"environment": "",
"origin": "",
"token": false,
"token-prefix": "",
"url": "http://alerta.example.com",
"insecure-skip-verify": false,
"timeout": "0s",
},
Expand All @@ -6807,12 +6806,12 @@ func TestServer_UpdateConfig(t *testing.T) {
Elements: []client.ConfigElement{{
Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/alerta/"},
Options: map[string]interface{}{
"enabled": false,
"environment": "",
"origin": "kapacitor",
"token": true,
"token-prefix": "",
"url": "http://alerta.example.com",
"enabled": false,
"environment": "",
"origin": "kapacitor",
"token": true,
"token-prefix": "",
"url": "http://alerta.example.com",
"insecure-skip-verify": false,
"timeout": "3h0m0s",
},
Expand All @@ -6824,12 +6823,12 @@ func TestServer_UpdateConfig(t *testing.T) {
expElement: client.ConfigElement{
Link: client.Link{Relation: client.Self, Href: "/kapacitor/v1/config/alerta/"},
Options: map[string]interface{}{
"enabled": false,
"environment": "",
"origin": "kapacitor",
"token": true,
"token-prefix": "",
"url": "http://alerta.example.com",
"enabled": false,
"environment": "",
"origin": "kapacitor",
"token": true,
"token-prefix": "",
"url": "http://alerta.example.com",
"insecure-skip-verify": false,
"timeout": "3h0m0s",
},
Expand Down Expand Up @@ -10786,9 +10785,9 @@ func TestServer_AlertHandlers(t *testing.T) {
"Mime-Version": []string{"1.0"},
"Content-Type": []string{"text/html; charset=UTF-8"},
"Content-Transfer-Encoding": []string{"quoted-printable"},
"To": []string{"oncall@example.com, backup@example.com"},
"From": []string{"test@example.com"},
"Subject": []string{"message"},
"To": []string{"oncall@example.com, backup@example.com"},
"From": []string{"test@example.com"},
"Subject": []string{"message"},
},
Body: "details\n",
}}
Expand Down
1 change: 0 additions & 1 deletion services/alert/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/influxdata/kapacitor/services/alerta"
"github.com/influxdata/kapacitor/services/bigpanda"
"github.com/influxdata/kapacitor/services/discord"
"github.com/influxdata/kapacitor/services/hipchat"
"github.com/influxdata/kapacitor/services/httpd"
"github.com/influxdata/kapacitor/services/httppost"
"github.com/influxdata/kapacitor/services/kafka"
Expand Down
1 change: 0 additions & 1 deletion services/diagnostic/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/influxdata/kapacitor/services/bigpanda"
"github.com/influxdata/kapacitor/services/discord"
"github.com/influxdata/kapacitor/services/ec2"
"github.com/influxdata/kapacitor/services/hipchat"
"github.com/influxdata/kapacitor/services/httppost"
"github.com/influxdata/kapacitor/services/influxdb"
"github.com/influxdata/kapacitor/services/k8s"
Expand Down
Loading