Logging #

FLAT Server writes most of its logs in JSON format to the standard error output (stderr). One line is written for each event. I.e. one line each for a client request, an upstream request or an error.

For comfortable log processing, events are discriminated with the type field that is one of

The access log can be augmented with custom fields.

All JSON log lines have a requestID field. Its value can be used to correlate log events.

FLAT Access Log #

Client requests received by FLAT are recorded as type flat_access and have the following format:

{
  "timestamp": "2019-10-15T13:28:26+00:00",
  "type": "flat_access",
  "requestID": "XaXJeWA-@B@3XFNhk42H@QAAAAQ",
  "url": "http://localhost:8080/api/path",
  "path": "/api/path",
  "status": 200,
  "method": "GET",
  "agent": "curl/7.54.0",
  "referrer": "",
  "mime": "application/json",
  "realtime": 0.019845,
  "bytes": 563,
  "requestbytes": 0,
  "flow": "flow.xml",
  "requestmime": "",
  "location": ""
}

Fields #

Request Log #

Outgoing requests to upstream APIs are recorded as type flat_request and have the following format:

{
  "timestamp": "2019-10-15T13:28:26+00:00",
  "type": "flat_request",
  "requestID": "XaXJeWA-@B@3XFNhk42H@QAAAAQ",
  "url": "https://example.com/?foo=bar",
  "method": "get",
  "status": 200,
  "mime": "application/json",
  "bytes": 231,
  "duration": 0.607165,
  "id": "main.0",
  "cacheHit": false,
  "refresh": false,
  "timing": {
    "DNS": "17.391",
    "TCP": "96.475",
    "TTFB": "623.931"
  },
  "curlErrorCode": 28,
  "curlErrorMessage": "Operation timed out after 3000 milliseconds with 0 out of -1 bytes received"
}

Fields #

¹ a string representing a decimal number formatted as "x.xxx" (see example above)

Error Log #

Errors that have occurred during processing, such as Validation Errors are recorded as type flat_alert.

These log events should be monitored!

{
  "timestamp": "2019-10-15T13:28:26+00:00",
  "type": "flat_alert",
  "requestID": "XaXJeWA-@B@3XFNhk42H@QAAAAQ",
  "topic": "validation",
  "message": "Response validation failed: Type constraint violated in body: String value found, but an object is required. "
}

Fields #

PHP Access Log #

Additional information is recorded in separate lines with the php_access format:

{
  "type": "php_access",
  "requestid": "XaXJeWA-@B@3XFNhk42H@QAAAAQ",
  "uri": "/api/v1/version",
  "query": "",
  "timestamp": 1715797252,
  "project": "_default",
  "method": "GET",
  "pid": 81,
  "usertime": 0,
  "systemtime": 0,
  "realtime": 8.222,
  "fitrequesttime": 0,
  "fitrequestvolume": 0,
  "req": "sub",
  "status": "200",
  "mime": "application/json"
}

Fields #

httpd Access Log #

Client requests received by the Apache httpd included in FLAT are recorded as type apache_access. By default, they are written to /dev/stderr, and they can be disabled by setting CUSTOMLOG=/dev/null. They have the following format:

{
  "timestamp": "2024-05-15T14:36:09+00:00",
  "type": "apache_access",
  "remoteIp": "172.28.1.170",
  "domain": "example.com",
  "port": 80,
  "user": "-",
  "servertime": 1714739569.207,
  "requestID": "XaXJeWA-@B@3XFNhk42H@QAAAAQ",
  "path": "/",
  "query": "?foo=bar",
  "status": "200",
  "method": "GET",
  "bytes": 231,
  "agent": "curl/7.54.1",
  "referrer": "-",
  "Forw": "10.2.79.104, 80.187.123.220, 64.252.89.191",
  "Via": "-",
  "Accept": "*/*",
  "host": "example.com",
  "Location": "-",
  "XRW": "-",
  "realtime": 5616,
  "project": "_default"
}

Fields #

Other Log Events #

In rare cases plain text log lines may be written to stdout or stderr. For example, this happens during startup.

These lines are usually error log messages of the included Apache Web server that look like this:

[Tue Oct 15 13:11:30.190335 2019] [mpm_worker:notice] [pid 28:tid 139763282708608] - AH00292: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips configured -- resuming normal operations

phpstats Log #

If you chose to run the optional phpstats container, it will provide real time information regarding the utilization of the php-fpm process. This can be used to tune the PHP-FPM configuration or feed a custom metric to your autoscaler.

Fields #

{
  "type": "fpmstats",
  "timestamp": 1714732438,
  "listen_queue": 0,
  "idle_processes": 6,
  "active_processes": 4,
  "total_processes": 10,
  "slow_requests": 0
}

See also #