-
-
Notifications
You must be signed in to change notification settings - Fork 812
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Seanstoppable-datadog'
- Loading branch information
Showing
103 changed files
with
17,608 additions
and
94 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
title: "Datadog" | ||
date: 2018-08-18T00:00:00Z | ||
draft: false | ||
weight: 60 | ||
--- | ||
|
||
Connects to the Datadog API and displays alerting modules. | ||
|
||
## Source Code | ||
|
||
```bash | ||
wtf/datadog/ | ||
``` | ||
|
||
## Configuration | ||
|
||
```yaml | ||
datadog: | ||
apiKey: "<yourapikey>" | ||
applicationKey: "<yourapplicationkey>" | ||
enabled: true | ||
monitors: | ||
tags: | ||
- "team:ops" | ||
position: | ||
top: 4 | ||
left: 3 | ||
height: 1 | ||
width: 2 | ||
``` | ||
### Attributes | ||
`apiKey` <br /> | ||
Value: Your <a href="https://docs.datadoghq.com/api/?lang=python#overview">Datadog API</a> key. | ||
|
||
`applicationKey` <br /> | ||
Value: Your <a href="https://docs.datadoghq.com/api/?lang=python#overview">Datadog Application</a> key. | ||
|
||
`monitors` <br /> | ||
Configuration for the monitors functionality. | ||
|
||
`tags` <br /> | ||
Array of tags you want to query monitors by. | ||
|
||
`enabled` <br /> | ||
Determines whether or not this module is executed and if its data displayed onscreen. <br /> | ||
Values: `true`, `false`. | ||
|
||
`position` <br /> | ||
Defines where in the grid this module's widget will be displayed. <br /> | ||
|
||
`refreshInterval` <br /> | ||
How often, in seconds, this module will update its data. <br /> | ||
Values: A positive integer, `0..n`. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package datadog | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/senorprogrammer/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"), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package datadog | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/senorprogrammer/wtf/wtf" | ||
datadog "github.com/zorkian/go-datadog-api" | ||
) | ||
|
||
type Widget struct { | ||
wtf.TextWidget | ||
} | ||
|
||
func NewWidget() *Widget { | ||
widget := Widget{ | ||
TextWidget: wtf.NewTextWidget("Datadog", "datadog", false), | ||
} | ||
|
||
return &widget | ||
} | ||
|
||
/* -------------------- Exported Functions -------------------- */ | ||
|
||
func (widget *Widget) Refresh() { | ||
monitors, monitorErr := Monitors() | ||
|
||
widget.UpdateRefreshedAt() | ||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s", widget.Name))) | ||
widget.View.Clear() | ||
|
||
var content string | ||
if monitorErr != nil { | ||
widget.View.SetWrap(true) | ||
content = monitorErr.Error() | ||
} else { | ||
widget.View.SetWrap(false) | ||
content = widget.contentFrom(monitors) | ||
} | ||
|
||
widget.View.SetText(content) | ||
} | ||
|
||
/* -------------------- Unexported Functions -------------------- */ | ||
|
||
func (widget *Widget) contentFrom(monitors []datadog.Monitor) string { | ||
var str string | ||
|
||
triggeredMonitors := []datadog.Monitor{} | ||
|
||
for _, monitor := range monitors { | ||
state := *monitor.OverallState | ||
switch state { | ||
case "Alert": | ||
triggeredMonitors = append(triggeredMonitors, monitor) | ||
} | ||
} | ||
if len(triggeredMonitors) > 0 { | ||
str = str + fmt.Sprintf( | ||
" %s\n", | ||
"[red]Triggered Monitors[white]", | ||
) | ||
for _, triggeredMonitor := range triggeredMonitors { | ||
str = str + fmt.Sprintf("[red] %s\n", *triggeredMonitor.Name) | ||
} | ||
} else { | ||
str = str + fmt.Sprintf( | ||
" %s\n", | ||
"[green]No Triggered Monitors[white]", | ||
) | ||
} | ||
|
||
return str | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<!DOCTYPE html><html><head><title>https://wtfutil.com/categories/</title><link rel="canonical" href="https://wtfutil.com/categories/"/><meta name="robots" content="noindex"><meta http-equiv="content-type" content="text/html; charset=utf-8" /><meta http-equiv="refresh" content="0; url=https://wtfutil.com/categories/" /></head></html> | ||
<!DOCTYPE html><html><head><title>https://wtfutil.com/categories/</title><link rel="canonical" href="https://wtfutil.com/categories/"/><meta name="robots" content="noindex"><meta charset="utf-8" /><meta http-equiv="refresh" content="0; url=https://wtfutil.com/categories/" /></head></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.