Printing as a service - Metering setup guide
To process usage data with the Printing as a Service stream, you must first create the meter type (the product you want to meter) and the meters (which track usage per customer for that product). While these steps are typically performed using APIs from an external system, this example uses “Helper” streams to simplify the process.
Helper streams
Helper streams are used in place of APIs for this example. They perform the following functions:
Helper stream | Purpose |
|---|---|
1 Provisioning Meter Types | Creates the meter type “Pay-per-print,” which defines the product for measuring the number of prints per printer. This meter type uses the SUM aggregation type, a monthly reset interval (so a golden record is sent downstream at the end of each month), and includes threshold definitions for usage-based actions such as maintenance notifications or printer deactivation. |
2 Provisioning Meters | Provisions meters for printers, using the printer ID as the key (user ID). |
3 Purge Meters | Cleans up meters after processing is complete. |
Run Printing as a service with metering
Follow these steps to configure and run the example stream. The process is divided into three main parts:
Part 1: Set-up and configuration
Create application access:
Set up a new application access for your account. This is required for authenticating with the Usage Engine APIs, see https://infozone.atlassian.net/wiki/spaces/DAZ/pages/850493511.Import helper streams:
Import the helper streams, which can be found at the links below, see https://infozone.atlassian.net/wiki/spaces/DAZ/pages/7842293/Streams#Importing-an-existing-stream.Configure helper streams:
Enter your client credentials in each of the six HTTP functions in the helper streams.
Note!
Ensure that the audience and access token URL of the OAuth2 authentication are configured to match your Environment API base URL. See https://infozone.atlassian.net/wiki/x/qwJoDQ.
Part 2: Run the streams
Provision Meter types:
Run the 1 Provisioning Meter Types stream. Once complete, a new meter type, ‘Pay-per-print’ will be available in the Usage metering page.Copy the meter key:
Open the stream configuration for the Printing As A Service stream and copy the meter key from the Meter processor function for use in the next step.The Meter key from the Meter processor functionProvision meters:
Open the 2 Provisioning Meters stream configuration and paste the Meter key in the script function called "Prepare Meters".The Meter key added in the Script function, ‘Prepare Meters’Run the 2 Provisioning Meters stream. When finished, you will have five meters under the meter type, each configured with the following custom fields:
brand
type
model
customer
department
Custom fields on a meter
These meters are now linked to the Meter processor function in the Printing as a Service with Metering stream.
Run the example stream:
Run the “Printing as a Service with Metering” stream. When complete, you can view the aggregated usage values from the input records in the https://infozone.atlassian.net/wiki/spaces/DAZ/pages/849379329.The Inspect tab in the Meter processor function shows the newly created meters
Part 3: Delete meters
Note!
This step is optional and used for cleanup.
Navigate to the 3 Purge Meters stream configuration.
Paste the meter key into the Script function, ‘Prepare Filter’, and run the stream.
All meters related to this Meter key will be deleted.The Meter key in the Prepare Filter script function
Hint!
You can use any 3 Purge Meters stream to delete meters, just paste in the relevant meter key for the meters you want to remove.