-
Notifications
You must be signed in to change notification settings - Fork 23
/
main.go
45 lines (33 loc) · 876 Bytes
/
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
package main
import (
"crypto/tls"
"fmt"
"os"
"time"
"github.com/cloudfoundry/noaa/consumer"
)
var (
dopplerAddress = os.Getenv("DOPPLER_ADDR")
appId = os.Getenv("APP_GUID")
authToken = os.Getenv("CF_ACCESS_TOKEN")
)
func main() {
consumer := consumer.New(dopplerAddress, &tls.Config{InsecureSkipVerify: true}, nil)
consumer.SetDebugPrinter(ConsoleDebugPrinter{})
fmt.Println("===== Streaming ContainerMetrics (will only succeed if you have admin credentials)")
for {
containerMetrics, err := consumer.ContainerMetrics(appId, authToken)
for _, cm := range containerMetrics {
fmt.Printf("%v \n", cm)
}
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err.Error())
}
time.Sleep(3 * time.Second)
}
}
type ConsoleDebugPrinter struct{}
func (c ConsoleDebugPrinter) Print(title, dump string) {
println(title)
println(dump)
}