September 19, 2016

Get disk usage metrics for a time range

Get the disk usage metrics for the most recent 24 hours. Also demonstrates how to pass datetime values to the API
package main

import (


func main() {
	// Create a session
	sess := session.New()

	// Account service has the method we need
	service := services.GetAccountService(sess)

	// Range: most recent 24 hours
	// Time values are wrapped within an sl.Time type, to facilitate json marshaling
	tEnd := sl.Time(time.Now())
	tStart := sl.Time(tEnd.AddDate(0, 0, -1))

	data, err := service.GetDiskUsageMetricDataByDate(tStart, tEnd)
	if err != nil {

	fmt.Printf("Number of elements returned: %d\n", len(data))

	for _, d := range data {
		fmt.Printf("Counter: %.f, Time: %s, Type: %s\n", *d.Counter, *d.DateTime, *d.Type)


If this article contains any error, or leaves any of your questions unanswered, please help us out by opening up a github issue.
Open an issue