mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
35 lines
700 B
Go
35 lines
700 B
Go
package datadog
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/wtfutil/wtf/wtf"
|
|
datadog "github.com/zorkian/go-datadog-api"
|
|
)
|
|
|
|
// Monitors returns a list of newrelic monitors
|
|
func Monitors() ([]datadog.Monitor, error) {
|
|
client := datadog.NewClient(apiKey(), applicationKey())
|
|
|
|
monitors, err := client.GetMonitorsByTags(wtf.ToStrs(wtf.Config.UList("wtf.mods.datadog.monitors.tags")))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return monitors, nil
|
|
}
|
|
|
|
func apiKey() string {
|
|
return wtf.Config.UString(
|
|
"wtf.mods.datadog.apiKey",
|
|
os.Getenv("WTF_DATADOG_API_KEY"),
|
|
)
|
|
}
|
|
|
|
func applicationKey() string {
|
|
return wtf.Config.UString(
|
|
"wtf.mods.datadog.applicationKey",
|
|
os.Getenv("WTF_DATADOG_APPLICATION_KEY"),
|
|
)
|
|
}
|