Skip to content

Commit

Permalink
Merge pull request #212 from mackerelio/anomaly_detection_monitor_and…
Browse files Browse the repository at this point in the history
…_alerts

Implement anomaly detection monitor
  • Loading branch information
syou6162 committed Jul 22, 2019
2 parents a360089 + 8dc4283 commit 4f39082
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 17 deletions.
2 changes: 2 additions & 0 deletions alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ func formatJoinedAlert(alertSet *alertSet, colorize bool) string {
} else {
monitorMsg = fmt.Sprintf("%s %.2f", expression, alert.Value)
}
case *mkr.MonitorAnomalyDetection:
monitorMsg = ""
default:
monitorMsg = fmt.Sprintf("%s", monitor.MonitorType())
}
Expand Down
8 changes: 8 additions & 0 deletions alerts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ func TestFormatJoinedAlert(t *testing.T) {
},
"2tZhm 1970-01-01 00:08:20 WARNING long long long long long long long long long long long long long long long long long long long そして長い... app.example.com working [foo:bar,baz]",
},
{
&alertSet{
&mkr.Alert{ID: "2tZhm", Type: "anomalyDetection", Status: "WARNING", MonitorID: "5rXR3", OpenedAt: 500},
&mkr.Host{ID: "3XYyG", Name: "app.example.com", Roles: mkr.Roles{"foo": {"bar", "baz"}}, Status: "working"},
&mkr.MonitorAnomalyDetection{ID: "5rXR3", Type: "anomalyDetection", Name: "My anomaly detection for roles", WarningSensitivity: "insensitive", MaxCheckAttempts: 5, Scopes: []string{"foo: bar", "foo: baz"}},
},
"2tZhm 1970-01-01 00:08:20 WARNING My anomaly detection for roles app.example.com working [foo:bar,baz]",
},
}

for _, testCase := range testCases {
Expand Down
27 changes: 17 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ module github.com/mackerelio/mkr
go 1.12

require (
cloud.google.com/go v0.43.0 // indirect
github.com/Songmu/prompter v0.2.0
github.com/Songmu/retry v0.1.0
github.com/Songmu/timeout v0.4.0 // indirect
github.com/Songmu/wrapcommander v0.1.0
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/daviddengcn/go-colortext v0.0.0-20180409174941-186a3d44e920 // indirect
github.com/dsnet/compress v0.0.1 // indirect
github.com/dsnet/golib v0.0.0-20190531212259-571cdbcff553 // indirect
github.com/fatih/color v1.7.0
github.com/golang/protobuf v1.3.1 // indirect
github.com/github/hub v2.11.2+incompatible // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450 // indirect
github.com/golangplus/fmt v0.0.0-20150411045040-2a5d6d7d2995 // indirect
Expand All @@ -19,11 +21,13 @@ require (
github.com/google/go-querystring v1.0.0 // indirect
github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/klauspost/compress v1.7.4 // indirect
github.com/klauspost/cpuid v1.2.1 // indirect
github.com/kr/pty v1.1.8 // indirect
github.com/mackerelio/checkers v0.0.0-20190411030116-60cbd7b55456
github.com/mackerelio/golib v0.0.0-20190411032134-c87047ca454e // indirect
github.com/mackerelio/go-osstat v0.0.0-20190712033226-e9f3fb840708 // indirect
github.com/mackerelio/mackerel-agent v0.60.0
github.com/mackerelio/mackerel-client-go v0.5.0
github.com/mackerelio/mackerel-client-go v0.6.0
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mholt/archiver v3.1.1+incompatible
github.com/motemen/go-colorine v0.0.0-20180816141035-45d19169413a
Expand All @@ -39,13 +43,16 @@ require (
github.com/yudai/gojsondiff v1.0.0
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
github.com/yudai/pp v2.0.1+incompatible // indirect
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5 // indirect
golang.org/x/net v0.0.0-20190603091049-60506f45cf65 // indirect
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect
golang.org/x/exp v0.0.0-20190718202018-cfdd5522f6f6 // indirect
golang.org/x/image v0.0.0-20190703141733-d6a02ce849c9 // indirect
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028 // indirect
golang.org/x/net v0.0.0-20190628185345-da137c7871d7 // indirect
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
golang.org/x/sync v0.0.0-20190423024810-112230192c58
golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed // indirect
golang.org/x/text v0.3.2 // indirect
google.golang.org/appengine v1.6.0 // indirect
golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7 // indirect
golang.org/x/tools v0.0.0-20190719005602-e377ae9d6386 // indirect
google.golang.org/grpc v1.22.0 // indirect
gopkg.in/urfave/cli.v1 v1.20.0
gopkg.in/yaml.v2 v2.2.2
)

0 comments on commit 4f39082

Please sign in to comment.