API Overview

For a general overview of the concepts used across all APIs, including endpoints, authentication, headers, and more, see the following information:

The Cloud Analytics API provides cost and usage metrics for cloud spend on cloud accounts connected to RightScale. This API, unlike some of the other RightScale APIs, is scoped by user. If you make a request to the Cloud Analytics API, you do not need to provide an account ID and (by default) will receive information for all of the accounts that your user has access to.

There are three main data sources for the Cloud Analytics API:

  • CloudBills provides data for total cloud spend. Currently, CloudBills are only supported for:
    • Amazon Web Services, where the earliest data is from April 2015. This includes AWS linked accounts, which are using Consolidated Billing (find out how to set up Consolidated Billing accounts for RightScale), as long as the payer account is connected to RightScale.
    • Microsoft Azure Enterprise Agreement, where all of your available billing data is loaded into Cloud Analytics. This includes all of the Microsoft Azure accounts and subscriptions that are part of your Microsoft Enterprise Agreement. Find out how to enable this.
    • Google Cloud Platform, where all of your available billing data is loaded into Cloud Analytics. Find out how to enable this.
  • Instances provides a granular view of instances across all cloud accounts connected to RightScale. Instances can be filtered by a wide range of attributes, including tags. See filtering instances for more information. AWS users will also be able to see metrics about their ReservedInstances.
  • PluginCosts allows additional costs to be plugged in to Cloud Analytics, then shown on the dashboard, in scheduled reports, and in budget alerts. Unlike the other two data sources, this one is entirely user-driven: by default, no plugin costs are present.

The CombinedCosts API provides a simple interface to these three data sources at once. It provides all of the data from the cloud bills and plugin costs data sources, and uses instances data where there is no matching cloud bills data. This is used by the Cloud Analytics dashboard and in full-cost scheduled reports.

For an example of how to work with the combined costs API, see recreating the Cloud Analytics Dashboard.

In addition to the above data sources, the Cloud Analytics API can be used to manage the following resources:

  • BudgetAlerts: enable you to set a monthly spend budget and be alerted via email when this is exceeded, based on either actual or forecasted spend. These emails include links to AnalysisSnapshots, which are generated automatically by RightScale.
  • ScheduledReports: these are emailed to you, and include usage, cost, and the change from the previous reporting period. These emails also include links to AnalysisSnapshots.
  • AnalysisSnapshots: these can be used to generate unique links to share data using filters over a date range.
  • Scenarios: these can be used to model changes in cloud usage to forecast costs over a 3-year period.
    • InstanceCombinations: these represent instances that make-up a Scenario. An InstanceCombination can have many ReservedInstancePurchases, which are not actually purchased in the cloud and are only used for cost simulation purposes. Patterns can also be applied to InstanceCombinations to model future growth or other changes in costs.

CloudBills

The CloudBills data source has two API resources:

  • CloudBillMetrics has cost information for total cloud spend for a time period.
  • CloudBills has other metadata about the bills. At present, this is limited to filters and the CSV export.

Total Cloud Spend for a Time Period

