Audit CloudBees CD/RO server logs

2 minute readAutomation

CloudBees CD/RO server log files include a request-response data structure that aids in tracking and auditing API calls. Requests are automatically logged at the default setting, com.electriccloud=DEBUG level. Requests are no longer logged or shown if a user changes this setting.

The following key fields allow you to configure logging tools to perform complete audits of all actions performed on the CloudBees CD/RO server, including monitoring the lifecycle of entities, such as their creation, modification, and deletion:

  • userName: This field captures the username of the individual who made the API call, enabling user-level tracking of actions.

  • publicSessionId: This unique session identifier distinguishes requests originating from different sources, such as CLI, a web-based UI, or other APIs, enhancing session-specific logging.

Additionally, configure your logging tools to capture responses to API calls, such as: create<ObjectName>, modify<ObjectName>, delete<ObjectName>, and set<ObjectName>.

publicSessionId cannot be used to perform API calls.

Authentication handling

All requests sent to the server are accepted. However, if an unauthenticated user (or a user with an expired session) makes a request to the server, the userName and publicSessionId fields are omitted from the response.

Response formats and examples

The userName and publicSessionId fields are incorporated into various response formats, such as: XML, JSON, and REST.

XML API response format

Examples in XML format:

<?xml version="1.0" encoding="UTF-8"?>

<requests version="2.2" timeout="180" sessionId="[PROTECTED]">
  <request requestId="1">
    <getZones/>
  </request>
</requests>
<?xml version="1.0" encoding="UTF-8"?>

<requests version="2.2" timeout="180" sessionId="[PROTECTED]">
  <request requestId="1">
    <login>
      <userName>admin</userName>
      <password>[PROTECTED]</password>
    </login>
  </request>
</requests>
<?xml version="1.0" encoding="UTF-8"?>

<requests version="2.2" timeout="180" sessionId="[PROTECTED]" publicSessionId="GJUKBPGVB227B62Q" userName="admin">
  <request requestId="1">
    <getZones/>
  </request>
</requests>
<?xml version="1.0" encoding="UTF-8"?>

<requests version="2.2" timeout="180" sessionId="[PROTECTED]" publicSessionId="GJUKBPGVB227B62Q" userName="admin">
  <request requestId="1">
    <logout/>
  </request>
</requests>

JSON API response format

Examples in JSON format:

2023-10-23T17:04:39.831 | DEBUG | qtp1961569592-45               |          |                                      |                                                                             | ApiServletImpl                 | servletRequestContext[id=9,on 127.0.0.1:8443,from 172.17.0.1:47510,bytes=167]:
{
  "version" : "2.2",
  "timeout" : 180,
  "sessionId" : "[PROTECTED]",
  "requests" : [ {
    "parameters" : {
      "userName" : "admin",
      "password" : "[PROTECTED]"
    },
    "requestId" : 1,
    "operation" : "login"
  } ]
}
2023-10-23T17:04:46.236 | DEBUG | qtp1961569592-312              |          |                                      |                                                                             | ApiServletImpl                 | servletRequestContext[id=10,on 127.0.0.1:8443,from 172.17.0.1:57466,bytes=114]:
{
  "version" : "2.2",
  "timeout" : 180,
  "sessionId" : "[PROTECTED]",
  "publicSessionId" : "ITDH9L8MSVFDRN3X",
  "userName" : "admin",
  "requests" : [ {
    "operation" : "getZones",
    "requestId" : 1
  } ]
}

REST API response format

Example of a REST API call:

2023-10-23T17:32:07.970 | REST request [publicSessionId=7O5GNPB49DLPSO4S, userName=admin]: GET /zones

Logging examples in CRUD operations

Examples demonstrating how these fields appear in log messages for various CRUD operations:

  • Create: <createStep>…​</createStep>

    ApiServletImpl                 | servletRequestContext[id=139,on 127.0.0.1:8443,from 192.168.251.106:59224,bytes=369]:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <requests version="2.2" timeout="180" sessionId="[PROTECTED]" publicSessionId="WQBMC1UUK9GX57UC" userName="user2">
      <request requestId="1">
        <createStep>
          <command>echo "Hello World"</command>
          <procedureName>Procedure1</procedureName>
          <projectName>Project1</projectName>
          <stepName>Step1</stepName>
        </createStep>
      </request>
    </requests>
  • Read (Get): <getStep>…​</getStep>

    ApiServletImpl                 | servletRequestContext[id=149,on 127.0.0.1:8443,from 192.168.251.106:36476,bytes=326]:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <requests version="2.0" sessionId="[PROTECTED]" publicSessionId="ERME99LH2AD7LHS3" userName="user1">
      <request requestId="1">
        <getStep>
          <projectName>Project1</projectName>
          <procedureName>Procedure1</procedureName>
          <stepName>Step1</stepName>
        </getStep>
      </request>
    </requests>
  • Update (Modify): (The example below for a Modify operation is JSON format.)

    2024-01-12T13:28:11.332 | DEBUG | qtp852665143-55                |          |                                      |                                                                             | ApiServletImpl                 | servletRequestContext[id=154,on 127.0.0.1:8443,from 192.168.251.106:59294,bytes=586]:
    {
      "version" : "2.0",
      "sessionId" : "[PROTECTED]",
      "publicSessionId" : "ERME99LH2AD7LHS3",
      "userName" : "user1",
      "requests" : [ {
        "requestId" : "8",
        "operation" : "modifyStep",
        "parameters" : {
          "projectName" : "Project1",
          "procedureName" : "Procedure1",
          "stepName" : "Step1",
          "description" : "",
          "resourceName" : "local",
          "precondition" : "",
          "condition" : "",
          "timeLimit" : "",
          "timeLimitUnits" : "minutes",
          "parallel" : "0",
          "alwaysRun" : "0",
          "workspaceName" : "",
          "credentialName" : "",
          "errorHandling" : "failProcedure",
          "exclusiveMode" : "none",
          "releaseMode" : "none",
          "command" : "echo \"Hello, World!\"",
          "postProcessor" : "",
          "broadcast" : "0",
          "shell" : "",
          "workingDirectory" : "",
          "logFileName" : "StepLog1.log"
        }
      } ]
    }
  • Delete: <deleteStep>…​</deleteStep>

    ApiServletImpl                 | servletRequestContext[id=159,on 127.0.0.1:8443,from 192.168.251.106:38068,bytes=332]:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <requests version="2.0" sessionId="[PROTECTED]" publicSessionId="ERME99LH2AD7LHS3" userName="user1">
      <request requestId="0">
        <deleteStep>
          <projectName>Project1</projectName>
          <procedureName>Procedure1</procedureName>
          <stepName>Step1</stepName>
        </deleteStep>
      </request>
    </requests>coming