How Metering API works
Overview on Metering API
Metering API is how IBM, partners, and clients submit usage data. This data flows into customer dashboards and analytics services and facilitates billing for pay-as-you-go subscriptions.
Changes and version control for Metering API
Metering API adheres to the following change policy for minor versions:
- Existing endpoints and fields MUST NOT be removed or renamed.
- New OPTIONAL endpoints, or new HTTP methods for existing endpoints, MAY be added to enable support for new features.
- New fields MAY be added to existing request/response messages. These fields MUST be OPTIONAL and SHOULD be ignored by clients and servers that do not understand them.
Changes since latest release
- Initial Version - No changes being documented
Authentication
All communication will be over HTTPS with a self-signed certificate. All messages are authenticated using basic authentication. When authentication fails, partners must respond with 401 Unauthorized
.
Authentication uses an Authorization header and the Bearer scheme.
Authorization: Bearer <token>
The token must be one of:
- A Pull Secret generated for an IBM Software Central or Red Hat Marketplace account
- An IBM Entitlement Key
- An access token
File upload API
The request is a multipart form-data request and consisting of a single application/gzip
archive file. The archive file must contain a single manifest.json file at the root level.
If the archive file does not have the manifest.json file, or if the file exists but is invalid then no data from the archive will be processed.
The maximum size for the archive file is 1MiB.
Archive file structure
The archive will contain one manifest.json file and one or more data files that will be processed based on the type in the manifest file.
Manifest file content
{"version": "1","type": "<manifest types>"}
Property | Required | Type | Description |
---|---|---|---|
version | yes | string | Version of manifest file format. Currently only “1” is allowed. |
type | yes | string | The type of data being sent. Supported types are “swcAccountMetrics”, “accountMetrics”, and “dataReporter”. |
Data files
swcAccountMetrics type
This is the preferred type.
swcAccountMetrics
properties will be defined in usage events and additional properties. They can either be a root
level or measuredUsage
level property, as shown in Additional properties.
Every file in the archive must be well-formed JSON with correct schema as described below. If any file in the archive is invalid then the entire archive will not be processed.
Example
{"data": [{"eventId": "unique guid per individual event","start": 1485907200001,"end": 1485910800000,"accountId": "IBM Software Central or Red Hat Marketplace account id","subscriptionId": "optionalValue","productId": "sampleProductId","productName": "IBM Cloud Pak for Data Enterprise Edition","licensePartNumber": "part1234","productType": "bundled or product","source": "MCSP","sourceSaas": "AWS, IBMCloud, etc","accountIdSaas": "operationalSassAccountId","subscriptionIdSaas": "20230414","dswOfferAccountingSystemCode": "TRBO","dswSubscriptionAgreementNumber": "string","ssmSubscriptionId": "ssmSubsctriptionId","sapEntitlementLine": "testEntitlement","icn": "icnString","group": "c8b82d189e03845.source.group.com","groupName": "groupName","kind": "IBMLicensing","manual": "false","parentProductId": "productIdOfParentProduct","parentMetricId": "VIRTUAL_PROCESSOR_CORE","topLevelProductId": "productIdOfTopLevelProduct","topLevelMetricId": "VIRTUAL_PROCESSOR_CORE","measuredUsage": [{"metricId": "metric id","value": 8,"start": 1485907200001,"end": 1485910800000,"metricAggregationType": "cummulative","metricType": "paygo","crn": "crn:version:cname:ctype:service-name:location:scope:service-instance:resource-type:resource","dedupCorrelationId": "optional-from-DRO-b2a7-d7ca4c5c76d4","clusterId": "222222-6767-4c3a-xxxx-d7ca4c5c76d4","hostname": "demo-metric-hostname-675b5dcff-cqj6n","pod": "demo-metric-pod-cqj6n","platformId": "platform-cqj6n","namespace": "namespace1","meter_def_namespace": "namespace1","measuredMetricId": "VIRTUAL_PROCESSOR_CORE","measuredValue": "7","productConversionRatio": "3:1"}]}],"metadata": {}}
accountMetrics type
The accountMetrics type is for product usage metrics for an IBM Software Central or Red Hat Marketplace account. Every file in the archive must be well-formed JSON with correct schema as described below. If any file in the archive is invalid then the entire archive will not be processed.
Example
{"data": [{"eventId": "unique guid per individual event","start": <UTC milliseconds timestamp>,"end": <UTC milliseconds timestamp>,"accountId": "IBM Software Central or Red Hat Marketplace account id""additionalAttributes": {},"measuredUsage": [{"metricId": "metric id","value": <numeric value>,"additionalAttributes": {}}]}],"metadata": {}}
Account metrics file properties
Property | Required | Type | Description |
---|---|---|---|
data | yes | array | Array of usage event objects. See below. |
metadata | no | object | This field is allowed, but it currently has no effect on processing. |
Usage event properties
Property | Required | Type | Description |
---|---|---|---|
eventId | yes | string | A value uniquely identifying the event. A second event with the same eventId will be processed as an amendment. Two events in the same archive MUST NOT have the same eventId. Recommended to be a GUID. |
start | no | integer | UTC milliseconds timestamp representing the start of the window for usage data being reported. Must be before end . Must be present here if end is present here. If present here, must not be in measuredUsage . |
end | no | integer | UTC milliseconds timestamp representing the end of the window for usage data being reported. Must be after start but before the time data is received. Must be present here if start is present here. If present here, must not be in measuredUsage . |
accountId | no | string | The id of the IBM Software Central or Red Hat Marketplace account that usage is being reported for. |
subscriptionId | no | string | The id of the IBM Software Central or Red Hat Marketplace subscription for the product that usage is being reported for. |
additionalAttributes | yes | object | An object for other values related to the usage data. This object will be merged with measuredUsage additionalAttributes for processing. additionalAttributes must not appear in swcAccountMetrics measuredUsage . additionalAttributes can only appear in measuredUsage on accountMetrics . See “Measured usage properties” and “Additional properties” below. |
measuredUsage | yes | array | Array of measuredUsage objects. See “Measured usage properties” below. |
Measured usage properties
Property | Required | Type | Description |
---|---|---|---|
metricId | yes | string | The id of the metric being reported. |
value | yes | number | The recorded usage value for the time window. |
start | no | integer | UTC milliseconds timestamp representing the start of the window for usage data being reported. Must be before end . Must be present here if end is present here. If present here, must not be in usage event above. |
end | no | integer | UTC milliseconds timestamp representing the end of the window for usage data being reported. Must be after start but before the time data is received. Must be present here if start is present here. If present here, must not be in usage event above. |
additionalAttributes | no | object | Additional attributes associated with the metric. This object will be merged with overall additionalAttributes . If the same property appears in both then priority will be given to the value in measuredUsage additionalAttributes . additionalAttributes must not appear in swcAccountMetrics measuredUsage . additionalAttributes can only appear in measuredUsage on accountMetrics . Note: measuredUsage additionalAttributes is only allowed in data submitted via the “File upload API”. It is not valid in data submitted via the legacy Metering API. |
Additional properties
These properties provide additional information about the usage. They are all initially optional, but the value of one property may influence the values that other properties can or must have. Unknown properties must have no effect on processing, but they will be saved. All property values are strings.
In swcAccountMetrics
, properties can either appear as root
properties or as properties under measuredUsage
. The swcAccountMetrics
column in the table below illustrates which properties belong in root
or measuredUsage
.
In accountMetrics
they can appear in an additionalAttributes
field at either the root
or measuredUsage
level. The accountMetrics
column in the table below describes which additionalAttributes
each property can appear in. “either” in this column means it can appear in either the root
level additionalAttributes
or in the measuredUsage
addtionalAttributes
.
Attribute | Description | swcAccountMetrics | accountMetrics |
---|---|---|---|
clusterId | The id for the cluster. This value is required if source is LS. | measuredUsage | either |
hostname | The id for the host reporting data. This value is required if source is ILMT. | measuredUsage | either |
group | The group name in the CustomResourceDefinition representing the meter definition deployed to the cluster. This value is required if source is LS. | root | either |
groupName | A group name indicates a chargeback/tag group for the usage coming from containerized environments. This will be used to identify a namespace, the labels on the namespace and apply matching IBM Software Central or Red Hat Marketplace tags to the usage. | root | either |
kind | The kind identified in CustomResourceDefinition. This value is required if source is LS. | root | either |
namespace | The namespace from where the data was reported. This value or meter_def_namespace is required if source is LS. | measuredUsage | either |
meter_def_namespace | The namespace from where the data was reported. This value or namespace is required if source is LS. | measuredUsage | either |
pod | The pod name. | measuredUsage | either |
platformId | The id of the platform. | measuredUsage | either |
source | The source of the data. If this value is not provided then the productId will be identified as the source of the data. Allowed values are “IASP”, “ILMT”, “LS”, “MCSP”, “ON_PREM”, or “RHM”. Having any of the allowed source values set will also identify the usage as being for an IBM product. | root | root level additionalAttributes only |
manual | “true” if usage value was entered by customer. “false” if value was computed. | root | either |
metricType | The type of metric being reported. Allowed values are “billable”, “paygo”, “license”, “adoption”, or “infrastructure”. See “Metric types” below. | measuredUsage | either |
metricAggregationType | The aggregation method for the metric being reported. Allowed values are “cumulative”, “total-up-to-date”, “point-in-time”, or “high-watermark”. If metricAggregationType is not provided, a default will be used based on the metricType . See “Metric aggregation types” below. | measuredUsage | either |
measuredMetricId | The metric id of the measuredValue . This does not need to match the actual metric of reported usage to allow for cases where one metric is measured, converted with a ratio and reported with a different metric id. This value must not be provided if productType is cloudPak or bundled. If this value is not provided for a product with a parent product it will be assumed to be equal to measuredUsage metricId . | measuredUsage | either |
measuredValue | The original value of the usage before any conversion ratios are applied. This value must not be provided if productType is cloudPak or bundled. If this value is not provided for a product with a parent product it will be calculated based on measuredUsage value and productConversionRatio . | measuredUsage | either |
productConversionRatio | The ratio of usage contribution indicating how many units of this product usage contribute to 1 unit of usage for the parent product e.g. “4:1”. This value must not be provided if productType is cloudPak or bundled. If this value is not provided for a product with a parent product it will be assumed to be “1:1”. | measuredUsage | either |
licensePartNumber | The part number that usage is being reported for. | root | either |
productId | A unique identifier for the product. This value is required if source is LS, ILMT, IASP, or MCSP. This value is required if parentProductId is provided. | root | either |
productName | A readable name for the product. Either the productId and productName or the entitlement subscriptionId is required. | root | either |
productType | The type of product. Allowed values are “product”, “bundled”, “subcomponent”, “service”, “cloudPak”, or “flexPoint”. See “Product types” below. | root | either |
parentProductId | In case that usage is being reported by a subcomponent, it represents the “Product Id” of the parent product. A subcomponent will also have it’s own productId . This value must not be provided if productType is cloudPak or bundled. This value is required if productType is subcomponent or service. This value must be the same for all measuredUsages in an event after overall additionalAttributes and measuredUsage additionalAttributes are merged for each measuredUsage . | root | either |
parentMetricId | The metric id of the usage value that is reported for the parent product. This may be different from the measuredMetricId if the value is converted. This value must be the same for all measuredUsages in an event after overall additionalAttributes and measuredUsage additionalAttributes are merged for each measuredUsage . | root | either |
topLevelProductId | For cases where usage is reported for products with subcomponents that have subcomponents (services) themselves. If topLevelProductId is provided then parentProductId must also be provided, and parentProductId and topLevelProductId must have different values. This value must be the same for all measuredUsages in an event after overall additionalAttributes and measuredUsage additionalAttributes are merged for each measuredUsage . | root | either |
topLevelMetricId | The metric id of the usage value that is reported for the top level product. This may be different from the measuredMetricId if the value is converted. This value must be the same for all measuredUsages in an event after overall additionalAttributes and measuredUsage additionalAttributes are merged for each measuredUsage . | root | either |
sourceSaas | The SaaS cloud service provider where usage data was collected e.g. AWS, IBMCloud, etc. | root | either |
accountIdSaas | The id of the account with the cloud service provider identified by sourceSaas | root | either |
subscriptionIdSaas | The id of the subscription from the cloud service provider identified by sourceSaas | root | either |
dswOfferAccountingSystemCode | Acquisition Code from DSW SAP, e.g. “ISWC”. This value is required if metricType is billable or paygo. | root | either |
dswSubscriptionAgreementNumber | DSW Subscription Agreement number. It is one of two value types for sap_entitlement_acct. The sap_entitlement_acct value type is agreed upon during the SAPcc boarding process. Once configured in the SAP tables, the same value type must be used consistently. This value or ssmSubscriptionId is required if metricType is billable or paygo. | root | either |
ssmSubscriptionId | SSM Subscription Id. It is one of two value types for sap_entitlement_acct. The sap_entitlement_acct value type is agreed upon during the SAPcc boarding process. Once configured in the SAP tables, the same value type must be used consistently. This value or dswSubscriptionAgreementNumber is required if metricType is billable or paygo. | root | either |
sapEntitlementLine | Entitlement ID from DSW SAP. This value is required if metricType is billable or paygo. | root | either |
icn | IBM Customer Number. This value is required if metricType is billable or paygo. | root | either |
Metric types
Metric Type | Description |
---|---|
billable or paygo | Billable and paygo types indicate standard usage data which will be rated and charged according to configured pricing rules (which may be charges per unit, tiered pricing, etc.) |
license | License type represents a snapshot of current usage for products that have an up front quantity purchased. |
adoption | Adoption type is for any metric that is only used to measure how a product is being used. Adoption metrics have no costs or charges associated with them. The adoption metricType is allowed, but is not implemented. |
infrastructure | The infrastructure metricType is allowed, but currently no processing is done for usage with this metricType. |
Metric aggregation types
Metric Aggregation Type | Description |
---|---|
total-up-to-date | Total up to date and cumulative both represent usage that adds up over time. Total up to date is the running total as directly retrieved from Prometheus or Thanos. |
cumulative | Cumulative is the usage delta added to the total over the usage reporting period. It is the default aggregation type used when the metric type is billable or paygo. |
high-watermark | High watermark is the highest usage value measured during the reporting period. It is the default aggregation type used when the metric type is license. |
point-in-time | Point in time is simply the usage value measured at a particular point in time. It is the default aggregation type used when the metric type is adoption or infrastructure. |
Product types
Product Type | Description |
---|---|
product | A standalone product. If usage is received with this type, no other usage events should be related to it using the parentProductId or the topLevelProductId. |
flexPoint | A legacy custom product type. |
bundled or cloudPak | Both of these types refer to a product that is comprised of subcomponents. Its subcomponents may also have subcomponents. When usage for products of these types are sent, usage for the subcomponents (and subcomponents/services of subcomponents) should also be sent in the same request. |
subcomponent or service | These types refer to a product that is a subcomponent of another product. Subcomponents can have subcomponents or services that they are a parent product to. Services are the lowest level products, and they should not be parent product to any other products. Products with these types should have parentProductId or parentProductId and topLevelProductId defined. |
dataReporter type
Data reporter type data is sent to Segment without further processing.
Example
{"data": [],"metadata" {}}
Data reporter file properties
Property | Required | Type | Description |
---|---|---|---|
data | yes | array | Value is an array of objects. It must exist, and it must contain at least one object. Each object will be submitted as a Segment event. No validation is done on objects before they are submitted, but objects may be rejected as invalid by Segment. |
metadata | no | object | This field is allowed, but it has no effect on processing. |
Responses
Metering API responds with the following HTTP codes.
HTTP Code | Platform Action | Description |
---|---|---|
202 | Accepted | The submission was accepted for processing. This does not necessarily mean processing was successful. Use status apis such as ”Get status using requestId” to check the result of processing. |
401 | Authentication Failure | Failed to authenticate or not authorized |
413 | Request Too Large | The request should be split up and resent. |
422 | Invalid Request | Something is invalid about the request. Could be more than one archive file, unparseable archive file, or a different issue |
500 | Internal server error | Internal server error |
503 | Downstream error | Error from a downstream system |
Retries
Retries for internal and downstream errors will be processed automatically by the system. Errors in submitted data can be fixed by submitting an amendment. Refer to “Amend usage”.
Amend usage
Submitted data can be amended by submitting revised data with the same eventId in a new request. Amendments must have the same group
, kind
, and subscriptionId
as their original usage event. They must also have the same number or fewer measuredUsages
as their original usage event, and any metricIds
present in measuredUsages
in the amendment must have been present in the original usage event. Amendments are processed by completely replacing the data in the original usage event with the data in the amendment per measuredUsage
. A measuredUsage
present in the original usage event but not present in the amendment will be unchanged. Submitting an amendment where the value
for a measuredUsage
is 0 will effectively delete that metric.
Metering API reference
For details on methods, endpoints, requests, and responses, refer to Metering API reference.