loggly
Sends request logs to Loggly.
logglyPriority 411What it does
loggly sends the records of the requests that reach the route or other object it is added to, to a Loggly account named by its Customer token. How they travel is set once in the plugin metadata. Under Protocol, syslog sends each entry to the Host and Port over UDP, while http and https post the records in bulk.
Every entry carries a Severity, INFO unless you change it. The Severity map gives one exact upstream status, 503 for example, a level of its own, and every other status keeps the level above.
When to use it
- The operations team already reads its logs in Loggly, and the request records of the orders API should join them there.
- Records of server errors should stand out: a
500,502,503or504from the backend is sent atERR, every other request atINFO. - Records should be found by tag, for example
gatewayandproduction, beside the logs of other systems in the same account. - The network lets no syslog traffic out, and the records should travel over HTTPS instead.
Not for records sent to a syslog server you run — see syslog (Sends request logs to a syslog server), records sent to an HTTP collector of your own — see http-logger (Sends request logs to an HTTP endpoint in batches) or records kept in Elasticsearch — see elasticsearch-logger (Sends request logs to an Elasticsearch index).
Set it up
Send tagged records over syslog and raise the severity of server errors
The severity is written into the syslog frame only; over the http or https transport the record goes as plain JSON without it.
Under Basics set Customer token to <secret>. Under Behavior leave Severity at INFO, fill Tags as in the JSON below and fill Severity map as in the JSON below.
{
"customer_token": "<secret>",
"tags": [
"gateway",
"production"
],
"severity": "INFO",
"severity_map": {
"500": "ERR",
"502": "ERR",
"503": "ERR",
"504": "ERR"
}
}
More scenarios
Send the records over HTTPS instead of syslogenvironment-wide settings
Set Protocol to https and leave Timeout at 5000 milliseconds.
{
"protocol": "https",
"timeout": 5000
}
Things to know
- Customer token — The token is also part of the address the
httpandhttpstransports post to. - Customer token — A token is required: a loggly without one is refused when you save.
- Tags — An empty list of tags is refused when you save.
- Severity map — Each key is one exact upstream status, such as 503, and ranges like 5xx are refused. Other statuses keep the level above.
- Severity map — A status outside the range of HTTP statuses,
600for example, is refused when you save. - Severity map — A level that Severity does not offer,
FATALfor example, is refused when you save. - 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.
- Include request body when — The console’s form draws one level of conditions; a value that nests deeper is kept as it is and edited in Raw JSON.
- Include response body when — The console’s form draws one level of conditions; a value that nests deeper is kept as it is and edited in Raw JSON.
- 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, Protocol accepts only
http,httpsandsyslog;tcpis refused when you save. - Protocol — Syslog sends each entry to the host and port over UDP; http and https post a bulk batch to an address built from the host and the customer token.
- 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.
- AdviceChoose
httpsin the plugin metadata when the records leave your network, as the second example does. - AdviceTurn on the request and response bodies only on routes whose records may hold what clients and the backend send.
Settings
The fields as the console shows them, section by section.
Basics
customer_tokenstringRequiredThe customer token of your Loggly account. It is also part of the address the http and https transports post to. Stored on the engine and shown only to roles that manage this object.
Behavior
severitystringdefault INFOThe level every entry carries, in upper or lower case. Mixed case such as Info is refused.
tagsarray of stringsdefault ["apisix"]A tag may not begin with tag=, which is the prefix the syslog frame writes around each one itself.
severity_mapobjectThe values are the same level names as above, read in either case. An object whose keys are a name matching ^[1-5][0-9]{2}$, each with a string as its value.
ssl_verifybooleandefault trueChecked only on the https transport. Over syslog nothing is verified.
log_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 logglyEnvironment-wide settings
Set once per environment, under Plugins › loggly. Every loggly in the environment uses these.
hoststringdefault logs-01.loggly.comOver syslog the host of the receiver; over http and https the account host the bulk address is built from, with or without a scheme.
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.
portintegerdefault 514Read on the syslog transport alone; a bulk address carries its own port.
protocolstringdefault syslogtimeoutintegerdefault 5000One timeout, applied to the syslog socket and to the bulk request alike.