API Logger
OnePipe is made up of several microservices performing different distinct operations for a given transaction. In order to harmonise logs for a given transaction across the different microservices, there is need for every API request made by each microservice to other third party systems (or microservices) to be logged on the API Logger - both request details and response details.
This document provides details on how to implement the API logger on your microservice.
Base URL: https://dwh.bits.[env].onepipe.io
Endpoint: /v2/generic/api-logger/log
--header 'Authorization: Bearer {token}'
**Request for bearer token from your manager
Request Payload
{
"platform": "onepipe",
"client": {
"client_id": "{{client_id}}",
"client_name": "{{client_name}}",
"client_app_id": "{{client_app_id}}",
"client_app_name": "{{client_app_name}}""
},
"transaction": {
"transaction_ref": "{{onepipe_transaction_ref}}",
"transaction_timestamp": "2019-09-16T00:55:36.998"
},
"request": {
"source_name": "{{name_of_microservice}}",
"destination_name": "{{destination_name}}",
"destination_url": "https://endpoint.com",
"request_type": "POST",
"request_description": "Process transaction",
"request_timestamp": "2019-09-16T00:55:36.998",
"request_headers": null,
"request_body": {
"param_1": "value_1",
"param_2": "value_2"
}
},
"response": {
"response_timestamp": "2019-09-16T00:55:36.998",
"response_http_status": 200,
"response_code": "{{response-http-status-code}}",
"response_headers": null,
"response_body": {
"param_1": "value_1",
"param_2": "value_2"
}
}
}
Field | Data Type | Description | Example Value |
---|---|---|---|
| String | This specifies the platform under which the API Logger is used. For API Logs used in OnePipe, value of this should be set to |
|
| String | The id of the OnePipe Client the transaction is being made with. |
|
| String | The name of the OnePipe Client the transaction is being made with. |
|
| String | The id of the OnePipe App the transaction is being made with. |
|
| String | The name of the OnePipe App the transaction is being made with. |
|
| String | The actual OnePipe transaction ref of the transaction being performed. |
|
| Date String | The time transaction is being processed. Should be in format |
|
| String | Name of the microservice making the http request. |
|
| String | Name of the destination http request is being made to. |
|
| String | Endpoint http request is being made to. |
|
| String | Http request type - can be |
|
| String | Description or reason for making the request. |
|
| Date String | The time http request is being made to the third party system or microservice. Should be in format |
|
| Json | Possible request headers to log if applicable. Value can be set to | {
"header_1": "value_1",
"header_2": "value_2"
} |
| Json | Request payload used for the http request. | {
"user_id": "1234567890",
"action": "create"
} |
| Date String | The time http response is being received from the third party system or microservice. Should be in format |
|
| Integer | The http response status received. |
|
| String | This maps to the key parameter in the response that determines status of the request. Vaue can also be set as the http response status received. |
|
| Json | Possible response headers to log if applicable. Value can be set to | |
| Json | Response payload received from the http request. |
Response Payload
Points to Note
The API Logger request MUST be implemented asynchronously in your code, so as not to increase latency by blocking regular operations that don’t have to wait.
The API Logger can be implemented as a dedicated service implementation that can be invoked immediately after making any http request.
For logs to be successfully harmonised for a given transaction across the several microservices, the
client_id
,client_app_id
andtransaction_ref
MUST remain consistent while being shipped to the API Logger