Chapter 30. Managing log data Red Hat Process Automation Manager manages the required maintenance runtime data. It removes some data automatically, including the following data types: Process instance data , which is removed upon process instance completion. Work item data , which is removed upon work item completion. Task instance data , which is removed upon completion of a process to which the given task belongs. Runtime data that is not cleaned automatically includes session information data that is based on the selected runtime strategy. Singleton strategy ensures that runtime data of session information is not automatically removed. Per request strategy allows automatic removal when a request is terminated. Per process instances automatically removes process instance data when a process instance is mapped to a session that is completed or aborted. Red Hat Process Automation Manager also provides audit log data tables. You can use these tables to keep track of current and past process instances. By default, Red Hat Process Automation Manager does not remove any data from audit log tables. There are three ways to manage and maintain the audit data tables: You can set up an automatic cleanup of these tables using Business Central, as described in Section 30.1, "Setting up automatic cleanup job" . You can remove information from the tables manually using the Java API, as described in Section 30.2, "Manual cleanup" . You can run a custom query on the Red Hat Process Automation Manager database, including the audit log tables, as described in Section 30.4, "Running a custom query on the Red Hat Process Automation Manager database" . 30.1. Setting up automatic cleanup job You can set up an automatic cleanup job in Business Central. Procedure In Business Central, go to Manage > Jobs . Click New Job . Enter values for Business Key , Due On , and Retries fields. Enter the following command into the Type field. To configure parameters, complete the following steps: Click the Advanced tab. Click Add Parameter . In the Key column, enter a parameter. In the Value column, enter a parameter. For the list of parameters for the command, see Section 30.3, "Removing logs from the database" . Click Create . Business Central creates the automatic cleanup job. 30.2. Manual cleanup To perform manual cleanup, you can use the audit Java API. The audit API consists of the following areas: Table 30.1. Audit API areas Name Description Process audit It is used to clean up process, node and variable logs that are accessible in the jbpm-audit module. For example, you can access the module as follows: org.jbpm.process.audit.JPAAuditLogService Task audit It is used to clean up tasks and events that are accessible in the jbpm-human-task-audit module. For example, you can access the module as follows: org.jbpm.services.task.audit.service.TaskJPAAuditService Executor jobs It is used to clean up executor jobs and errors that are accessible in the jbpm-executor module. For example, you can access the module as follows: org.jbpm.executor.impl.jpa.ExecutorJPAAuditService 30.3. Removing logs from the database Use LogCleanupCommand executor command to clean up the data, which is using the database space. The LogCleanupCommand consists of logic to automatically clean up all or selected data. There are several configuration options that you can use with the LogCleanupCommand : Table 30.2. LogCleanupCommand parameters table Name Description Is Exclusive SkipProcessLog Indicates whether process and node instances, and process variables log cleanup is skipped when the command runs. The default value is false . No, it is used with other parameters. SkipTaskLog Indicates if the task audit and event log cleanup are skipped. The default value is false . No, it is used with other parameters. SkipExecutorLog Indicates if Red Hat Process Automation Manager executor entries cleanup is skipped. The default value is false . No, it is used with other parameters. SingleRun Indicates if a job routine runs only once. The default value is false . No, it is used with other parameters. NextRun Schedules the job execution. The default value is 24h . For example, set to 12h for jobs to be executed every 12 hours. The schedule is ignored if you set SingleRun to true , unless you set both SingleRun and NextRun . If both are set, the NextRun schedule takes priority. The ISO format can be used to set the precise date. No, it is used with other parameters. OlderThan Logs that are older than the specified date are removed. The date format is YYYY-MM-DD . Usually, this parameter is used for single run jobs. Yes, it is not used with OlderThanPeriod parameter. OlderThanPeriod Logs that are older than the specified timer expression are removed. For example, set 30d to remove logs, which are older than 30 days. Yes, it is not used with OlderThan parameter. ForProcess Specifies process definition ID for logs that are removed. No, it is used with other parameters. RecordsPerTransaction Indicates the number of records in a transaction that is removed. The default value is 0 , indicating all the records. No, it is used with other parameters. ForDeployment Specifies deployment ID of the logs that are removed. No, it is used with other parameters. EmfName Persistence unit name that is used to perform delete operation. Not applicable Note LogCleanupCommand does not remove any active instances, such as running process instances, task instances, or executor jobs. 30.4. Running a custom query on the Red Hat Process Automation Manager database You can use the ExecuteSQLQueryCommand executor command to run a custom query on the Red Hat Process Automation Manager database, including the audit log data tables. You can set up a job that runs this command in Business Central. Procedure In Business Central, select Manage > Jobs . Click New Job . Enter values for Business Key , Due On , and Retries fields. Enter the following command into the Type field. To configure parameters, complete the following steps: Open the Advanced tab. Click Add Parameter . In the Key column, enter a parameter value. In the Value column, enter a parameter value. For the list of parameters for the command, see Section 30.4.1, "Parameters for the ExecuteSQLQueryCommand command" . Click Create . Business Central creates the custom query job. Optional: If you want to retrieve the results of the query, complete the following steps: In the list of jobs that Business Central displays, find the job that you started. If the job is not present in the list, remove any filters from the Active filters list. Record the id value for the job. Using a web browser, access the Swagger documentation on your KIE Server at <kie_server_address>/docs , for example, http://localhost:8080/kie-server/docs/ . Click the GET /server/jobs/{jobId} request. In the jobId field, enter the id value that you recorded. From the withErrors list, select true . From the withData list, select true . Click Execute . Review the Server response field. If the SQL query succeeded, the result is under the "response-data" key. 30.4.1. Parameters for the ExecuteSQLQueryCommand command The ExecuteSQLQueryCommand executor command runs a custom query on the Red Hat Process Automation Manager database, including the audit log tables. For the schema for the audit log tables, see Process engine in Red Hat Process Automation Manager . You can configure the following parameters for the ExecuteSQLQueryCommand command. Table 30.3. ExecuteSQLQueryCommand parameters table Name Description SingleRun true if the query can be triggered once. false if the query can be triggered multiple times. EmfName name of the persistence unit to be used to run the query businessKey The business key to use with the query. If configuring the command in Business Central, use the business key that you set for the job SQL The native SQL query to execute. Preface parameters with the : character parametersList List of all parameters in the SQL query. Separate the parameters with the , character SQL parameter name The value for the SQL parameter. Create a separate command parameter for every SQL parameter For example, you might use a query with two parameters: SELECT * FROM RequestInfo WHERE id = :paramId AND businessKey = :paramKey Set the following parameters for the ExecuteSQLQueryCommand command: SQL : SELECT * FROM RequestInfo WHERE id = :paramId AND businessKey = :paramKey ; parametersList : paramId,paramKey paramId : The value for id paramKey : The value for businessKey

Commands:
org.jbpm.executor.commands.LogCleanupCommand
org.jbpm.executor.commands.ExecuteSQLQueryCommand
SELECT * FROM RequestInfo WHERE id = :paramId AND businessKey = :paramKey