Software AG Products 10.11 | Using API Gateway | Usage Scenarios | Trace API | How do I archive and purge the tracer details using REST API Calls?
 
How do I archive and purge the tracer details using REST API Calls?
API Gateway provides the following REST API and the resources to archive and purge the trace details:
To archive the trace details use the following REST API calls:
*POST/rest/apigateway/apitransactions?action=archive&eventType=serverLogTraceSpan&from=yyyy-MM-dd HH:mm:ss&until=yyyy-MM-dd HH:mm:ss
This archives the server logs that were captured when you enabled the tracer for the specified range.
*POST/rest/apigateway/apitransactions/archives?action=archive&eventType=serverLogTraceSpan&olderThan= 7d
This archives the server logs that were captured when you enabled the tracer for the specified duration.
With this REST API call you can archive the server logs that were captured during the last 7 days. Similarly, you can archive the last months and years trace details by specifying the olderThan as 2y for 2 years and 3M for 3 months. You can specify the number of days, years, and months as per your need.
To purge the trace details use the following REST API calls:
*DELETE/rest/apigateway/apitransactions?action=purge&eventType=serverLogTraceSpan&from=yyyy-MM-dd HH:mm:ss&until=yyyy-MM-dd HH:mm:ss
This deletes the server logs that were captured when you enabled the tracer for the specified range.
*DELETE/rest/apigateway/apitransactions?action=purge&eventType=serverLogTraceSpan&olderThan= 7d
This deletes the server logs that were captured when you enabled the tracer for the specified duration.
With this REST API call you can delete the server logs that were captured during the last 7 days. Similarly, you can delete the last months and years trace details by specifying the olderThan as 2y for 2 years and 3M for 3 months. You can specify the number of days, years, and months as per your need.
To archive and purge the trace details use the following REST API calls:
*DELETE/rest/apigateway/apitransactions?action=archiveAndPurge&eventType=serverLogTraceSpan&from= yyyy-MM-dd HH:mm:ss&until=yyyy-MM-dd HH:mm:ss
This archives and deletes the server logs that were captured when you enabled the tracer for the specified range.
*DELETE/rest/apigateway/apitransactions?action=archiveAndPurge&eventType=serverLogTraceSpan&olderThan= 7d
This archives and deletes the server logs that were captured when you enabled the tracer for the specified duration.
With this REST API call you can archive and delete the server logs that were captured during the last 7 days. Similarly, you can archive and delete the last months and years trace details by specifying the olderThan as 2y for 2 years and 3M for 3 months. You can specify the number of days, years, and months as per your need.
Note:
In all these REST API calls,
*if you want to archive and purge the stage-wise mediator details, specify the eventType as mediatorTraceSpan.
*if you want to archive and purge the requests and response logs, specify the eventType as requestResponseTraceSpan.
When you make these REST API calls, you can see the job ID in the response, which is used in the following REST API call to retrieve the status of the job.
To view the status of archive or purge jobs:
You can view the status of archive or purge jobs using the following REST API call:
GET/rest/apigateway/apitransactions/jobs/JobID retrieves the status of the specified job ID.
Sample request: GET/rest/apigateway/apitransactions/jobs/ca108bf0-34f3-4726-83a0-2eab4f8b947
Sample response payload:
{
"status": "Completed",
"action": "purge",
"jobId": "ca108bf0-34f3-4726-83a0-2eab4f8b9473",
"creationDate": "2021-08-16 09:07:35 GMT",
"totalDocuments": 4456,
"deletedDocuments": 4456
}