Skip to content

Commit

Permalink
alert - add runbookLinks and alertTriageDashboards (#56)
Browse files Browse the repository at this point in the history
Adding parameters that are present in the Wavefront API but not in this client:
- runbookLinks
- alertTriageDashboards
  • Loading branch information
FeargusOG authored Nov 2, 2023
1 parent 974c9dd commit ec88d7d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
12 changes: 12 additions & 0 deletions alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ const (
AlertTypeClassic = "CLASSIC"
)

type AlertTriageDashboard struct {
DashboardId string `json:"dashboardId"`
Parameters map[string]map[string]string `json:"parameters"`
Description string `json:"description"`
}

// Alert represents a single Wavefront Alert
type Alert struct {
// Name is the name given to an Alert
Expand Down Expand Up @@ -81,6 +87,12 @@ type Alert struct {

// Include obsolete metrics in alert query
IncludeObsoleteMetrics bool `json:"includeObsoleteMetrics,omitempty"`

// User-supplied runbook links for this alert
RunbookLinks []string `json:"runbookLinks"`

// User-supplied dashboard and parameters to create dashboard links
AlertTriageDashboards []AlertTriageDashboard `json:"alertTriageDashboards"`
}

type SourceLabelPair struct {
Expand Down
18 changes: 15 additions & 3 deletions alert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (m *MockCrudAlertClient) Do(req *http.Request) (io.ReadCloser, error) {
return testDo(m.T, req, "./fixtures/create-alert-response.json", m.method, &Alert{})
}

func TestAlerts_CreateUpdateDeleteAlert(t *testing.T) {
func TestAlerts_CRUDAlert(t *testing.T) {
assert := asserts.New(t)
baseurl, _ := url.Parse("http://testing.wavefront.com")
a := &Alerts{
Expand All @@ -81,13 +81,19 @@ func TestAlerts_CreateUpdateDeleteAlert(t *testing.T) {
AdditionalInfo: "please resolve this alert",
Tags: []string{"mytag1", "mytag2"},
}
var readAlert Alert
alertId := "1234"

// Update should fail because no ID is set
assert.Error(a.Update(&alert))

a.client.(*MockCrudAlertClient).method = "POST"
assert.NoError(a.Create(&alert))
assert.Equal("1234", *alert.ID)
assert.Equal(alertId, *alert.ID)

a.client.(*MockCrudAlertClient).method = "GET"
readAlert.ID = &alertId
assert.NoError(a.Get(&readAlert))

a.client.(*MockCrudAlertClient).method = "PUT"
assert.NoError(a.Update(&alert))
Expand Down Expand Up @@ -130,13 +136,19 @@ func TestMultiThresholdAlerts_CreateUpdateDeleteAlert(t *testing.T) {
AdditionalInfo: "please resolve this alert",
Tags: []string{"mytag1", "mytag2"},
}
var readAlert Alert
alertId := "1234"

// Update should fail because no ID is set
assert.Error(a.Update(&alert))

a.client.(*MockCrudAlertClient).method = "POST"
assert.NoError(a.Create(&alert))
assert.Equal("1234", *alert.ID)
assert.Equal(alertId, *alert.ID)

a.client.(*MockCrudAlertClient).method = "GET"
readAlert.ID = &alertId
assert.NoError(a.Get(&readAlert))

a.client.(*MockCrudAlertClient).method = "PUT"
assert.NoError(a.Update(&alert))
Expand Down

0 comments on commit ec88d7d

Please sign in to comment.