To find the total cloud spend for a time period, use the [CloudBillMetrics#grouped_time_series][cbm-gts] API call. To find the total cloud spend on Amazon Web Services for May, just do:

curl -Gs https://analytics.rightscale.com/api/cloud_bill_metrics/actions/grouped_time_series \
      -b rightscalecookies \
      -H X-Api-Version:1.0 \
      -d start_time=2015-05-01 \
      -d end_time=2015-06-01 \
      -d group='[["cloud_vendor_name"]]'
[
  {
    "kind": "ca#time_series_metrics_result",
    "timestamp": "2015-05-01T00:00:00+00:00",
    "results": [
      {
        "kind": "ca#metrics_result",
        "group": {
          "cloud_vendor_name": "Amazon Web Services"
        },
        "metrics": {
          "kind": "ca#metrics",
          "total_cost": 1251.45
        },
        "breakdown_metrics_results": [

        ]
      }
    ]
  }
]

The example call above has a group parameter, because this is a grouped time series, showing results by month. In this case, we used it for a single month and we chose the grouping so we would get a summary of the total spend.

We can also use the group parameter to drill down using nested groups. For instance, group='[["product_category"]]' means that the results will be grouped by product category. group='[["product_category","product"]]' means that the results will be grouped by product category and product, still at one level deep. group='[["product_category"],["product"]]', on the other hand, means that the results will be grouped by product category and then, within those groups, grouped by product. Here is what that looks like:

curl -Gs https://analytics.rightscale.com/api/cloud_bill_metrics/actions/grouped_time_series \
      -b rightscalecookies \
      -H X-Api-Version:1.0 \
      -d start_time=2015-05-01 \
      -d end_time=2015-06-01 \
      -d group='[["product_category"],["product"]]'
[
  {
    "kind": "ca#time_series_metrics_result",
    "timestamp": "2015-05-01T00:00:00+00:00",
    "results": [
      {
        "kind": "ca#metrics_result",
        "group": {
          "product_category": "Other"
        },
        "metrics": {
          "kind": "ca#metrics",
          "total_cost": 0.01
        },
        "breakdown_metrics_results": [
          {
            "kind": "ca#metrics_result",
            "group": {
              "product": "AWSQueueService"
            },
            "metrics": {
              "kind": "ca#metrics",
              "total_cost": 0.01
            },
            "breakdown_metrics_results": [

            ]
          }
        ]
      },
      {
        "kind": "ca#metrics_result",
        "group": {
          "product_category": "Network"
        },
        "metrics": {
          "kind": "ca#metrics",
          "total_cost": 1.64
        },
        "breakdown_metrics_results": [
          {
            "kind": "ca#metrics_result",
            "group": {
              "product": "AWSDataTransfer"
            },
            "metrics": {
              "kind": "ca#metrics",
              "total_cost": 1.64
            },
            "breakdown_metrics_results": [

            ]
          }
        ]
      },
      {
        "kind": "ca#metrics_result",
        "group": {
          "product_category": "Storage"
        },
        "metrics": {
          "kind": "ca#metrics",
          "total_cost": 0.02
        },
        "breakdown_metrics_results": [
          {
            "kind": "ca#metrics_result",
            "group": {
              "product": "AmazonS3"
            },
            "metrics": {
              "kind": "ca#metrics",
              "total_cost": 0.02
            },
            "breakdown_metrics_results": [

            ]
          }
        ]
      },
      {
        "kind": "ca#metrics_result",
        "group": {
          "product_category": "Database"
        },
        "metrics": {
          "kind": "ca#metrics",
          "total_cost": 46.96
        },
        "breakdown_metrics_results": [
          {
            "kind": "ca#metrics_result",
            "group": {
              "product": "AmazonRDS"
            },
            "metrics": {
              "kind": "ca#metrics",
              "total_cost": 46.96
            },
            "breakdown_metrics_results": [

            ]
          }
        ]
      },
      {
        "kind": "ca#metrics_result",
        "group": {
          "product_category": "Compute"
        },
        "metrics": {
          "kind": "ca#metrics",
          "total_cost": 1202.82
        },
        "breakdown_metrics_results": [
          {
            "kind": "ca#metrics_result",
            "group": {
              "product": "AmazonEC2"
            },
            "metrics": {
              "kind": "ca#metrics",
              "total_cost": 1202.82
            },
            "breakdown_metrics_results": [

            ]
          }
        ]
      }
    ]
  }
]

Filtering CloudBills

The time series can be filtered. We can get a list of filter options with the CloudBills#filter_options API call. For example, we can get all of the available product category filters for cloud bills in May 2015:

curl -Gs https://analytics.rightscale.com/api/cloud_bills/actions/filter_options \
      -b rightscalecookies \
      -H X-Api-Version:1.0 \
      -d start_time=2015-05-01 \
      -d end_time=2015-06-01 \
      -d filter_types='["cloud_bill:product_category"]'
[
  {
    "kind": "ca#filter",
    "type": "cloud_bill:product_category",
    "value": "Compute",
    "label": "Compute",
    "tag_resource_type": null
  },
  {
    "kind": "ca#filter",
    "type": "cloud_bill:product_category",
    "value": "Database",
    "label": "Database",
    "tag_resource_type": null
  },
  {
    "kind": "ca#filter",
    "type": "cloud_bill:product_category",
    "value": "Storage",
    "label": "Storage",
    "tag_resource_type": null
  },
  {
    "kind": "ca#filter",
    "type": "cloud_bill:product_category",
    "value": "Network",
    "label": "Network",
    "tag_resource_type": null
  },
  {
    "kind": "ca#filter",
    "type": "cloud_bill:product_category",
    "value": "Other",
    "label": "Other",
    "tag_resource_type": null
  }
]

This shows that the available filter values are Compute, Database, Storage, Network, and Other. We can then pass the filter object back to the time series call to get storage costs by product for May:

curl -Gs https://analytics.rightscale.com/api/cloud_bill_metrics/actions/grouped_time_series \
      -b rightscalecookies \
      -H X-Api-Version:1.0 \
      -d start_time=2015-05-01 \
      -d end_time=2015-06-01 \
      -d cloud_bill_filters='[{"type":"cloud_bill:product_category","value":"Storage"}]' \
      -d group='[["product"]]'
[
  {
    "kind": "ca#time_series_metrics_result",
    "timestamp": "2015-05-01T00:00:00+00:00",
    "results": [
      {
        "kind": "ca#metrics_result",
        "group": {
          "product": "AmazonS3"
        },
        "metrics": {
          "kind": "ca#metrics",
          "total_cost": 0.02
        },
        "breakdown_metrics_results": [

        ]
      }
    ]
  }
]

And so we can see that all of our storage cost in May was the two cents we spent on Amazon S3.

Instances

Instances have far more API calls available than CloudBills. These are divided into three resources:

  • InstanceMetrics has aggregated cost and usage information, which can be presented in a variety of ways.
  • Instances has other metadata about the instances. Like CloudBills, filter options and CSV export are in this resource, along with instance-level information.
  • InstanceUsagePeriods enables you to get usage period details from instances. An instance can have many usage periods, which can be caused by stop/start actions or changes to the instance type etc. InstanceUsagePeriods are used internally to calculate aggregate InstanceMetrics.

Costs by Tag

The Cloud Analytics API contains instance, deployment, and account tags (find out more about tags). These are all available as tags, distinguished by their tag_resource_type attribute. When grouping by tags, it's very useful to either filter or group on tag_resource_type, in case the same tags exist on different types of resource.

The [InstanceMetrics#grouped_overall][im-go] call can summarise and group metrics for a time period. In this case, we will show instance costs on 1 May 2015, by tag, ordered most expensive to least expensive:

curl -Gs https://analytics.rightscale.com/api/instance_metrics/actions/grouped_overall \
      -b rightscalecookies \
      -H X-Api-Version:1.0 \
      -d start_time=2015-05-01 \
      -d end_time=2015-05-02 \
      -d group='["tag_resource_type","tag_key"]' \
      -d metrics='["total_cost","average_instance_count"]' \
      -d order='["-total_cost"]'
[
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "accounts",
      "key": "account:demo"
    },
    "metrics": {
      "average_instance_count": 28.0396643518519,
      "total_cost": 51.5431005351713
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "accounts",
      "key": "rs_report:include"
    },
    "metrics": {
      "average_instance_count": 28.0396643518518,
      "total_cost": 51.5431005351713
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "instances",
      "key": "ec2:Name"
    },
    "metrics": {
      "average_instance_count": 19.0396643518519,
      "total_cost": 33.8734404141307
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "instances",
      "key": "rs_monitoring:state"
    },
    "metrics": {
      "average_instance_count": 20.0396643518519,
      "total_cost": 32.4574570847096
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "deployments",
      "key": "selfservice:href"
    },
    "metrics": {
      "average_instance_count": 11.0396643518519,
      "total_cost": 29.937438626944
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "deployments",
      "key": "selfservice:launched_from"
    },
    "metrics": {
      "average_instance_count": 11.0396643518519,
      "total_cost": 29.937438626944
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "deployments",
      "key": "selfservice:launched_from_type"
    },
    "metrics": {
      "average_instance_count": 11.0396643518519,
      "total_cost": 29.937438626944
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "deployments",
      "key": "selfservice:launched_by"
    },
    "metrics": {
      "average_instance_count": 11.0396643518519,
      "total_cost": 29.9374386269439
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "instances",
      "key": "server:uuid"
    },
    "metrics": {
      "average_instance_count": 17.5388425925926,
      "total_cost": 23.9202435826083
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "instances",
      "key": "rs_login:state"
    },
    "metrics": {
      "average_instance_count": 16.0364930555556,
      "total_cost": 18.7398453089306
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "instances",
      "key": "server:private_ip_0"
    },
    "metrics": {
      "average_instance_count": 16.0364930555556,
      "total_cost": 18.7398453089306
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "instances",
      "key": "server:public_ip_0"
    },
    "metrics": {
      "average_instance_count": 15.0364930555556,
      "total_cost": 18.7158268575025
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "instances",
      "key": "database:active"
    },
    "metrics": {
      "average_instance_count": 5.01793981481481,
      "total_cost": 7.82612257806182
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "instances",
      "key": "appserver:active"
    },
    "metrics": {
      "average_instance_count": 4.01357638888889,
      "total_cost": 7.65706713604762
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "instances",
      "key": "rs_launch:type"
    },
    "metrics": {
      "average_instance_count": 4.01357638888889,
      "total_cost": 7.65706713604762
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "instances",
      "key": "loadbalancer:default"
    },
    "metrics": {
      "average_instance_count": 8.50732638888889,
      "total_cost": 7.35703541347038
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "instances",
      "key": "cpa:test"
    },
    "metrics": {
      "average_instance_count": 1.0,
      "total_cost": 3.192
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "instances",
      "key": "appserver:listen_ip"
    },
    "metrics": {
      "average_instance_count": 2.51122685185185,
      "total_cost": 2.47666886236996
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "instances",
      "key": "appserver:listen_port"
    },
    "metrics": {
      "average_instance_count": 2.51122685185185,
      "total_cost": 2.47666886236996
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "instances",
      "key": "rs_dbrepl:master_active"
    },
    "metrics": {
      "average_instance_count": 1.5075,
      "total_cost": 2.47505970079875
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "instances",
      "key": "rs_dbrepl:master_instance_uuid"
    },
    "metrics": {
      "average_instance_count": 1.5075,
      "total_cost": 2.47505970079875
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "instances",
      "key": "rs_dbrepl:slave_instance_uuid"
    },
    "metrics": {
      "average_instance_count": 1.51043981481481,
      "total_cost": 2.47106378359984
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "instances",
      "key": "rs_monitoring:security_updates_available"
    },
    "metrics": {
      "average_instance_count": 7.0,
      "total_cost": 1.44000000273725
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "instances",
      "key": "rs_vote:DR+T2+App+Server+Tier"
    },
    "metrics": {
      "average_instance_count": 1.0,
      "total_cost": 0.0
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "tag_resource_type": "instances",
      "key": "rs_vote:PROD-APP"
    },
    "metrics": {
      "average_instance_count": 2.0,
      "total_cost": 0.0
    },
    "breakdown_metrics_results": [

    ]
  }
]

