
SAP Variant Configuration and Pricing writes the following audit logs:
Furthermore, each creation and each deletion of a configuration or pricing document (through the corresponding endpoints of the configuration and pricing services) is logged:
Those logs also contain the so-called SAP Passport, which can tell you if the service endpoint was called from SAP Commerce Cloud or from SAP CPQ.
The fields autoCleanup=true and the expiryDate in those logs tell you when the configuration or pricing document will be deleted automatically.
Please refer to the Security Guide for SAP Variant Configuration and Pricing to find a list of all kinds of written logs: Audit Logging | SAP Help Portal
SAP Variant Configuration and Pricing uses the SAP Audit Log service on SAP BTP: Audit Logging in the Cloud Foundry Environment | SAP Help Portal
Please note that there are two different views on the audit logs:
Audit logs are kept for 90 days.
You can either use the Audit Log Viewer or the Audit Log Retrieval API.
To use the audit log viewer, open your BTP subaccount, go to the menu Entitlements, press the Edit button, press the Add Service Plans button, search for the Audit Log Viewer Service, choose its plan free (Application), press the button Add 1 Service Plan, and the press button Save.
Go to the menu Services → Service Marketplace in the same subaccount, search for Audit Log Viewer Service, open the corresponding tile and press the Create button. Press the Create button in the popup dialog. Press View Subscription in the next popup dialog to switch to the menu Services → Instances and Subscriptions. There, you should see the application Audit Log Viewer Service with the plan free next to the application SAP Variant Configuration and Pricing.
Go to the menu Security → Role Collections in the same subaccount, create a new role collection with the name Audit Log Viewer. Open the new role collection, press the Edit button, assign the role(s) Auditlog_Auditor to the role collection and assign your user, usually the email address, to the role collection and press the Save button.
With that, you can use the audit log viewer: Go to the menu Services → Instances and Subscriptions, open the Audit Log Viewer Service and press the Go to Application button.
Audit Log Viewer 1.0 opens with prefilled From-Date and To-Date filters, but empty search results list. Press Reload button to start the search. You should see all audit logs written for that subaccount in the selected time frame. You should for example see logs for the changes to the role collection that were done above. You can use the other filter input field to further restrict that list.
The audit log viewer only shows the first 500 hits based on the chosen from- and to-date filters.
The limitation in the audit log viewer of maximum 500 logs and its limited filter capabilities are problematic when you, for example, want to find out when a certain configuration or price document was created or deleted.
In that case, you must use the Audit Log Retrieval API, store the logs in a file, and analyze the logs there:
Create an instance of the service Audit Log Management:
Create a service key for that service instance:
Do the service call:
After doing all the above steps, you should be able to get the service response in JSON format with all the audit logs related to that subaccount.
Online docu: Audit Log Retrieval API Usage for Subaccounts in the Cloud Foundry Environment | SAP Help Portal
API docu: SAP Business Accelerator Hub
# (!)Before running the script:
# replace placeholders <> for $uaaUri, $clientId, $clientSecret, and $uri (get them from service key)
# adapt the time_from- and time_to-timestamps in $query
# get oauth token
# ---------------
$uaaUri = "<region-specific uaa authentication host>/oauth/token?grant_type=client_credentials"
$clientId = "<your client id>"
# use single quotes here otherwhise it will not work in PowerShell because of potential $ sign in the client secret string:
$clientSecret = '<your client secret>'
$user = $clientId
$pw = $clientSecret
$pair = "$($user):$($pw)"
$encodedCredentials = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$headers = @{ "Authorization" = "Basic $encodedCredentials" }
$response = Invoke-WebRequest -Uri $UaaUri -Method POST -Headers $headers
$token = (ConvertFrom-Json $response.Content).access_token
# read the audit logs and write to file:
# --------------------------------------
# Canary
# $uri = "https://auditlog-management.cfapps.sap.hana.ondemand.com/auditlog/v2/auditlogrecords"
$uri = "<region-specific auditlog service host>/auditlog/v2/auditlogrecords"
$query = "time_from=2024-02-20T00:00:01&time_to=2024-02-20T23:59:59"
$headers = @{ "Authorization" = "Bearer " + $token; 'Accept' = 'application/json'}
$uri1 = $uri + '?' + $query
$response = Invoke-WebRequest -Uri $uri1 -Headers $headers
# uncomment to print in console:
#$response.statusCode
#$response.Headers.paging
if ($response.statusCode -eq 200) {
$response.RawContent | Out-File -FilePath .\audit-logs.txt
# read remaining audit logs:
while ($response.Headers.containsKey("paging")) {
$uri2 = $uri + '?' + $response.Headers.paging
$response = Invoke-WebRequest -Uri $uri2 -Headers $headers
if ($response.statusCode -eq 200) {
$response.RawContent | Out-File -FilePath .\audit-logs.txt -Append
} else { break }
}
# uncomment to display file content:
# Get-Content -Path .\audit-logs.txt
}
::from https://blog.danskingdom.com/allow-others-to-run-your-powershell-scripts-from-a-batch-file-they-will-love-you-for-it/
@ECHO OFF
CLS
SET ThisScriptsDirectory=%~dp0
SET PowerShellScriptPath=%ThisScriptsDirectory%MyPowerShellScript.ps1
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%PowerShellScriptPath%'";
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
3 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |