November 23, 2017
Get Metric

The script gets the CPU Metric and Memory Metric for a VSI
for more information see below

Important manual pages:

Author: SoftLayer Technologies, Inc. <>
import SoftLayer

Your SoftLayer API username and key.

Generate an API key at the SoftLayer Customer Portal:
USERNAME = 'set me'
API_KEY = 'set me'

# The virtual guest ID you want to reload
virtualGuestId = 4949592

startDateTime = "2014-06-04T00:00:00-05:00"
endDateTime = "2014-07-14T10:37:00-05:00"

# Declare a new API service object
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)

    # Getting the metrics
    cpuMetrict = client['SoftLayer_Virtual_Guest'].getCpuMetricDataByDate(startDateTime, endDateTime, id=virtualGuestId)
    memoryMetrict = client['SoftLayer_Virtual_Guest'].getMemoryMetricDataByDate(startDateTime, endDateTime, id=virtualGuestId)
except SoftLayer.SoftLayerAPIError as e:
    # If there was an error returned from the SoftLayer API then bomb out with the
    # error message.
    print("Unable to get metrics faultCode=%s, faultString=%s" % (e.faultCode, e.faultString))


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