Payload and feedback logging in Watson OpenScale

For Watson OpenScale, all transactions that are sent to the deployed models must be logged as payload records in the Watson OpenScale data mart. The input and output payloads (requests and responses) need to be in the format that is required by Watson OpenScale as described in the specifications.

Watson OpenScale supports payload and feedback logging through the following methods:

Logging the payload with Python SDK

The following code sample shows how to log the payload by using the Python SDK:

authenticator = IAMAuthenticator(apikey=CLOUD_API_KEY)
subscription = : wos_client.subscriptions.get(subscription_id).result.to_dict()
payload_data_set_id = wos_client.data_sets.list(type=DataSetTypes.PAYLOAD_LOGGING,
                                                target_target_id=subscription_id,                  target_target_type=TargetTypes.SUBSCRIPTION).result.data_sets[0]
request_data = {
    "fields": ["AGE", "BP", "CHOLESTEROL", "NA", "K"],
    "values": [[28, "LOW", "HIGH", 0.61, 0.026]],
    "meta": {
      "fields": ["SEX"],
      "values": [["F"]]
response_data = {
    "fields": ["AGE", "BP", "CHOLESTEROL", "NA", "K", "probability", "prediction", "DRUG"],
    "values": [[28, "LOW", "HIGH", 0.61, 0.026, [0.82, 0.07, 0.0, 0.05, 0.03], 0.0, "drugY"]]
request_data = <put your data here>
response_data = <put your data here>
wos_client.data_sets.store_records(data_set_id=payload_data_set_id, request_body=[PayloadRecord(
                   request= request_data,
                   response= response_data,

Previewing the payload logging table

You can preview the content of your payload logging table either by directly connecting to the database or by using the Python SDK, which is shown in the following sample output.

Python SDK sample output of payload logging table

Logging the payload with the REST API

The following code sample shows how to log the payload by using the REST API:

PAYLOAD_STORING_HREF_PATTERN ='{}/v1/data_marts/{}/scoring_payloads'
deployment_uid = subscription.get_details()['entity']['deployments'][0]['deployment_id']
payload = [{'binding_id': binding_uid, 
            'deployment_id': deployment_uid,
            'subscription_id': subscription.uid,
            'scoring_id': scoring_uid,
            'response': response_data,
            'request': request_data}]
headers = {'Authorization': 'Bearer '+ token}
req_response =, 
                             headers = headers)

Next steps

After you set up payload logging, you can continue configuring monitors by entering model details. For more information, see Provide model details.

See the sample payload files.