Skip to main content

Access logs to Elasticsearch, syslog and HTTP, with the Kafka and Splunk forms

Send a record per request from a Route to your Elasticsearch, a syslog collector or an HTTP endpoint with the logger Plugins, next to Traffic Explorer.

By Akif F. Güven Updated Observability

What you will have at the end

A Route, orders-api, that writes one record per request to three places you run, next to the request records G8 keeps itself: an index of your choosing in Elasticsearch, with a log format you wrote; a syslog collector over UDP; and an HTTP endpoint that receives batches as JSON. Each record arrives with the API key the caller sent replaced by asterisks. The three Plugin additions are in the audit log, with the Elasticsearch password masked.

Traffic Explorer and the logger Plugins are two different things

Traffic Explorer is G8’s own record of every request in the Environment, written by the gateway into the Environment’s Elasticsearch or OpenSearch under a name derived from the Environment’s id, read back in the console with the masking, retention and the body permission set under Traffic Explorer › Settings. On this install it is visible under Plugins › Global rules as the global rule g8-request-records, which the console manages and you do not edit.

The logger Plugins are yours. They send a record per request to whatever you run, in the format you choose, from one Route, one Service or, as a Global rule you create, from every Route. The two run side by side: this article leaves Traffic Explorer as it is and adds three loggers to one Route.

Prerequisites

  • A Route with traffic. Here it is orders-api, which serves /orders/* with key-auth and limit-count from Rate limiting per Consumer; the calls below are made as the Consumer mobile_app.
  • The targets. An Elasticsearch the gateway can reach, here the lab’s elasticsearch:9200 with the elastic account; a syslog collector and an HTTP endpoint, here one small container, blog-logsink, that prints every syslog line and every HTTP body it receives, so that the article can show what arrived. The lab has no Kafka and no Splunk; their forms are described, and the article says plainly that they were not run.
  • A role that may manage Routes. The screenshots below were taken as nora.becker.

Elasticsearch: your own index, your own format

Open the Route, select the Plugins tab, Add plugin, and choose elasticsearch-logger. Under Basics:

  • One address or Several addresses: with several, each batch goes to one of them picked at random. One here: Endpoint address http://elasticsearch:9200. The note explains why an address that ends in a slash is refused: the bulk path is added to it.
  • Field › Index: shop-access. The note says the name is built again for every request, with a time format in braces and request variables, so shop-access-{yyyy.MM.dd} or an index per Route is a matter of the name alone.
  • Auth › Username and Password: the account the gateway writes with. The password is stored on the engine and shown only to roles that manage the Route; for production, give the gateway an account that may write this index and nothing else.

The Basics section of the elasticsearch-logger form on orders-api: One address selected, Endpoint address http://elasticsearch:9200, Index shop-access, and under Auth the Password typed and masked One address, one index, one account. The index name is rebuilt per request, so a date or a variable in it is allowed.

Under Behavior, Log format is where the record is shaped. Empty, the engine writes its default record, which carries the whole request and response: headers, sizes, timings, the Consumer and the Route. The article writes a smaller one, so that each line of the index holds exactly the fields the analysts asked for. Each value is a request variable:

{
  "host": "$host",
  "client": "$remote_addr",
  "method": "$request_method",
  "uri": "$request_uri",
  "status": "$status",
  "route": "$route_name",
  "consumer": "$consumer_name",
  "apikey": "$http_apikey",
  "latency_ms": "$request_time",
  "at": "$time_iso8601"
}

The apikey line is there on purpose: it is the header the Consumer authenticates with, and the next section shows what the gateway does with it. Log format extra adds fields to the default record only; the note under it says that while a log format is set, the engine writes that format alone.

The Behavior section of the elasticsearch-logger form: SSL verify on, the Log format editor holding the ten-field JSON above with "Valid JSON · matches the field's schema" under it, and the Log format extra example The record as it will be written, checked against the field’s schema while you type.

Batch size and Inactive timeout sit under the same section and decide how many records a batch holds and how long the sender waits for more. The banner on top of the form, two settings edited as JSON, names the two fields that have no control of their own, the log format and its extra, which the editor above draws. Include request body and Include response body are off, and stay off here.

Select Add plugin.

What arrived in Elasticsearch

Three requests as mobile_app, then a search of the index:

curl -s -u elastic:… 'http://localhost:9200/shop-access/_search?size=2&sort=at:desc'
{"at": "2026-10-13T17:40:17+00:00", "host": "localhost", "client": "<the client address>",
 "method": "GET", "uri": "/orders/ord-10421", "status": 200, "route": "orders-api",
 "consumer": "mobile_app", "apikey": "********", "latency_ms": 0.023,
 "route_id": "00000000000000010173"}

The record has the ten fields of the format, plus the Route’s id, which the engine adds. The apikey field reads ********: the gateway masked the header before the record left it, under the same rule that masks it in Traffic Explorer, without anything set on the logger. The analysts get the fact that a key was sent, never the key.

Syslog: a line per request to your collector

Add plugin, syslog. Under Basics: Host blog-logsink, Port 514, Socket type udp; tcp is the default. The TLS switch under Behavior is drawn with a warning of its own: turning it on changes nothing, the lines always travel in plain text. Put a TLS relay in front of the collector when the lines must be encrypted. Pool size, drawn for tcp, is how many connections to the collector stay open.

The saved syslog Plugin on orders-api, opened for editing: Host blog-logsink, Port 514 with the note Between 1 and 65535, Socket type udp, and the Behavior section below Host, port and transport, shown on the saved Plugin. The record format is the same default as the other loggers unless a Log format is set.

One setting under More decided whether anything arrived at all: Flush limit, 4096 bytes by default. Its help says it plainly: lines wait until this much has built up, however long that takes, so a quiet Route may not send a line for a long time. The first run of this article saw nothing at the collector until Flush limit was set to 128 bytes, after which every batch went out at once. Set it low for a Route with little traffic.

The Flush limit field of the syslog form under More, set to 128, with the note that the drop limit has to stand above it and the help line that lines wait until this much has built up, however long that takes The one field this section turns on. At its default a quiet Route sends nothing for a long time.

The collector received one line per request, in the syslog format with the record as JSON, shortened here:

<46>1 2026-10-13T17:46:31.778Z localhost … {"client_ip":"<the client address>",
"consumer":{"username":"mobile_app"},"upstream_latency":1,
"response":{"size":355,"status":200,"headers":{…}},
"request":{"method":"GET","headers":{"host":"localhost:9281",
"x-consumer-username":"mobile_app","x-credential-identifier":"mobile-app-key",
"apikey":"********",…},"uri":"/orders/ord-10421"},"start_time":1791913591744,…}

The default record carries the request headers, and the API key among them is masked the same way.

HTTP: a batch of JSON to your endpoint

Add plugin, http-logger. Basics › URI: http://blog-logsink:8080/access-logs; Auth header is a value sent as the Authorization header with every batch, stored on the engine and masked in the form. Under Behavior, Concat method json sends each batch as a JSON array; new_line sends one record per line.

The http-logger form on orders-api: URI http://blog-logsink:8080/access-logs, the Auth header empty and masked, Concat method json, Timeout 3 s, SSL verify off, and the banner that two of its settings are edited as JSON An address and, if the endpoint wants one, a header. The batch arrives as a JSON array.

The endpoint received a POST per batch, each an array of records in the default format, with "apikey":"********" in the request headers of every record.

Kafka and Splunk, not run here

kafka-logger takes a list of Brokers, each a host and port with optional SASL settings, a Kafka topic, a Key for partitioning, the Meta format of the record and a TLS switch, and the same Log format, batch and body settings as the loggers above. The lab has no Kafka, so the Plugin was opened and not saved.

splunk-hec-logging takes an Endpoint with the HEC Token, sent as Splunk followed by the token with every batch and masked in the form, the full collector URI including its path, an optional Channel sent as the X-Splunk-Request-Channel header, and the batch settings. No Splunk is reachable from the lab; the form was opened and not saved.

Both carry the same batch settings. Whether the masks reach their records was not measured.

What the audit log keeps

Each logger is a Route update: who, when, which Route, and the Plugin block as the difference. The elasticsearch-logger record shows the endpoint, the index, the username and the whole log format, with the password as •••• and the note under the diff that a masked value changed, plugins.elasticsearch-logger.auth.password.

The Change section of the audit record of the orders-api Route update: the elasticsearch-logger block added on the after side with auth password as four dots and username elastic, the index shop-access, the ten-line log format and the endpoint address, next to the unchanged key-auth and limit-count blocks The logger as the engine received it, with the store password masked on both sides.

What to do next

Written by
Akif F. Güven
Engineer, G8
Was this helpful?
Next step

See G8 in a demo

We’ll show you the console with APIs and AI traffic like yours, and answer the questions these articles leave open.

  1. 01Demo
  2. 02Proof of conceptOn Docker for a quick start, or on the infrastructure you plan to run G8 on.
  3. 03LicenseWe prepare a quote for your edition and nodes, and you receive a signed license file.