udp-logger
Sends request logs to a UDP server.
udp-loggerPriority 400What it does
udp-logger sends the records of the requests that reach the route or other object it is added to, as UDP datagrams to a server at Host and Port. The records are collected on the gateway node and sent in batches, so one send can carry several records.
The datagrams travel in plain text, and the form offers no encryption. For records that must travel encrypted, choose tcp-logger with TLS on, or http-logger with an HTTPS address.
When to use it
- A log collector of the operations team listens on a UDP port inside the gateway network, for example
logs.internalon port5140. - The records of a busy route, the orders API for example, should leave the gateway without a connection to keep open.
- Every route should send the same few fields, the client, method, path, status and time, set once in the plugin metadata.
Not for records sent over a TCP connection, encrypted if needed — see tcp-logger (Sends request logs to a TCP server), records sent to a syslog server — see syslog (Sends request logs to a syslog server) or records sent to an HTTP collector — see http-logger (Sends request logs to an HTTP endpoint in batches).
Set it up
Send request records to a UDP collector
Under Basics set Host to logs.internal and set Port to 5140. Under Behavior set Timeout to 2 seconds.
{
"host": "logs.internal",
"port": 5140,
"timeout": 2
}
More scenarios
Shape the record every route sends to the UDP collectorenvironment-wide settings
Fill Log format as in the JSON below.
{
"log_format": {
"client": "$remote_addr",
"method": "$request_method",
"path": "$uri",
"status": "$status",
"at": "$time_iso8601"
}
}
Things to know
- Port — The records arrive as UDP datagrams on this port,
5140in the example. - Port — A port of
0or above65535is refused when you save. - A Log format in the plugin metadata shapes the record of every route whose udp-logger names no Log format of its own. In the example each record carries
pathwith the path the client asked for. - Log format extra — Added to the default record only: while a log format is set, on this object or in the plugin's metadata, the engine writes that format alone and reads nothing here.
- Timeout — A whole number of seconds: a fraction,
1.5for example, is refused when you save. - Include request body when — Not checked at save: an expression the engine cannot read is stored, and the body is then never logged. Only the gateway's error log says so.
- Include response body when — Not checked at save: an expression the engine cannot read is stored, and the body is then never logged. Only the gateway's error log says so.
- Batch size — A batch goes out when it holds Batch size records, when its first record has waited Buffer duration, or when nothing new arrived for Inactive timeout.
- In the plugin metadata, Pending entry limit caps the backlog. While more entries than this wait to be sent, new ones are dropped rather than queued.
- AdviceSend records over UDP only to a collector inside your own network.
- AdviceTurn on the request and response bodies only on routes whose collector is meant to hold what clients and the backend send.
Settings
The fields as the console shows them, section by section.
Basics
hoststringRequiredportintegerRequiredBehavior
timeoutintegerdefault 3log_formatobject{"host":"$host","client":"$remote_addr","status":"$status","at":"$time_iso8601"}log_format_extraobject{"zone":"eu-west","gateway":"$hostname"}include_req_bodybooleandefault falseinclude_req_body_exprarrayinclude_resp_bodybooleandefault falseinclude_resp_body_exprarraymax_req_body_bytesintegerdefault 524288max_resp_body_bytesintegerdefault 524288Advanced
batch_max_sizeintegerdefault 1000buffer_durationintegerdefault 60inactive_timeoutintegerdefault 5max_retry_countintegerdefault 0retry_delayintegerdefault 1namestringdefault udp loggerEnvironment-wide settings
Set once per environment, under Plugins › udp-logger. Every udp-logger in the environment uses these.
log_formatobject{"host":"$host","client":"$remote_addr","status":"$status","at":"$time_iso8601"}log_format_extraobject{"zone":"eu-west","gateway":"$hostname"}max_pending_entriesintegerdefault 8192How many log entries may wait to be sent. While the backlog is above this number, new entries are dropped rather than queued.