How Metering API works

Overview on Metering API

Metering API is how IBM, partners, and clients submit usage data to IBM Software Central or Red Hat Marketplace. This data flows into customer dashboards and analytics services and facilitates billing for pay-as-you-go subscriptions.


Partner product onboarding and Metering API

During product onboarding, partners configure pricing for each paid edition. Pricing set-up includes defining billing frequency, subscription terms, and charge metrics. Using Metering API, partners send usage metrics and subscription plan information to the marketplace to help enable integrated billing and customer dashboards.

Partners with entitlements enabled for integrated billing must submit usage for all active instances every hour. Inability to report usage can lead to loss of revenue collection and revenue share for partners.

Partners should collect and send the following information on customer purchases through the marketplace:

  • Usage metrics
  • Subscription plan ID associated to usage metrics

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>"
}
PropertyRequiredTypeDescription
versionyesstringVersion of manifest file format. Currently only “1” is allowed.
typeyesstringThe 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

PropertyRequiredTypeDescription
datayesarrayArray of usage event objects. See below.
metadatanoobjectThis field is allowed, but it currently has no effect on processing.

Usage event properties

PropertyRequiredTypeDescription
eventIdyesstringA 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.
startnointegerUTC 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.
endnointegerUTC 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.
accountIdnostringThe id of the IBM Software Central or Red Hat Marketplace account that usage is being reported for.
subscriptionIdnostringThe id of the IBM Software Central or Red Hat Marketplace subscription for the product that usage is being reported for.
additionalAttributesyesobjectAn 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.
measuredUsageyesarrayArray of measuredUsage objects. See “Measured usage properties” below.

Measured usage properties

PropertyRequiredTypeDescription
metricIdyesstringThe id of the metric being reported.
valueyesnumberThe recorded usage value for the time window.
startnointegerUTC 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.
endnointegerUTC 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.
additionalAttributesnoobjectAdditional 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.

AttributeDescriptionswcAccountMetricsaccountMetrics
clusterIdThe id for the cluster. This value is required if source is LS.measuredUsageeither
hostnameThe id for the host reporting data. This value is required if source is ILMT.measuredUsageeither
groupThe group name in the CustomResourceDefinition representing the meter definition deployed to the cluster. This value is required if source is LS.rooteither
groupNameA 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.rooteither
kindThe kind identified in CustomResourceDefinition. This value is required if source is LS.rooteither
namespaceThe namespace from where the data was reported. This value or meter_def_namespace is required if source is LS.measuredUsageeither
meter_def_namespaceThe namespace from where the data was reported. This value or namespace is required if source is LS.measuredUsageeither
podThe pod name.measuredUsageeither
platformIdThe id of the platform.measuredUsageeither
sourceThe 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 “LS”, “ILMT”, “IASP”, or “MCSP”. Having any of the allowed source values set will also identify the usage as being for an IBM product.rootroot level additionalAttributes only
manual“true” if usage value was entered by customer. “false” if value was computed.rooteither
metricTypeThe type of metric being reported. Allowed values are “billable”, “paygo”, “license”, “adoption”, or “infrastructure”. See “Metric types” below.measuredUsageeither
metricAggregationTypeThe 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.measuredUsageeither
measuredMetricIdThe 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.measuredUsageeither
measuredValueThe 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.measuredUsageeither
productConversionRatioThe 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”.measuredUsageeither
licensePartNumberThe part number that usage is being reported for.rooteither
productIdA 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.rooteither
productNameA readable name for the product. Either the productId and productName or the entitlement subscriptionId is required.rooteither
productTypeThe type of product. Allowed values are “product”, “bundled”, “subcomponent”, “service”, “cloudPak”, or “flexPoint”. See “Product types” below.rooteither
parentProductIdIn 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.rooteither
parentMetricIdThe 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.rooteither
topLevelProductIdFor 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.rooteither
topLevelMetricIdThe 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.rooteither
sourceSaasThe SaaS cloud service provider where usage data was collected e.g. AWS, IBMCloud, etc.rooteither
accountIdSaasThe id of the account with the cloud service provider identified by sourceSaasrooteither
subscriptionIdSaasThe id of the subscription from the cloud service provider identified by sourceSaasrooteither
dswOfferAccountingSystemCodeAcquisition Code from DSW SAP, e.g. “ISWC”. This value is required if metricType is billable or paygo.rooteither
dswSubscriptionAgreementNumberDSW 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.rooteither
ssmSubscriptionIdSSM 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.rooteither
sapEntitlementLineEntitlement ID from DSW SAP. This value is required if metricType is billable or paygo.rooteither
icnIBM Customer Number. This value is required if metricType is billable or paygo.rooteither

Metric types

Metric TypeDescription
billable or paygoBillable 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.)
licenseLicense type represents a snapshot of current usage for products that have an up front quantity purchased.
adoptionAdoption 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.
infrastructureThe infrastructure metricType is allowed, but currently no processing is done for usage with this metricType.

Metric aggregation types

Metric Aggregation TypeDescription
total-up-to-dateTotal 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.
cumulativeCumulative 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-watermarkHigh 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-timePoint 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 TypeDescription
productA standalone product. If usage is received with this type, no other usage events should be related to it using the parentProductId or the topLevelProductId.
flexPointA legacy custom product type.
bundled or cloudPakBoth 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 serviceThese 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

PropertyRequiredTypeDescription
datayesarrayValue 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.
metadatanoobjectThis field is allowed, but it has no effect on processing.

Responses

Metering API responds with the following HTTP codes.

HTTP CodePlatform ActionDescription
202AcceptedThe 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.
401Authentication FailureFailed to authenticate or not authorized
413Request Too LargeThe request should be split up and resent.
422Invalid RequestSomething is invalid about the request. Could be more than one archive file, unparseable archive file, or a different issue
500Internal server errorInternal server error
503Downstream errorError 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.