FLAT
CouperSevenval TechnologiesDocker ImageGithub
master
master
  • Changelog
  • FLAT
  • Administration
    • Configuration
    • Docker
    • Logging
  • Cookbook
    • Using the Built-in Mocking
    • Performing Additional Checks on JWT Access Tokens
    • Logging Custom Fields
    • Using Environment Variables
    • Handling Errors with an Error Flow
    • File Serving
    • Forwarding a Request to an Upstream API
    • Extracting Common Initialization Flow Tasks
    • Encoding and Decoding JWT
    • Passing Header Fields to the Client
    • How can I pass an arbitrary header field to an upstream system?
    • Performing Additional Checks on JWT Access Tokens
    • Proxying requests to Upstream APIs
    • Increasing the Request Timeout
    • How can I see what the client requested?
    • Using Swagger UI for API Documentation
    • Testing API Requests
    • Testing with Backend Requests
    • Testing Templates
    • Sending POST Requests
    • Processing Upstream Responses
    • Protecting Access using JWT Tokens
  • Reference
    • Configuration
    • Debugging
    • flat CLI
    • Flow
    • Variables
    • OpenAPI / Swagger Integration
    • OpenAPI
      • CORS - Cross-Origin Resource Sharing
    • OpenAPI
      • Differences from Swagger
    • OpenAPI
      • Mocking
    • OpenAPI
      • Routing
    • OpenAPI
      • Security
    • OpenAPI
      • Upstream APIs
    • OpenAPI
      • Validation
    • Flow Actions
      • assert Action
      • auth Action
      • backend-flow Action
      • copy Action
      • debug Action
      • dump Action
      • echo Action
      • error Action
      • eval Action
      • log Action
      • nameshave Action
      • pass-body Action
      • proxy-request Action
      • regex Action
      • request Action
      • requests Action
      • serve Action
      • set-config Action
      • set-env Action
      • set-response-headers Action
      • set-status Action
      • sub-flow Action
      • template Action
      • test-request Action
      • xslt Action
    • Functions
      • apply-codecs()
      • array-reverse()
      • array()
      • base64-decode()
      • base64-encode()
      • body()
      • calc-signature()
      • capitalize-first()
      • content()
      • decrypt-xml()
      • decrypt()
      • encrypt()
      • ends-with()
      • file-exists()
      • fit-document()
      • fit-log()
      • fit-serialize()
      • get-log()
      • has-class()
      • html-parse()
      • join()
      • json-doc()
      • json-parse()
      • json-stringify()
      • json-to-csv()
      • json-to-xml()
      • jwt-decode()
      • jwt-encode()
      • ldap-lookup()
      • ldap-query()
      • lookup()
      • matches()
      • md5()
      • replace()
      • sort()
      • split()
      • tolower()
      • toupper()
      • trim()
      • unixtime()
      • urldecode(), url-decode()
      • urlencode(), url-encode()
      • uuid3() and uuid4()
      • verify-signature()
      • verify-xmldsig()
      • xml-parse()
      • xml-to-json()
    • Templating
      • {{,}}
      • Comment {{// …}}
      • Dot {{.}}
      • Conditional `{{if <condition>}} … {{elseif <condition> }} … {{else}} … {{end}}
      • loop
      • ?? Operator
      • Object XML Notation (OXN)
      • Pair Producer {{: …}}
      • Placeholder
      • Template Variables
      • with
    • Testing
  • Tutorial
Powered by GitBook
On this page
  • Access Log
  • Fields
  • Request Log
  • Fields
  • Error Log
  • Fields
  • Other Log Events
  • See also

Was this helpful?

  1. Administration

Logging

PreviousDockerNextCookbook

Last updated 4 years ago

Was this helpful?

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

  • flat_access

  • flat_request

  • flat_alert

The access log can be augmented with .

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

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

  • timestamp: Start time of the request in ISO 8601 format

  • type: Event type discriminator, fixed string flat_access

  • url: client request URL

  • path: path, query string and fragment of the client request URL

  • status: HTTP status code of the client response (number) (200, 404, 500, …)

  • method: HTTP method of the client request (GET, POST, …)

  • agent: User-Agent header of the client request

  • referrer: Referer [sic] header of the client request

  • mime: Content-Type header of the client response (text/html, application/json…)

  • realtime: request duration in seconds (number)

  • bytes: uncompressed size of the outgoing response body (number)

  • requestbytes: uncompressed size of the incoming request body (number)

  • requestmime: Content-Type header of the client request i.e. MIME type of the incoming request body

  • location: Location header of the client response

Request Log

{
  "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

  • timestamp: Start time of the request in ISO 8601 format

  • type: Event type discriminator, fixed string flat_request

  • requestID: Log Correlation ID

  • url: Absolute URL of the upstream request including query-string

  • method: HTTP method of the upstream request (GET, POST, …)

  • status: HTTP status code of the upstream response (number) (0 for failed requests)

  • mime: Content-Type header of the upstream response (text/html, application/json…)

  • bytes: Size of the (possibly compressed) response body in bytes (number) (0 if the body is empty; when read from the internal cache, the original response length is used)

  • duration: Time spent waiting for the response in seconds (number)

  • refresh: Indicating whether the response was a 304 response to a request revalidating the local cache (boolean)

  • timing: Contains timing information about request phases

    • DNS: Time to perform name lookup in ms (number)

    • TCP: Time to establish a TCP connection in ms (number) (may be near zero for keep-alive requests)

    • TTFB: Time to first byte in ms since request was sent (number)

  • curlErrorMessage: Text error message of libcurl for failed requests (optional)

Error Log

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

  • timestamp: Start time of the request in ISO 8601 format

  • type: Event type discriminator, fixed string flat_alert

  • requestID: Log Correlation ID

  • message: An informative error message

Other Log Events

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

[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

See also

requestID: Log Correlation ID, accessible in flows as and

flow: filename of the applied

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

id: Request/Content identifier as configured with the request's or content attribute (suffixed with .N where N is incremented for each followed redirect starting with 0)

cacheHit: Indicating whether the response was read from FLAT's HTTP Cache (boolean) (activated with request option )

curlErrorCode: for failed requests (number, optional) (e.g. 28)

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

topic: Log topic of the alert, corresponds to

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

(Cookbook)

(Reference)

(Reference)

custom fields
flow
requests
cURL Error Code
Validation Errors
debugging topics
Apache Web server
Custom Logging
log action
get-log() function
id field
use-http-cache
$request/id
$error/requestID