How to enable logging for RHEV REST API requests?

Solution Verified - Updated -

Environment

Red Hat Enterprise Virtualization 3.x

Issue

What log can be used in order to troubleshoot requests coming to RHEV REST API?

Resolution

Enable Logging:

Edit engine-service.xml.in, insert the access-log line below within the virtual-server section, and restart the ovirt-engine service.
* In RHEV 3.2 and earlier this file can be found at /usr/share/ovirt-engine/service/engine-service.xml.in
* In RHEV 3.3+ this file can be found at /usr/share/ovirt-engine/services/ovirt-engine/ovirt-engine.xml.in

# vim /usr/share/ovirt-engine/service/engine-service.xml.in
--- SNIP ---
    <subsystem xmlns="urn:jboss:domain:web:1.1" native="false" default-virtual-server="default-host">
--- SNIP ---
      <virtual-server name="default-host" enable-welcome-root="false">
        <access-log pattern='%h %l %u %t %r %s %b %{Referer}i %{User-Agent}i %S %T'/>
--- SNIP ---
      </virtual-server>
--- SNIP ---
    </subsystem>
--- SNIP ---

# service ovirt-engine restart

This change will cause JBoss / RHEV engine to log all requests, including the URL, HTTP method, and the time it took to respond. This log will be stored in the /var/log/ovirt-engine/default-host/ directory.

Understand access.log messages:

Looking at the requested format in the file:

<access-log pattern='%h %l %u %t %r %s %b %{Referer}i %{User-Agent}i %S %T'/>

Looking at the actual output ion the log:

[root@rhev-m default-host]$ grep POST access_log.2013-07-09 | grep Ruby | grep -v stop| grep -v start
10.10.177.217 - - [09/Jul/2013:13:49:45 -0400] POST /api/vms HTTP/1.1 202 3424 - Ruby 7pkrrV2kHavrsmKO+vFR3Z7C 12.207

We get the following info:

  • The "hyphen" in the output indicates that the requested piece of information is not available
  • %h This is the IP address of the client (remote host) which made the request to the server
  • %l Remote log name -> missing in the example
  • %u This is the userid of the person requesting the document as determined by HTTP authentication -> missing in the example
  • %t time
  • %r The request line from the client - POST /api/vms HTTP/1.1
    -> method used: POST
    -> resource requested: /api/vms
    -> protocol used: HTTP/1.1
  • %s This is the status code that the server sends back to the client - 200
    This information is very valuable, because it reveals whether the request resulted in a successful response (codes beginning in 2), a redirection (codes beginning in 3), an error caused by the client (codes beginning in 4), or an error in the server (codes beginning in 5). The full list of possible status codes can be found in the HTTP specification (RFC2616 section 10). http://www.w3.org/Protocols/rfc2616/rfc2616.txt
  • %b The last part indicates the size of the object returned to the client, not including the response headers. If no content was returned to the client, this value will be "-". To log "0" for no content, use %B instead.
  • %{Referer}i -> HTTP request header. This gives the site that the client reports having been referred from.
  • %{User-Agent}i : The User-Agent HTTP request header. This is the identifying information that the client browser reports about itself.
  • %S
  • %T The time taken to serve the request, in seconds. In this case, whatever was more then 30 seconds, timed out on the client side.

Source of this information is in apache documentation online.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.