go-datadog-api icon indicating copy to clipboard operation
go-datadog-api copied to clipboard

Improve documentation for posting metrics

Open ctoto93 opened this issue 9 years ago • 3 comments

Here is my code to post metrics. Metrics explorer could not find the sent metrics. But there is no error shown

    datadogClient := datadog.NewClient(config.API_KEY,config.APP_KEY)

    data := []datadog.DataPoint{datadog.DataPoint{1.0,15.0}}

    test:= datadog.Metric{}
    test.Metric = "order"
    test.Host = "golife"
    test.Points = data

    fmt.Println(test)

    err = datadogClient.PostMetrics([]datadog.Metric{test})
    if err != nil{
        panic(err)
    }

ctoto93 avatar Mar 10 '16 06:03 ctoto93

@ctoto93 the first value you pass into a datadog.DataPoint needs to be a UNIX timestamp which is documented here: https://github.com/zorkian/go-datadog-api/blob/master/series.go#L13-L15

Please try something like datadog.DataPoint{float64(time.Now().Unix()), 15.0} and let us know whether that works for you.

seiffert avatar Mar 28 '16 16:03 seiffert

Follow up on this, I couldn't find any docs for the list of Types you can specify with a metric. Any idea?

thdxr avatar Jun 07 '16 12:06 thdxr

@seiffert care to raise a PR with an example in the Readme?

ojongerius avatar Dec 06 '16 05:12 ojongerius