Deployment Audit Trail
Each time you deploy a package to your K2 environment, an audit trail is created. This is referred to as the Deployment Audit Trail and the data is logged and stored in the K2 database. This data shows the history for each deployment made in your K2 environment. You can see information on deployed packages and environmental changes that occurred. This includes information on individual items in each deployment package.
The audit trail makes troubleshooting easier, especially when solutions are duplicated (a package deployed as new multiple times). You can also see the history of options you chose for each item in every deployed package.
The audit trail covers the following three deployment steps and records data for each step:
- Upload Package
- Analyze and Configure
- Deploy
The see the audit trail you need access to SQL tooling and permissions to the K2 database.
Deployment Audit Trail Stored Procedures
You execute specific deployment-related stored procedures to see the deployment logging data. You find the stored procedures in the Deployment schema. For more details on these stored procedures, expand each section below:

Use this stored procedure to see a summary of all deployments. You may want to use this to see a summary of all deployments in your environment.
- Open Microsoft SQL Server Management Studio and connect to your SQL server.
- In the Object Explorer, navigate to Databases > K2 > Programmability > Stored Procedures.
- Scroll down the list of stored procedures and locate Deployment.GetDeploymentSummaryReport.
- Right-click the stored procedure and select Execute Stored Procedure...
- On the Execute Procedure screen click OK.
- The results show as follows:
The following table explains how to interpret the results:[Deployment].[GetDeploymentSummaryReport] ID The value that uniquely identifies a deployment session.
Name The name given to the deployment session. User The user that created the session (example the user that executed the deployment). Package Type The type of package that was deployed, such as System Packages or User Packages. Intent The user's deployment intention, such as whether they updated an existing solution or created a new solution. Session start The date and time the deployment session began, in UTC format. This corresponds to when you chose “Deploy package” on the initial Package and Deploy options screen. Session duration The time this deployment session took. Format - Hours:Minutes:Seconds:Miliseconds DeployStart The date and time (in UTC format) when a package deployment began in a deployment session. This corresponds to when, after all mappings and analysis is done, you clicked Next. Deployment duration The difference between end and start date time for the entire deployment. Format - Hours:Minutes:Seconds:Miliseconds Items failed to deploy The number of items that failed during deployment. Items successfully deployed The number of successfully deployed items. Items not deployed The number of items that did not deploy. - By adding an ID parameter, you can show a summary of a particular deployment. To do this, add a value for the @DeploymentID parameter. In this example, add 33 in the Value field and click OK.
- Results for deployment ID 33 shows:

Use this stored procedure to return a list of all items that were attempted to be deployed. This also includes their statuses.
- Open Microsoft SQL Server Management Studio and connect to your SQL server.
- In the Object Explorer, navigate to Databases > K2 > Programmability > Stored Procedures.
- Scroll down the list of stored procedures and locate Deployment.GetItemStatusReport.
- Right-click the stored procedure and select Execute Stored Procedure...
- On the Execute Procedure screen, add a parameter. To do this, add a value for the @DeploymentID parameter. In this example, add 33 in the Value field and click OK.
- The results show as follows:
The following table explains how to interpret the results:[Deployment].[GetItemStatusReport] Item name At package time, this stores the original complex type name.
Item namespace At package time, this stores the original complex type namespace. Item type The type of deployed artifact such as SmartObject, View, Form, or Process. Status Deployment status of the deployed artifact, which is one of the following:
- 0 - Information
- 1 - Warning
- 2 - Error
Status message Status message of the deployed artifact, such as Ready, Existing, Identical or a Missing Reference. Action Action taken at the time of deployment, which is one of the following:
- 0 - CreateNew
- 1 - OverwriteOrNewVersion
- 2 - UseExisting
- 3 - Exclude
Target item name This stores the matched item name on the target, such as items matched on an exact name, namespace, and GUID match, or a partial name or partial GUID match. Target item namespace This stores the matched item namespace on the target. StackTrace This column logs any exception raised during deployment of the artifact. Use this to understand what could have gone wrong with the item.

Use this stored procedure to return a list of all items deployed and their statuses.
- Open Microsoft SQL Server Management Studio and connect to your SQL server.
- In the Object Explorer, navigate to Databases > K2 > Programmability > Stored Procedures.
- Scroll down the list of stored procedures and locate Deployment.GetItemDeploymentStatusReport.
- Right-click the stored procedure and select Execute Stored Procedure...
- On the Execute Procedure screen, add a parameter. To do this, add a value for the @DeploymentID parameter. In this example, add 33 in the Value field and click OK.
- The results show as follows:
The following table explains how to interpret the results:[Deployment].[GetItemDeploymentStatusReport] Sequence This number represents the order in which the item was deployed.
Item Name At package time, this stores the original complex type name. Item namespace At package time, this stores the original complex type namespace. Item type The type of deployed artifact, such as SmartObject, View, Form, or Process. Deployment status This shows if the item deployment was a success or failure. Duration This records the difference between end and start date time for the deployment per item. Format - Hours:Minutes:Seconds:Miliseconds. Message Any message shown with details why an item deployment failed. StackTrace Logs any exception raised while deploying the item. Use this to understand what could have gone wrong with the item.

Use this stored procedure to delete logs for all deployments older than a specified date-time. You may want to use this when you have many deployments and no longer need to keep the data.
- Open Microsoft SQL Server Management Studio and connect to your SQL server.
- In the Object Explorer, navigate to Databases > K2 > Programmability > Stored Procedures.
- Scroll down the list of stored procedures and locate Deployment.DeleteDeploymentHistory.
- Right-click the stored procedure and select Execute Stored Procedure...
- On the Execute Procedure screen you need to add a parameter. To do this, add a value for the @olderThan parameter. In this example, add 2018-09-18 10:12:00 in the Value field and click OK.
- The results show as follows:
- Any deployment history before the specified date and time is deleted.

When using the Deployment Audit Trail keep in mind the following considerations:
- A package can only contain one model. The model is a logical representation of the package and holds all information about the packaged artifacts. The model is stored in the definition.model file
- When you deploy a package to your environment, a new deployment session is created at the start of the deployment. The person deploying the package owns the deployment session and gets logged as the owner in the Deployment Audit trail
- A session must have a unique name in the K2 environment