The two most expensive tags were account tags. This is to be expected because the user in these examples only has access to one account. The tags with the selfservice namespace are automatically added by RightScale Self-Service, so approximately 57% of the costs for this day were from Self-Service managed instances.

(Note: because an instance can have multiple tags, the sum of the total cost will not be the same as the total instance cost for that time period, because the same instances can be counted under multiple groups. For the total without grouping, use InstanceMetrics#overall.)

Filtering Instances

Calls to Instances resources can, where available, be filtered by passing the instance_filters parameter. To get a list of the available filters, use the Instances#filter_options call. This one shows the platforms (operating systems) used on our account during 1 May 2015:

curl -Gs https://analytics.rightscale.com/api/instances/actions/filter_options \
      -b rightscalecookies \
      -H X-Api-Version:1.0 \
      -d start_time=2015-05-01 \
      -d end_time=2015-05-02 \
      -d filter_types='["instance:platform"]'
[
  {
    "kind": "ca#filter",
    "type": "instance:platform",
    "value": "Linux/UNIX",
    "label": "Linux/UNIX",
    "tag_resource_type": null
  },
  {
    "kind": "ca#filter",
    "type": "instance:platform",
    "value": "Windows",
    "label": "Windows",
    "tag_resource_type": null
  }
]

We can then filter our previous grouped overall request by platform, by passing one of these filters as well (for Instances, only the type and value attributes are required, along with tag_resource_type if the filter is a tag filter):

curl -Gs https://analytics.rightscale.com/api/instance_metrics/actions/grouped_overall \
      -b rightscalecookies \
      -H X-Api-Version:1.0 \
      -d start_time=2015-05-01 \
      -d end_time=2015-05-02 \
      -d group='["tag_resource_type","tag_key"]' \
      -d metrics='["total_cost","average_instance_count"]' \
      -d order='["-total_cost"]' \
      -d instance_filters='[{"type":"instance:platform","value":"Windows"}]'
[
  {
    "kind": "ca#metrics_result",
    "group": {
      "key": "account:demo"
    },
    "metrics": {
      "average_instance_count": 6.0031712962963,
      "total_cost": 20.1016117806857
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "key": "rs_report:include"
    },
    "metrics": {
      "average_instance_count": 6.0031712962963,
      "total_cost": 20.1016117806857
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "key": "ec2:Name"
    },
    "metrics": {
      "average_instance_count": 5.0031712962963,
      "total_cost": 16.909611775779
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "key": "selfservice:href"
    },
    "metrics": {
      "average_instance_count": 4.0031712962963,
      "total_cost": 13.717611775779
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "key": "selfservice:launched_from_type"
    },
    "metrics": {
      "average_instance_count": 4.0031712962963,
      "total_cost": 13.717611775779
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "key": "rs_monitoring:state"
    },
    "metrics": {
      "average_instance_count": 4.0031712962963,
      "total_cost": 13.717611775779
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "key": "selfservice:launched_by"
    },
    "metrics": {
      "average_instance_count": 4.0031712962963,
      "total_cost": 13.717611775779
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "key": "selfservice:launched_from"
    },
    "metrics": {
      "average_instance_count": 4.0031712962963,
      "total_cost": 13.717611775779
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "key": "rs_launch:type"
    },
    "metrics": {
      "average_instance_count": 1.50234953703704,
      "total_cost": 5.18039827367766
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "key": "appserver:active"
    },
    "metrics": {
      "average_instance_count": 1.50234953703704,
      "total_cost": 5.18039827367766
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "key": "server:uuid"
    },
    "metrics": {
      "average_instance_count": 1.50234953703704,
      "total_cost": 5.18039827367766
    },
    "breakdown_metrics_results": [

    ]
  },
  {
    "kind": "ca#metrics_result",
    "group": {
      "key": "cpa:test"
    },
    "metrics": {
      "average_instance_count": 1.0,
      "total_cost": 3.192
    },
    "breakdown_metrics_results": [

    ]
  }
]

We can see that there are no loadbalancer:default tags here, because the instances with that tag on this account are all Linux, rather than Windows.

Showing Running Instances

The number of running instances is given by the InstanceMetrics#current_count call, which takes no parameters:

curl -Gs https://analytics.rightscale.com/api/instance_metrics/actions/current_count \
      -b rightscalecookies \
      -H X-Api-Version:1.0
{
  "current_instances_count": 21
}

That is not necessarily very interesting, though. Which instances are running will be more useful. The instance:state can be used for this, so we get the possible values:

curl -Gs https://analytics.rightscale.com/api/instances/actions/filter_options \
      -b rightscalecookies \
      -H X-Api-Version:1.0 \
      -d start_time=2015-06-05 \
      -d end_time=2015-06-06 \
      -d filter_types='["instance:state"]'
[
  {
    "kind": "ca#filter",
    "type": "instance:state",
    "value": "terminated",
    "label": "terminated",
    "tag_resource_type": null
  },
  {
    "kind": "ca#filter",
    "type": "instance:state",
    "value": "stopped",
    "label": "stopped",
    "tag_resource_type": null
  },
  {
    "kind": "ca#filter",
    "type": "instance:state",
    "value": "operational",
    "label": "operational",
    "tag_resource_type": null
  },
  {
    "kind": "ca#filter",
    "type": "instance:state",
    "value": "booting",
    "label": "booting",
    "tag_resource_type": null
  }
]

The available values are terminated, stopped, operational, and booting. From these, we want operational and booting instances, so we pass the appropriate filters to Instances#index:

curl -Gs https://analytics.rightscale.com/api/instances \
      -b rightscalecookies \
      -H X-Api-Version:1.0 \
      -d start_time=2015-06-05 \
      -d end_time=2015-06-06 \
      -d instance_filters='[{"type":"instance:state","value":"operational"},{"type":"instance:state","value":"booting"}]'
[
  {
    "kind": "ca#instance",
    "instance_key": "30601::6::i-59b36a6f",
    "instance_uid": "i-59b36a6f",
    "instance_rsid": "D3FSLG9QJ6BPI",
    "account_id": 30601,
    "account_name": "[RS Demo] Hybrid Cloud",
    "instance_start_at": "2013-12-19T01:33:57+00:00",
    "cloud_vendor_name": "Amazon Web Services",
    "cloud_id": 6,
    "cloud_name": "EC2 us-west-2",
    "datacenter_key": "6::us-west-2b",
    "datacenter_name": "us-west-2b",
    "deployment_id": 444420003,
    "deployment_name": "3-Tier w/ DR",
    "instance_type_key": "5::m1.small",
    "instance_type_name": "m1.small",
    "instance_name": "PROD T1 LB2",
    "server_template_id": 327687003,
    "server_template_name": "Load Balancer with HAProxy (v13.5)",
    "platform": "Linux/UNIX",
    "provisioned_by_user_id": 42138,
    "provisioned_by_user_email": "ryan.geyer@rightscale.com",
    "incarnator_id": 955019003,
    "incarnator_type": "Server",
    "state": "operational",
    "total_usage_hours": 14.2575,
    "estimated_cost_for_period": 0.0,
    "estimated_managed_rcu_count_for_period": 0.0
  },
  {
    "kind": "ca#instance",
    "instance_key": "30601::6::i-4e6b2b47",
    "instance_uid": "i-4e6b2b47",
    "instance_rsid": "41T45JQGC1FS8",
    "account_id": 30601,
    "account_name": "[RS Demo] Hybrid Cloud",
    "instance_start_at": "2014-04-03T15:00:30+00:00",
    "cloud_vendor_name": "Amazon Web Services",
    "cloud_id": 6,
    "cloud_name": "EC2 us-west-2",
    "datacenter_key": "6::us-west-2a",
    "datacenter_name": "us-west-2a",
    "deployment_id": 444420003,
    "deployment_name": "3-Tier w/ DR",
    "instance_type_key": "5::m1.small",
    "instance_type_name": "m1.small",
    "instance_name": "PROD T1 LB1",
    "server_template_id": 327687003,
    "server_template_name": "Load Balancer with HAProxy (v13.5)",
    "platform": "Linux/UNIX",
    "provisioned_by_user_id": 3472,
    "provisioned_by_user_email": "matthew@rightscale.com",
    "incarnator_id": 952612003,
    "incarnator_type": "Server",
    "state": "operational",
    "total_usage_hours": 14.2575,
    "estimated_cost_for_period": 0.0,
    "estimated_managed_rcu_count_for_period": 0.0
  },
  {
    "kind": "ca#instance",
    "instance_key": "30601::6::i-97c5979e",
    "instance_uid": "i-97c5979e",
    "instance_rsid": "A0QARNLSITSA7",
    "account_id": 30601,
    "account_name": "[RS Demo] Hybrid Cloud",
    "instance_start_at": "2014-04-15T06:42:40+00:00",
    "cloud_vendor_name": "Amazon Web Services",
    "cloud_id": 6,
    "cloud_name": "EC2 us-west-2",
    "datacenter_key": "6::us-west-2a",
    "datacenter_name": "us-west-2a",
    "deployment_id": 444420003,
    "deployment_name": "3-Tier w/ DR",
    "instance_type_key": "5::m1.large",
    "instance_type_name": "m1.large",
    "instance_name": "PROD T3 DB Master",
    "server_template_id": 327688003,
    "server_template_name": "Database Manager for MySQL 5.5 (v13.5)",
    "platform": "Linux/UNIX",
    "provisioned_by_user_id": 65467,
    "provisioned_by_user_email": "bruno.ciscato@rightscale.com",
    "incarnator_id": 952611003,
    "incarnator_type": "Server",
    "state": "operational",
    "total_usage_hours": 14.2575,
    "estimated_cost_for_period": 0.0,
    "estimated_managed_rcu_count_for_period": 0.0
  },
  {
    "kind": "ca#instance",
    "instance_key": "30601::6::i-0935f301",
    "instance_uid": "i-0935f301",
    "instance_rsid": "54730DUUI1TII",
    "account_id": 30601,
    "account_name": "[RS Demo] Hybrid Cloud",
    "instance_start_at": "2014-04-15T06:42:44+00:00",
    "cloud_vendor_name": "Amazon Web Services",
    "cloud_id": 6,
    "cloud_name": "EC2 us-west-2",
    "datacenter_key": "6::us-west-2b",
    "datacenter_name": "us-west-2b",
    "deployment_id": 444420003,
    "deployment_name": "3-Tier w/ DR",
    "instance_type_key": "5::m1.large",
    "instance_type_name": "m1.large",
    "instance_name": "PROD T3 DB Slave",
    "server_template_id": 327688003,
    "server_template_name": "Database Manager for MySQL 5.5 (v13.5)",
    "platform": "Linux/UNIX",
    "provisioned_by_user_id": 65467,
    "provisioned_by_user_email": "bruno.ciscato@rightscale.com",
    "incarnator_id": 955018003,
    "incarnator_type": "Server",
    "state": "operational",
    "total_usage_hours": 14.2575,
    "estimated_cost_for_period": 0.0,
    "estimated_managed_rcu_count_for_period": 0.0
  },
  {
    "kind": "ca#instance",
    "instance_key": "30601::2183::i-69b1b038f",
    "instance_uid": "i-69b1b038f",
    "instance_rsid": "F2MVJ5JRSTE7T",
    "account_id": 30601,
    "account_name": "[RS Demo] Hybrid Cloud",
    "instance_start_at": "2014-07-12T08:52:56+00:00",
    "cloud_vendor_name": "Microsoft Azure",
    "cloud_id": 2183,
    "cloud_name": "Azure West Europe",
    "datacenter_key": "2183::",
    "deployment_id": 444420003,
    "deployment_name": "3-Tier w/ DR",
    "instance_type_key": "8::small",
    "instance_type_name": "small",
    "instance_name": "DR T3 DB Slave",
    "server_template_id": 327688003,
    "server_template_name": "Database Manager for MySQL 5.5 (v13.5)",
    "platform": "Linux/UNIX",
    "provisioned_by_user_id": 65467,
    "provisioned_by_user_email": "bruno.ciscato@rightscale.com",
    "incarnator_id": 990320003,
    "incarnator_type": "Server",
    "state": "operational",
    "total_usage_hours": 14.2575,
    "estimated_cost_for_period": 0.855450001626096,
    "estimated_managed_rcu_count_for_period": 0.0
  },
  {
    "kind": "ca#instance",
    "instance_key": "30601::6::i-287f5b23",
    "instance_uid": "i-287f5b23",
    "instance_rsid": "177N0Q6ENPOGG",
    "account_id": 30601,
    "account_name": "[RS Demo] Hybrid Cloud",
    "instance_start_at": "2014-08-31T22:18:04+00:00",
    "cloud_vendor_name": "Amazon Web Services",
    "cloud_id": 6,
    "cloud_name": "EC2 us-west-2",
    "datacenter_key": "6::us-west-2a",
    "datacenter_name": "us-west-2a",
    "deployment_id": 444420003,
    "deployment_name": "3-Tier w/ DR",
    "instance_type_key": "5::c1.medium",
    "instance_type_name": "c1.medium",
    "instance_name": "PROD App Server Tier #30",
    "server_template_id": 327686003,
    "server_template_name": "PHP App Server (v13.5)",
    "platform": "Linux/UNIX",
    "provisioned_by_user_id": 0,
    "incarnator_id": 226682003,
    "incarnator_type": "ServerArray",
    "state": "operational",
    "total_usage_hours": 14.2575,
    "estimated_cost_for_period": 0.0,
    "estimated_managed_rcu_count_for_period": 0.0
  },
  {
    "kind": "ca#instance",
    "instance_key": "30601::6::i-2b7f5b20",
    "instance_uid": "i-2b7f5b20",
    "instance_rsid": "E5O0I0TUFG6A4",
    "account_id": 30601,
    "account_name": "[RS Demo] Hybrid Cloud",
    "instance_start_at": "2014-08-31T22:18:10+00:00",
    "cloud_vendor_name": "Amazon Web Services",
    "cloud_id": 6,
    "cloud_name": "EC2 us-west-2",
    "datacenter_key": "6::us-west-2a",
    "datacenter_name": "us-west-2a",
    "deployment_id": 444420003,
    "deployment_name": "3-Tier w/ DR",
    "instance_type_key": "5::c1.medium",
    "instance_type_name": "c1.medium",
    "instance_name": "PROD App Server Tier #31",
    "server_template_id": 327686003,
    "server_template_name": "PHP App Server (v13.5)",
    "platform": "Linux/UNIX",
    "provisioned_by_user_id": 0,
    "incarnator_id": 226682003,
    "incarnator_type": "ServerArray",
    "state": "operational",
    "total_usage_hours": 14.2575,
    "estimated_cost_for_period": 0.0,
    "estimated_managed_rcu_count_for_period": 0.0
  },
  {
    "kind": "ca#instance",
    "instance_key": "30601::1::i-6e0f579f",
    "instance_uid": "i-6e0f579f",
    "instance_rsid": "D0NMOTAUIF0B0",
    "account_id": 30601,
    "account_name": "[RS Demo] Hybrid Cloud",
    "instance_start_at": "2015-02-11T18:38:41+00:00",
    "cloud_vendor_name": "Amazon Web Services",
    "cloud_id": 1,
    "cloud_name": "EC2 us-east-1",
    "datacenter_key": "1::us-east-1e",
    "datacenter_name": "us-east-1e",
    "instance_type_key": "5::m1.medium",
    "instance_type_name": "m1.medium",
    "instance_name": "Webinar Instance",
    "platform": "Linux/UNIX",
    "provisioned_by_user_id": 29927,
    "provisioned_by_user_email": "shivan@rightscale.com",
    "state": "operational",
    "total_usage_hours": 14.2575,
    "estimated_cost_for_period": 1.24040250261006,
    "estimated_managed_rcu_count_for_period": 0.0
  },
  {
    "kind": "ca#instance",
    "instance_key": "30601::6::i-f3cdc9ff",
    "instance_uid": "i-f3cdc9ff",
    "instance_rsid": "DRAIJCSKGT9NU",
    "account_id": 30601,
    "account_name": "[RS Demo] Hybrid Cloud",
    "instance_start_at": "2015-02-24T15:31:20+00:00",
    "cloud_vendor_name": "Amazon Web Services",
    "cloud_id": 6,
    "cloud_name": "EC2 us-west-2",
    "datacenter_key": "6::us-west-2b",
    "datacenter_name": "us-west-2b",
    "instance_type_key": "5::t1.micro",
    "instance_type_name": "t1.micro",
    "instance_name": "Ubuntu_10.04_x64_v5.8.8_EBS",
    "platform": "Linux/UNIX",
    "provisioned_by_user_id": 81064,
    "provisioned_by_user_email": "mitchell.gerdisch@rightscale.com",
    "state": "operational",
    "total_usage_hours": 14.2575,
    "estimated_cost_for_period": 0.285149998038092,
    "estimated_managed_rcu_count_for_period": 0.0
  },
  {
    "kind": "ca#instance",
    "instance_key": "30601::1::i-3b1463d4",
    "instance_uid": "i-3b1463d4",
    "instance_rsid": "32HR4HIEOIAPQ",
    "account_id": 30601,
    "account_name": "[RS Demo] Hybrid Cloud",
    "instance_start_at": "2015-03-02T20:08:58+00:00",
    "cloud_vendor_name": "Amazon Web Services",
    "cloud_id": 1,
    "cloud_name": "EC2 us-east-1",
    "datacenter_key": "1::us-east-1a",
    "datacenter_name": "us-east-1a",
    "deployment_id": 59344,
    "deployment_name": "Default",
    "instance_type_key": "5::m1.small",
    "instance_type_name": "m1.small",
    "instance_name": "AWS VPC NAT",
    "server_template_id": 352499003,
    "server_template_name": "AWS VPC NAT ServerTemplate (v14.0.1)",
    "platform": "Linux/UNIX",
    "provisioned_by_user_id": 81064,
    "provisioned_by_user_email": "mitchell.gerdisch@rightscale.com",
    "incarnator_id": 1078304003,
    "incarnator_type": "Server",
    "state": "operational",
    "total_usage_hours": 14.2575,
    "estimated_cost_for_period": 0.627330002138831,
    "estimated_managed_rcu_count_for_period": 0.0
  },
  {
    "kind": "ca#instance",
    "instance_key": "30601::1::i-d3eba623",
    "instance_uid": "i-d3eba623",
    "instance_rsid": "26F7T1MKMNV92",
    "account_id": 30601,
    "account_name": "[RS Demo] Hybrid Cloud",
    "instance_start_at": "2015-03-18T07:17:58+00:00",
    "cloud_vendor_name": "Amazon Web Services",
    "cloud_id": 1,
    "cloud_name": "EC2 us-east-1",
    "datacenter_key": "1::us-east-1e",
    "datacenter_name": "us-east-1e",
    "instance_type_key": "5::t1.micro",
    "instance_type_name": "t1.micro",
    "platform": "Linux/UNIX",
    "state": "operational",
    "total_usage_hours": 14.2575,
    "estimated_cost_for_period": 0.285150000832628,
    "estimated_managed_rcu_count_for_period": 0.0
  },
  {
    "kind": "ca#instance",
    "instance_key": "30601::1::i-78fbb688",
    "instance_uid": "i-78fbb688",
    "instance_rsid": "6TQKASRQAHTFR",
    "account_id": 30601,
    "account_name": "[RS Demo] Hybrid Cloud",
    "instance_start_at": "2015-03-18T07:32:38+00:00",
    "cloud_vendor_name": "Amazon Web Services",
    "cloud_id": 1,
    "cloud_name": "EC2 us-east-1",
    "datacenter_key": "1::us-east-1e",
    "datacenter_name": "us-east-1e",
    "instance_type_key": "5::m3.medium",
    "instance_type_name": "m3.medium",
    "instance_name": "BrunoWinRl6",
    "platform": "Windows",
    "provisioned_by_user_id": 65467,
    "provisioned_by_user_email": "bruno.ciscato@rightscale.com",
    "state": "operational",
    "total_usage_hours": 14.2575,
    "estimated_cost_for_period": 1.8962475,
    "estimated_managed_rcu_count_for_period": 0.0
  },
  {
    "kind": "ca#instance",
    "instance_key": "30601::1::i-27f0bdd7",
    "instance_uid": "i-27f0bdd7",
    "instance_rsid": "7H7DRFTDIIJTV",
    "account_id": 30601,
    "account_name": "[RS Demo] Hybrid Cloud",
    "instance_start_at": "2015-03-18T07:43:01+00:00",
    "cloud_vendor_name": "Amazon Web Services",
    "cloud_id": 1,
    "cloud_name": "EC2 us-east-1",
    "datacenter_key": "1::us-east-1e",
    "datacenter_name": "us-east-1e",
    "instance_type_key": "5::m3.medium",
    "instance_type_name": "m3.medium",
    "platform": "Windows",
    "state": "operational",
    "total_usage_hours": 14.2575,
    "estimated_cost_for_period": 1.89624750291484,
    "estimated_managed_rcu_count_for_period": 0.0
  },
  {
    "kind": "ca#instance",
    "instance_key": "30601::6::i-ecfb441b",
    "instance_uid": "i-ecfb441b",
    "instance_rsid": "5VCMP5QPSD1JE",
    "account_id": 30601,
    "account_name": "[RS Demo] Hybrid Cloud",
    "instance_start_at": "2015-05-15T17:54:13+00:00",
    "cloud_vendor_name": "Amazon Web Services",
    "cloud_id": 6,
    "cloud_name": "EC2 us-west-2",
    "datacenter_key": "6::us-west-2a",
    "datacenter_name": "us-west-2a",
    "deployment_id": 509558003,
    "deployment_name": "CM future",
    "instance_type_key": "5::m1.small",
    "instance_type_name": "m1.small",
    "instance_name": "Base ServerTemplate for Linux",
    "server_template_id": 349567003,
    "server_template_name": "Base ServerTemplate for Linux (RSB) (v13.5.11-LTS)",
    "platform": "Linux/UNIX",
    "provisioned_by_user_id": 65467,
    "provisioned_by_user_email": "bruno.ciscato@rightscale.com",
    "incarnator_id": 1108563003,
    "incarnator_type": "Server",
    "state": "booting",
    "total_usage_hours": 14.2575,
    "estimated_cost_for_period": 0.237030928163065,
    "estimated_managed_rcu_count_for_period": 0.0
  },
  {
    "kind": "ca#instance",
    "instance_key": "30601::2179::i-a86ef4a19",
    "instance_uid": "i-a86ef4a19",
    "instance_rsid": "DUEJS384V0DR6",
    "account_id": 30601,
    "account_name": "[RS Demo] Hybrid Cloud",
    "instance_start_at": "2015-05-22T17:13:34+00:00",
    "cloud_vendor_name": "Microsoft Azure",
    "cloud_id": 2179,
    "cloud_name": "Azure East US",
    "datacenter_key": "2179::",
    "deployment_id": 511869003,
    "deployment_name": "ROL  - test-drbcsluw0j7n",
    "instance_type_key": "8::large",
    "instance_type_name": "large",
    "instance_name": "Tier 1 - LB 1",
    "server_template_id": 357605003,
    "server_template_name": "Load Balancer with HAProxy (v13.5.11-LTS)",
    "platform": "Linux/UNIX",
    "provisioned_by_user_id": 73964,
    "provisioned_by_user_email": "hassan+ca_demo2@rightscale.com",
    "incarnator_id": 1112104003,
    "incarnator_type": "Server",
    "state": "operational",
    "total_usage_hours": 14.2575,
    "estimated_cost_for_period": 3.4218,
    "estimated_managed_rcu_count_for_period": 0.0
  },
  {
    "kind": "ca#instance",
    "instance_key": "30601::2::i-4c7b94aa",
    "instance_uid": "i-4c7b94aa",
    "instance_rsid": "6LEBNHRMSG2NK",
    "account_id": 30601,
    "account_name": "[RS Demo] Hybrid Cloud",
    "instance_start_at": "2015-05-27T22:55:03+00:00",
    "cloud_vendor_name": "Amazon Web Services",
    "cloud_id": 2,
    "cloud_name": "EC2 eu-west-1",
    "datacenter_key": "2::eu-west-1a",
    "datacenter_name": "eu-west-1a",
    "deployment_id": 513156003,
    "deployment_name": "test lamp with new relic reporting-xd86s6tm0klv",
    "instance_type_key": "5::m1.small",
    "instance_type_name": "m1.small",
    "instance_name": "Tier 1 - LB 1",
    "server_template_id": 342260003,
    "server_template_name": "Load Balancer with HAProxy (v13.5.5-LTS)",
    "platform": "Linux/UNIX",
    "provisioned_by_user_id": 81064,
    "provisioned_by_user_email": "mitchell.gerdisch@rightscale.com",
    "incarnator_id": 1113268003,
    "incarnator_type": "Server",
    "state": "operational",
    "total_usage_hours": 14.2575,
    "estimated_cost_for_period": 0.670102480866756,
    "estimated_managed_rcu_count_for_period": 0.0
  },
  {
    "kind": "ca#instance",
    "instance_key": "30601::2::i-d27a9534",
    "instance_uid": "i-d27a9534",
    "instance_rsid": "9AUU3K1FFHB9B",
    "account_id": 30601,
    "account_name": "[RS Demo] Hybrid Cloud",
    "instance_start_at": "2015-05-27T22:55:12+00:00",
    "cloud_vendor_name": "Amazon Web Services",
    "cloud_id": 2,
    "cloud_name": "EC2 eu-west-1",
    "datacenter_key": "2::eu-west-1a",
    "datacenter_name": "eu-west-1a",
    "deployment_id": 513156003,
    "deployment_name": "test lamp with new relic reporting-xd86s6tm0klv",
    "instance_type_key": "5::m1.small",
    "instance_type_name": "m1.small",
    "instance_name": "Tier 1 - LB 2",
    "server_template_id": 342260003,
    "server_template_name": "Load Balancer with HAProxy (v13.5.5-LTS)",
    "platform": "Linux/UNIX",
    "provisioned_by_user_id": 81064,
    "provisioned_by_user_email": "mitchell.gerdisch@rightscale.com",
    "incarnator_id": 1113269003,
    "incarnator_type": "Server",
    "state": "operational",
    "total_usage_hours": 14.2575,
    "estimated_cost_for_period": 0.67010251530678,
    "estimated_managed_rcu_count_for_period": 0.0
  },
  {
    "kind": "ca#instance",
    "instance_key": "30601::2::i-dc7a953a",
    "instance_uid": "i-dc7a953a",
    "instance_rsid": "E71NE48BETG0B",
    "account_id": 30601,
    "account_name": "[RS Demo] Hybrid Cloud",
    "instance_start_at": "2015-05-27T22:55:30+00:00",
    "cloud_vendor_name": "Amazon Web Services",
    "cloud_id": 2,
    "cloud_name": "EC2 eu-west-1",
    "datacenter_key": "2::eu-west-1a",
    "datacenter_name": "eu-west-1a",
    "deployment_id": 513156003,
    "deployment_name": "test lamp with new relic reporting-xd86s6tm0klv",
    "instance_type_key": "5::m1.large",
    "instance_type_name": "m1.large",
    "instance_name": "Tier 3 - DB 1",
    "server_template_id": 342262003,
    "server_template_name": "Database Manager for MySQL 5.5 (v13.5.8-LTS)",
    "platform": "Linux/UNIX",
    "provisioned_by_user_id": 81064,
    "provisioned_by_user_email": "mitchell.gerdisch@rightscale.com",
    "incarnator_id": 1113270003,
    "incarnator_type": "Server",
    "state": "operational",
    "total_usage_hours": 14.2575,
    "estimated_cost_for_period": 2.70892500765358,
    "estimated_managed_rcu_count_for_period": 0.0
  },
  {
    "kind": "ca#instance",
    "instance_key": "30601::2::i-407b94a6",
    "instance_uid": "i-407b94a6",
    "instance_rsid": "31LF0R9GP4VFV",
    "account_id": 30601,
    "account_name": "[RS Demo] Hybrid Cloud",
    "instance_start_at": "2015-05-27T22:55:53+00:00",
    "cloud_vendor_name": "Amazon Web Services",
    "cloud_id": 2,
    "cloud_name": "EC2 eu-west-1",
    "datacenter_key": "2::eu-west-1a",
    "datacenter_name": "eu-west-1a",
    "deployment_id": 513156003,
    "deployment_name": "test lamp with new relic reporting-xd86s6tm0klv",
    "instance_type_key": "5::m1.large",
    "instance_type_name": "m1.large",
    "instance_name": "Tier 3 - DB 2",
    "server_template_id": 342262003,
    "server_template_name": "Database Manager for MySQL 5.5 (v13.5.8-LTS)",
    "platform": "Linux/UNIX",
    "provisioned_by_user_id": 81064,
    "provisioned_by_user_email": "mitchell.gerdisch@rightscale.com",
    "incarnator_id": 1113271003,
    "incarnator_type": "Server",
    "state": "operational",
    "total_usage_hours": 14.2575,
    "estimated_cost_for_period": 2.708925,
    "estimated_managed_rcu_count_for_period": 0.0
  },
  {
    "kind": "ca#instance",
    "instance_key": "30601::2::i-a3789745",
    "instance_uid": "i-a3789745",
    "instance_rsid": "984UMQHKNMOJS",
    "account_id": 30601,
    "account_name": "[RS Demo] Hybrid Cloud",
    "instance_start_at": "2015-05-27T22:59:06+00:00",
    "cloud_vendor_name": "Amazon Web Services",
    "cloud_id": 2,
    "cloud_name": "EC2 eu-west-1",
    "datacenter_key": "2::eu-west-1a",
    "datacenter_name": "eu-west-1a",
    "deployment_id": 513156003,
    "deployment_name": "test lamp with new relic reporting-xd86s6tm0klv",
    "instance_type_key": "5::m1.large",
    "instance_type_name": "m1.large",
    "instance_name": "Tier 2 - PHP App Servers #1",
    "server_template_id": 342261003,
    "server_template_name": "PHP App Server (v13.5.5-LTS)",
    "platform": "Linux/UNIX",
    "provisioned_by_user_id": 0,
    "incarnator_id": 321402003,
    "incarnator_type": "ServerArray",
    "state": "operational",
    "total_usage_hours": 14.2575,
    "estimated_cost_for_period": 2.70892500765579,
    "estimated_managed_rcu_count_for_period": 0.0
  },
  {
    "kind": "ca#instance",
    "instance_key": "30601::2::i-ae789748",
    "instance_uid": "i-ae789748",
    "instance_rsid": "336M51DJU24K0",
    "account_id": 30601,
    "account_name": "[RS Demo] Hybrid Cloud",
    "instance_start_at": "2015-05-27T22:59:12+00:00",
    "cloud_vendor_name": "Amazon Web Services",
    "cloud_id": 2,
    "cloud_name": "EC2 eu-west-1",
    "datacenter_key": "2::eu-west-1a",
    "datacenter_name": "eu-west-1a",
    "deployment_id": 513156003,
    "deployment_name": "test lamp with new relic reporting-xd86s6tm0klv",
    "instance_type_key": "5::m1.large",
    "instance_type_name": "m1.large",
    "instance_name": "Tier 2 - PHP App Servers #2",
    "server_template_id": 342261003,
    "server_template_name": "PHP App Server (v13.5.5-LTS)",
    "platform": "Linux/UNIX",
    "provisioned_by_user_id": 0,
    "incarnator_id": 321402003,
    "incarnator_type": "ServerArray",
    "state": "operational",
    "total_usage_hours": 14.2575,
    "estimated_cost_for_period": 2.70892498468829,
    "estimated_managed_rcu_count_for_period": 0.0
  }
]

This returns the 21 instances listed by the count call, but in much more detail.

Recreating the Cloud Analytics Dashboard

The Cloud Analytics dashboard view uses time-series and monthly summary data from the combined costs API. This API includes all data from the cloud bills and plugin costs sources, and fills in compute data from the instances source where no cloud bills data is available.

This section makes use of the jq command-line JSON processor. The jq filters are used to simplify the resulting data structures.

Time Series Data

The overview chart on the Cloud Analytics dashboard shows all cloud costs for Amazon Web Services, Google, and Microsoft Azure, combined with compute costs for all other providers, broken down by product category. We use the CombinedCosts#grouped_time_series API call for this:

curl -Gs https://analytics.rightscale.com/api/combined_costs/actions/grouped_time_series \
      -b rightscalecookies \
      -H X-Api-Version:1.0 \
      -d start_time=2015-03-01 \
      -d end_time=2016-03-01 \
      -d group='[["product_category"]]' |
  jq 'map({(.timestamp): .results | map({(.group.product_category): .metrics.total_cost}) | add}) | add'
{
  "2015-03-01T00:00:00+00:00": {
    "Subscriptions": 0,
    "Database": 0,
    "Application Services": 0,
    "Administration & Security": 0,
    "Other": 0,
    "Network": 0,
    "Storage": 0,
    "Compute": 1880.2918881777277
  },
  "2015-04-01T00:00:00+00:00": {
    "Subscriptions": 0,
    "Database": 45.64,
    "Application Services": 0,
    "Administration & Security": 0,
    "Other": 0.01,
    "Network": 2,
    "Storage": 0.02,
    "Compute": 1969.8303171935686
  },
  "2015-05-01T00:00:00+00:00": {
    "Subscriptions": 0,
    "Database": 47.96,
    "Application Services": 0,
    "Administration & Security": 0,
    "Other": 0.01,
    "Network": 1.69,
    "Storage": 0.02,
    "Compute": 1501.7689343828038
  },
  "2015-06-01T00:00:00+00:00": {
    "Subscriptions": 0,
    "Database": 47.08,
    "Application Services": 0,
    "Administration & Security": 0,
    "Other": 0.01,
    "Network": 1.79,
    "Storage": 0.02,
    "Compute": 1684.009451161174
  },
  "2015-07-01T00:00:00+00:00": {
    "Subscriptions": 0,
    "Database": 47.51,
    "Application Services": 0,
    "Administration & Security": 0,
    "Other": 0.01,
    "Network": 1.61,
    "Storage": 0.02,
    "Compute": 1583.6229458332132
  },
  "2015-08-01T00:00:00+00:00": {
    "Subscriptions": 0,
    "Database": 47.93,
    "Application Services": 0,
    "Administration & Security": 0,
    "Other": 0.01,
    "Network": 2.45,
    "Storage": 0.02,
    "Compute": 2657.8847303865123
  },
  "2015-09-01T00:00:00+00:00": {
    "Subscriptions": 0,
    "Database": 46.75,
    "Application Services": 0,
    "Administration & Security": 0,
    "Other": 0.0376,
    "Network": 1.6868999999999998,
    "Storage": 0.1779,
    "Compute": 4612.353831906075
  },
  "2015-10-01T00:00:00+00:00": {
    "Subscriptions": 0,
    "Database": 47.61,
    "Application Services": 0,
    "Administration & Security": 0,
    "Other": 0.22549999999999998,
    "Network": 16.900499999999997,
    "Storage": 21.0306,
    "Compute": 3838.982260399758
  },
  "2015-11-01T00:00:00+00:00": {
    "Subscriptions": 0,
    "Database": 47.02,
    "Application Services": 0,
    "Administration & Security": 0,
    "Other": 0.02,
    "Network": 41.689699999999995,
    "Storage": 47.2056,
    "Compute": 2883.112607669069
  },
  "2015-12-01T00:00:00+00:00": {
    "Subscriptions": 0,
    "Database": 47.61,
    "Application Services": 0,
    "Administration & Security": 0,
    "Other": 0.0385,
    "Network": 72.7907,
    "Storage": 17.993399999999998,
    "Compute": 2799.972725734674
  },
  "2016-01-01T00:00:00+00:00": {
    "Subscriptions": 0,
    "Database": 47.99,
    "Application Services": 0,
    "Administration & Security": 0,
    "Other": 0.02,
    "Network": 72.11400000000002,
    "Storage": 4.469499999999999,
    "Compute": 2647.4247049910464
  },
  "2016-02-01T00:00:00+00:00": {
    "Subscriptions": 0,
    "Database": 39.68,
    "Application Services": 0,
    "Administration & Security": 0,
    "Other": 0.02,
    "Network": 53.530100000000004,
    "Storage": 2.9091,
    "Compute": 2093.8078610132834
  }
}

(The data shown here is compute-only for March 2015, because we started processing Amazon Web Services full costs in April 2015.)

Monthly Breakdown

The monthly breakdown works in much the same way. This time, we only need data for a single month, so we set the start time and end time to restrict the data to a single month. This time, we group by cloud vendor name and cloud vendor account ID, then product, instead of product category. (All Instances data has the product and product category 'Compute'.)

curl -Gs https://analytics.rightscale.com/api/combined_costs/actions/grouped_time_series \
      -b rightscalecookies \
      -H X-Api-Version:1.0 \
      -d start_time=2016-01-01 \
      -d end_time=2016-02-01 \
      -d group='[["cloud_vendor_name","cloud_vendor_account_id"],["product"]]' |
  jq '.[0].results | map({(.group.cloud_vendor_name): {(.group.cloud_vendor_account_id): .breakdown_metrics_results | map ({(.group.product): .metrics.total_cost}) | add}}) | add'
{
  "VMware": {
    "HybridDemo_Tenant": {
      "Compute": 0.627026988666727
    }
  },
  "Amazon Web Services": {
    "440514240447": {
      "AmazonEC2": 517.77,
      "AmazonRDS": 47.99,
      "AmazonS3": 0.1,
      "AWSDataTransfer": 1.04,
      "AWSQueueService": 0.02
    }
  },
  "Google": {
    "rightscale.com:salesdemo": {
      "ForwardingRuleChargeBase": 18.6,
      "Licensed1000047F1Micro": 0,
      "NetworkCloudVpnInternetEgressEuEu": 0.017,
      "NetworkCloudVpnInternetEgressEuEu1": 0.1045,
      "NetworkGoogleEgressNaNa": 0,
      "NetworkGoogleIngressApacApac": 0,
      "NetworkGoogleIngressEuEu": 0,
      "NetworkGoogleIngressNaNa": 0,
      "NetworkInterConnectEgressNa": 0,
      "NetworkInterConnectIngressApac": 0,
      "NetworkInterConnectIngressNa": 0,
      "NetworkInternetEgressApacAf": 0,
      "NetworkInternetEgressApacApac": 0.0003,
      "NetworkInternetEgressApacAu": 0,
      "NetworkInternetEgressApacCa": 0,
      "NetworkInternetEgressApacCn": 0.0078,
      "NetworkInternetEgressApacEu": 0.0001,
      "NetworkInternetEgressApacEu1": 0.0002,
      "NetworkInternetEgressApacEu2": 0,
      "NetworkInternetEgressApacIn": 0.0001,
      "NetworkInternetEgressApacMe": 0,
      "NetworkInternetEgressApacNa": 0.0511,
      "NetworkInternetEgressApacSa": 0,
      "NetworkInternetEgressEuAf": 0.0024,
      "NetworkInternetEgressEuApac": 0.0043,
      "NetworkInternetEgressEuAu": 0,
      "NetworkInternetEgressEuCa": 0,
      "NetworkInternetEgressEuCn": 0.0077,
      "NetworkInternetEgressEuEu": 0.0003,
      "NetworkInternetEgressEuEu1": 0.0042,
      "NetworkInternetEgressEuEu2": 0.0004,
      "NetworkInternetEgressEuIn": 0.0002,
      "NetworkInternetEgressEuMe": 0,
      "NetworkInternetEgressEuNa": 0.0039,
      "NetworkInternetEgressEuSa": 0.0002,
      "NetworkInternetEgressNaAf": 0,
      "NetworkInternetEgressNaApac": 0.0067,
      "NetworkInternetEgressNaAu": 0,
      "NetworkInternetEgressNaCa": 0.0009,
      "NetworkInternetEgressNaCn": 0.0174,
      "NetworkInternetEgressNaEu": 0.0055,
      "NetworkInternetEgressNaEu1": 0.0004,
      "NetworkInternetEgressNaEu2": 0.0002,
      "NetworkInternetEgressNaIn": 0.0002,
      "NetworkInternetEgressNaMe": 0,
      "NetworkInternetEgressNaNa": 0.1613,
      "NetworkInternetEgressNaSa": 0.0005,
      "NetworkInternetIngressAfApac": 0,
      "NetworkInternetIngressAfEu": 0,
      "NetworkInternetIngressAfNa": 0,
      "NetworkInternetIngressApacApac": 0,
      "NetworkInternetIngressApacEu": 0,
      "NetworkInternetIngressApacNa": 0,
      "NetworkInternetIngressAuApac": 0,
      "NetworkInternetIngressAuEu": 0,
      "NetworkInternetIngressAuNa": 0,
      "NetworkInternetIngressCaApac": 0,
      "NetworkInternetIngressCaEu": 0,
      "NetworkInternetIngressCaNa": 0,
      "NetworkInternetIngressCnApac": 0,
      "NetworkInternetIngressCnEu": 0,
      "NetworkInternetIngressCnNa": 0,
      "NetworkInternetIngressEu1Apac": 0,
      "NetworkInternetIngressEu1Eu": 0,
      "NetworkInternetIngressEu1Na": 0,
      "NetworkInternetIngressEu2Apac": 0,
      "NetworkInternetIngressEu2Eu": 0,
      "NetworkInternetIngressEu2Na": 0,
      "NetworkInternetIngressEuApac": 0,
      "NetworkInternetIngressEuEu": 0,
      "NetworkInternetIngressEuNa": 0,
      "NetworkInternetIngressInApac": 0,
      "NetworkInternetIngressInEu": 0,
      "NetworkInternetIngressInNa": 0,
      "NetworkInternetIngressMeApac": 0,
      "NetworkInternetIngressMeEu": 0,
      "NetworkInternetIngressMeNa": 0,
      "NetworkInternetIngressNaApac": 0,
      "NetworkInternetIngressNaEu": 0,
      "NetworkInternetIngressNaNa": 0,
      "NetworkInternetIngressSaApac": 0,
      "NetworkInternetIngressSaEu": 0,
      "NetworkInternetIngressSaNa": 0,
      "NetworkInterRegionEgressApacNa": 0,
      "NetworkInterRegionEgressEuNa": 0,
      "NetworkInterRegionIngressApacEu": 0,
      "NetworkInterRegionIngressApacNa": 0,
      "NetworkInterRegionIngressEuApac": 0,
      "NetworkInterRegionIngressEuNa": 0,
      "NetworkInterRegionIngressNaApac": 0,
      "NetworkInterRegionIngressNaEu": 0,
      "NetworkInterRegionIngressNaNa": 0,
      "NetworkInterZoneEgress": 0,
      "NetworkInterZoneIngress": 0,
      "NetworkIntraZoneEgress": 0,
      "NetworkIntraZoneIngress": 0,
      "StaticIpCharge": 14.87,
      "StorageGbsec": 1.5655,
      "StorageImage": 0.0899,
      "StoragePdCapacity": 2.1157,
      "StoragePdSnapshot": 0.0124,
      "VmimageF1Micro_Eu": 4.6872,
      "VmimageN1Highcpu_4": 0.0988,
      "VmimageN1Standard_1": 26.0394,
      "VmimageN1Standard_1_Apac": 28.6433,
      "VmimageN1Standard_2": 121.5901,
      "VmimageN1Standard_4": 25.9867,
      "VmimageN1Standard_8": 11.0667,
      "VpnTunnelDefault": 37.1966
    }
  },
  "Microsoft Azure": {
    "bd94cb61-9df6-4955-8c88-9e765333fe14": {
      "Data Management": 0,
      "Networking": 0.0096,
      "Storage": 0.586,
      "Virtual Machines": 4.8817,
      "Windows Azure Storage": 0
    }
  }
}

Next Steps

The Cloud Analytics API reference contains detailed descriptions of the calls available and their parameters.