-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
58 lines (50 loc) · 1.06 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
56
57
58
package main
import (
"context"
"log"
"net/http"
"os"
"strconv"
)
type LocalData struct {
AccountId int
UserKey string
Client *http.Client
GraphQlHeaders []string
CDPctx context.Context
CDPcancel context.CancelFunc
PolicyIds []int
DashboardMap map[string]Dashboard
ParentGuids []string
Dump string
}
func main() {
var err error
// Get required settings
data := LocalData{
UserKey: os.Getenv("NEW_RELIC_USER_KEY"),
}
// Validate settings
accountId := os.Getenv("NEW_RELIC_ACCOUNT")
if len(accountId) == 0 {
log.Printf("Please set env var NEW_RELIC_ACCOUNT")
os.Exit(1)
}
data.AccountId, err = strconv.Atoi(accountId)
if err != nil {
log.Printf("Please set env var NEW_RELIC_ACCOUNT to an integer")
os.Exit(1)
}
if len(data.UserKey) == 0 {
log.Printf("Please set env var NEW_RELIC_USER_KEY")
os.Exit(1)
}
data.makeClient()
// Get list of dashboards
data.getDashboards()
// Get widgets and nrql
data.getDashboardDetails()
// Output CSV
data.writeCSV()
log.Println("Done")
}