-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
55 lines (44 loc) · 1.14 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"flag"
"fmt"
"github.com/deanishe/awgo"
"github.com/zorkian/go-datadog-api"
)
func run() {
wf := aw.New()
apiKey := flag.String("apikey", "", "Datadog api key")
appKey := flag.String("appkey", "", "Datadog application key")
flag.Parse()
if *apiKey == "" || *appKey == "" {
wf.NewWarningItem("Datadog api key or application key is not set!", "subtitle")
wf.SendFeedback()
return
}
d := datadog.NewClient(*apiKey, *appKey)
switch flag.Arg(0) {
case "dashboard":
dashboards, err := d.GetDashboards()
if err != nil {
wf.FatalError(err)
}
for _, dash := range dashboards {
url := fmt.Sprintf("https://app.datadoghq.com/dash/%d/datadog", dash.GetId())
wf.NewItem(dash.GetTitle()).Subtitle(url).Arg(url).Valid(true)
}
case "monitor":
monitors, err := d.GetMonitors()
if err != nil {
wf.FatalError(err)
}
for _, moni := range monitors {
url := fmt.Sprintf("https://app.datadoghq.com/monitors#%d", moni.GetId())
wf.NewItem(moni.GetName()).Subtitle(url).Arg(url).Valid(true)
}
}
wf.WarnEmpty("No matching", "Try a different query")
wf.SendFeedback()
}
func main() {
aw.Run(run)
}