-
Notifications
You must be signed in to change notification settings - Fork 91
/
main.go
50 lines (41 loc) · 1.04 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
package main
import (
"time"
"github.com/kataras/iris/v12"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/cloudwatch"
cw "github.com/iris-contrib/middleware/cloudwatch"
)
// $ go get github.com/aws/aws-sdk-go/...
// $ go run main.go
func main() {
app := iris.New()
app.Use(cw.New("us-east-1", "test").ServeHTTP)
app.Get("/", func(ctx iris.Context) {
put := cw.GetPutFunc(ctx)
put([]*cloudwatch.MetricDatum{
{
MetricName: aws.String("MyMetric"),
Dimensions: []*cloudwatch.Dimension{
{
Name: aws.String("ThingOne"),
Value: aws.String("something"),
},
{
Name: aws.String("ThingTwo"),
Value: aws.String("other"),
},
},
Timestamp: aws.Time(time.Now()),
Unit: aws.String("Count"),
Value: aws.Float64(42),
},
})
ctx.StatusCode(iris.StatusOK)
ctx.Text("success!\n")
})
// http://localhost:8080
// should give: NoCredentialProviders
// which is correct, you have to authorize your aws, we asumme that you know how to.
app.Listen(":8080")
}