How to Retrieve Watson Speech Metering Usage Data from the License Service
By Shalini Gilra — DevOps CP4D, IBM Watson Speech Services.
You have a Cloud Pak cluster running Watson Speech and maybe other Watson services. One day, a license auditor comes to you and ask for your monthly speech-to-text
or text-to-speech
consumption. Yet another day, your IT manager asks you for weekly consumption data over the past 12 months. If these are some of the tasks that you have to work on then read on.
This article describes how to retrieve the metering data from the License Service posted by Watson Speech service on Cloud Pak for Data.
What is the License Service
The License Service is a part of the Cloud Pak foundational services, that is required before you can install Cloud Pak solutions.
License Service collects and measures the license usage of IBM Cloud Pak services and bundled products at the cluster level. You can retrieve this data upon request for monitoring and compliance. You can also retrieve an audit snapshot of the data that is audit evidence.
Currently, License Service refreshes the data every 5 minutes and stores historical data for 24 months. It also provides the API that you can use to upload and retrieve data.
For more information on License Service refer here
How Watson Speech makes use of the License Service
- Watson Speech operator deploys the license service by way of Operand Deployment Lifecycle Manager (ODLM). This creates the operator and instance of the license service in the foundational service namespace ( e.g.
ibm-common-services
). - License Service will expose API Token and the URL that is required to access the API in the <cpd-instance> namespace (e.g.
zen
) — it creates a secret namedibm-licensing-upload-token
containing the API token and a configmap namedibm-licensing-upload-config
containing the endpoint URL e.g. https://ibm-licensing-service-instance.ibm-common-services.svc.cluster.local:8080
Metrics usage reported to the License Service
The speech-to-text
and text-to-speech
runtime processing uploads the cumulative metering usage data once per day based on their respective metrics e.g. MONTHLY_MINUTE
and MONTHLY CHARACTER
How to retrieve metering usage data from the License Service posted by Watson Speech
You must obtain the API token and endpoint URL to license service before you can query the service to retrieve the usage data posted by the Speech service.
To obtain the API token use the following command after you login to you openshift cluster:
oc get secret ibm-licensing-upload-token -n <cpd-instance> -o jsonpath='{.data.token-upload}' | base64 -d
Replace the <cpd-instance> with the name of the namespace where Speech instance is deployed.
To obtain the URL use the following command:
oc get configmap ibm-licensing-upload-config -n <cpd-instance> -o jsonpath='{.data.url}'
Replace the svc.cluster.local:8080
in the obtained url with your cluster name if you intend to make the request externally outside the cluster context:
e.g. https://ibm-licensing-service-instance-ibm-common-services.apps.speech.cp.domain.com
Alternatively, you can also retrieve the expose route (url) to the licensing service using the following command:
oc get routes -n ibm-common-services | grep ibm-licensing-service-instance | awk ‘{print $2}’
Use the following cURL API requests to retrieve the desired usage data:
- Audit snapshot
curl -k https://ibm-licensing-service-instance-ibm-common-services.<cluster-name>/snapshot?token=<token> — output snapshot.zip
- Products
curl -k https://ibm-licensing-service-instance-ibm-common-services.<cluster-name>/bundled_products?token=<token>
- Bundled Products
curl -k https://ibm-licensing-service-instance-ibm-common-services.<cluster-name>/bundled_products?token=<token>
License Service Dashboard
You can also view the metrics usage on the License Service dashboard UI interface on your browser using the following url:
https://ibm-licensing-service-instance-ibm-common-services.<cluster-name>/
Replace <cluster-name> with the name of your cluster e.g. apps.speech.cp.domain.com
UI interface retrieves the licensing data for last 30 days for all products.
Sample usage data:
References:
For more details refer to the following IBM documentation links: