<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>OpenResty Inc. Documentation – OpenResty Edge™ Log Collection</title><link>https://doc.openresty.com/en/edge/edge-ops/log-collection/</link><description>Recent content in OpenResty Edge™ Log Collection on OpenResty Inc. Documentation</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="https://doc.openresty.com/en/edge/edge-ops/log-collection/index.xml" rel="self" type="application/rss+xml"/><item><title>Edge: OpenResty Edge™ Log Collection (Host Deployment)</title><link>https://doc.openresty.com/en/edge/edge-ops/log-collection/log-collection/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://doc.openresty.com/en/edge/edge-ops/log-collection/log-collection/</guid><description>
&lt;p>We recommend using &lt;a href="https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-overview.html">Filebeat&lt;/a> for Openresty Edge error log and access log collection.&lt;/p>
&lt;h2 id="filebeat-installation">
&lt;a class="header-anchor" href="#filebeat-installation" aria-hidden="true">#&lt;/a>
Filebeat Installation
&lt;/h2>
&lt;p>Install Filebeat software on all Openresty Edge Node machines. Please refer to &lt;a href="https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-installation-configuration.html">Filebeat installation&lt;/a>.&lt;/p>
&lt;h2 id="filebeat-configuration">
&lt;a class="header-anchor" href="#filebeat-configuration" aria-hidden="true">#&lt;/a>
Filebeat Configuration
&lt;/h2>
&lt;p>The following configuration is a simple example of collecting error and access logs on the Openresty Edge Node and sending them to Kafka:&lt;/p>
&lt;pre>&lt;code>filebeat.inputs:
- type: log
enabled: true
paths:
- /usr/local/oredge-node/logs/access.log*
- /usr/local/oredge-node/logs/error.log*
output.kafka:
enabled: true
# fill in the kafka broker address, this can also be multiple broker addresses
hosts: [&amp;quot;127.0.0.1:9092&amp;quot;]
topic: edge_node_logs
logging.level: error
# fill in the local host name or IP
name: 127.0.0.1
&lt;/code>&lt;/pre>
&lt;p>Save the above to &lt;code>/etc/filebeat/filebeat.yml&lt;/code> and start the Filebeat service, which will send the logs to Kafka once successfully started.&lt;/p>
&lt;pre>&lt;code class="language-bash">sudo systemctl start filebeat
&lt;/code>&lt;/pre>
&lt;h2 id="validation">
&lt;a class="header-anchor" href="#validation" aria-hidden="true">#&lt;/a>
Validation
&lt;/h2>
&lt;p>We can use the command line tool &lt;code>kafka-console-consumer.sh&lt;/code> provided by Kafka to check if the logs were sent successfully.&lt;/p>
&lt;p>On a machine with Kafka installed, execute the following command (replace the Kafka installation directory as appropriate), and a log output indicates that Filebeat is working properly.&lt;/p>
&lt;pre>&lt;code class="language-bash">$ /opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic edge_node_logs --from-beginning --max-messages 1
{&amp;quot;@timestamp&amp;quot;:&amp;quot;2022-12-27T07:06:53.045Z&amp;quot;,&amp;quot;@metadata&amp;quot;:{&amp;quot;beat&amp;quot;:&amp;quot;filebeat&amp;quot;,&amp;quot;type&amp;quot;:&amp;quot;_doc&amp;quot;,&amp;quot;version&amp;quot;:&amp;quot;8.5.3&amp;quot;},&amp;quot;message&amp;quot;:&amp;quot;127.0.0.1 - - [14/Dec/2022:16:02:36 +0800] test.com \&amp;quot;GET http://test.com/ HTTP/1.1\&amp;quot; 200 22 0.000 \&amp;quot;-\&amp;quot; \&amp;quot;curl/7.61.1\&amp;quot; - - -&amp;quot;,&amp;quot;input&amp;quot;:{&amp;quot;type&amp;quot;:&amp;quot;log&amp;quot;},&amp;quot;ecs&amp;quot;:{&amp;quot;version&amp;quot;:&amp;quot;8.0.0&amp;quot;},&amp;quot;host&amp;quot;:{&amp;quot;name&amp;quot;:&amp;quot;127.0.0.1&amp;quot;},&amp;quot;agent&amp;quot;:{&amp;quot;version&amp;quot;:&amp;quot;8.5.3&amp;quot;,&amp;quot;ephemeral_id&amp;quot;:&amp;quot;fd94a28e-91fe-4365-9584-fe6beb258751&amp;quot;,&amp;quot;id&amp;quot;:&amp;quot;e84c2374-3272-430e-bfe6-84ad2b24b845&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;127.0.0.1&amp;quot;,&amp;quot;type&amp;quot;:&amp;quot;filebeat&amp;quot;},&amp;quot;log&amp;quot;:{&amp;quot;offset&amp;quot;:0,&amp;quot;file&amp;quot;:{&amp;quot;path&amp;quot;:&amp;quot;/usr/local/oredge-node/logs/access.log_20221214.160000&amp;quot;}}}
&lt;/code>&lt;/pre></description></item><item><title>Edge: OpenResty Edge™ Log Collection (Kubernetes Deployment)</title><link>https://doc.openresty.com/en/edge/edge-ops/log-collection/k8s-log-collection/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://doc.openresty.com/en/edge/edge-ops/log-collection/k8s-log-collection/</guid><description>
&lt;p>In a Kubernetes environment, each OpenResty Edge Node Pod includes a built-in log collection sidecar container (&lt;code>oredge-node-log-collector&lt;/code>) based on &lt;a href="https://fluentbit.io/">Fluent Bit&lt;/a>. This sidecar container automatically collects various log files produced by OpenResty Edge Node and outputs them to the container&amp;rsquo;s standard output (stdout) and standard error (stderr), seamlessly integrating with the Kubernetes logging ecosystem. You can view and search these logs using the &lt;code>kubectl logs&lt;/code> command or through log platforms deployed in your cluster (such as Datadog, ELK, Loki, etc.).&lt;/p>
&lt;h2 id="collected-log-types">
&lt;a class="header-anchor" href="#collected-log-types" aria-hidden="true">#&lt;/a>
Collected Log Types
&lt;/h2>
&lt;p>The log collector covers the following OpenResty Edge Node log files:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Log Category&lt;/th>
&lt;th>Log File&lt;/th>
&lt;th>Output Target&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>HTTP Application Access Log&lt;/td>
&lt;td>&lt;code>access.log&lt;/code>&lt;/td>
&lt;td>stdout&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>HTTP Application Error Log&lt;/td>
&lt;td>&lt;code>error.log&lt;/code>&lt;/td>
&lt;td>stderr&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Stream Access Log&lt;/td>
&lt;td>&lt;code>stream_access.log&lt;/code>&lt;/td>
&lt;td>stdout&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Stream Error Log&lt;/td>
&lt;td>&lt;code>stream_error.log&lt;/code>&lt;/td>
&lt;td>stderr&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>DNS Access Log&lt;/td>
&lt;td>&lt;code>dns_access.log&lt;/code>&lt;/td>
&lt;td>stdout&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>DNS Error Log&lt;/td>
&lt;td>&lt;code>dns_error.log&lt;/code>&lt;/td>
&lt;td>stderr&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>HTTP Forward Proxy Access Log&lt;/td>
&lt;td>&lt;code>http_proxy_access.log&lt;/code>&lt;/td>
&lt;td>stdout&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>HTTP Forward Proxy Error Log&lt;/td>
&lt;td>&lt;code>http_proxy_error.log&lt;/code>&lt;/td>
&lt;td>stderr&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>SOCKS5 Access Log&lt;/td>
&lt;td>&lt;code>socks5_access.log&lt;/code>&lt;/td>
&lt;td>stdout&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>SOCKS5 Error Log&lt;/td>
&lt;td>&lt;code>socks5_error.log&lt;/code>&lt;/td>
&lt;td>stderr&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>CC Protection Log&lt;/td>
&lt;td>&lt;code>cc.log&lt;/code>&lt;/td>
&lt;td>stderr&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>WAF Protection Log&lt;/td>
&lt;td>&lt;code>waf.log&lt;/code>&lt;/td>
&lt;td>stderr&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>All access logs are output to stdout, while all error logs and security protection logs (CC, WAF) are output to stderr.&lt;/p>
&lt;h2 id="viewing-logs">
&lt;a class="header-anchor" href="#viewing-logs" aria-hidden="true">#&lt;/a>
Viewing Logs
&lt;/h2>
&lt;p>You can use the &lt;code>kubectl logs&lt;/code> command to view the log collector&amp;rsquo;s output:&lt;/p>
&lt;pre>&lt;code class="language-bash"># View all logs (stdout + stderr)
kubectl logs &amp;lt;oredge-node-pod-name&amp;gt; -c oredge-node-log-collector -n openresty-edge
# View only the last 100 lines
kubectl logs &amp;lt;oredge-node-pod-name&amp;gt; -c oredge-node-log-collector -n openresty-edge --tail=100
# Follow new logs in real time
kubectl logs &amp;lt;oredge-node-pod-name&amp;gt; -c oredge-node-log-collector -n openresty-edge -f
&lt;/code>&lt;/pre>
&lt;p>Each log entry is automatically prefixed with the source file name in the format &lt;code>&amp;lt;filename&amp;gt;: &amp;lt;log content&amp;gt;&lt;/code>, making it easy to distinguish between different log sources. For example:&lt;/p>
&lt;pre>&lt;code>access.log: 192.168.1.1 - - [23/Mar/2026:10:00:00 +0800] &amp;quot;GET / HTTP/1.1&amp;quot; 200 ...
error.log: 2026/03/23 10:00:01 [error] 12345#0: *1 connect() failed ...
waf.log: 2026/03/23 10:00:02 [waf] rule 1001 triggered ...
&lt;/code>&lt;/pre>
&lt;h2 id="restrictions-on-log-file-names-and-paths">
&lt;a class="header-anchor" href="#restrictions-on-log-file-names-and-paths" aria-hidden="true">#&lt;/a>
Restrictions on Log File Names and Paths
&lt;/h2>
&lt;blockquote>
&lt;p>&lt;strong>Note:&lt;/strong> In the Kubernetes deployment mode, the log file names and log paths of OpenResty Edge Node are fixed configurations and &lt;strong>cannot be customized through OpenResty Edge Admin&lt;/strong>. The log collector relies on these fixed file paths for collection. If the log file names or paths are modified, the log collector will be unable to collect the corresponding logs, and those logs will not appear in the container&amp;rsquo;s standard output.&lt;/p>
&lt;/blockquote>
&lt;h2 id="log-collector-resource-configuration">
&lt;a class="header-anchor" href="#log-collector-resource-configuration" aria-hidden="true">#&lt;/a>
Log Collector Resource Configuration
&lt;/h2>
&lt;p>The default resource configuration for the log collection sidecar container is as follows:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Resource Type&lt;/th>
&lt;th>Requests&lt;/th>
&lt;th>Limits&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>CPU&lt;/td>
&lt;td>50m&lt;/td>
&lt;td>500m&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Memory&lt;/td>
&lt;td>64Mi&lt;/td>
&lt;td>512Mi&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>This configuration is suitable for most scenarios. If your OpenResty Edge Node produces a particularly high volume of logs, you can increase the resource limits accordingly in the deployment file.&lt;/p>
&lt;p>You can check the actual resource usage of the log collector using the following command (requires &lt;a href="https://github.com/kubernetes-sigs/metrics-server">Metrics Server&lt;/a> to be deployed in the cluster):&lt;/p>
&lt;pre>&lt;code class="language-bash">kubectl top pod &amp;lt;oredge-node-pod-name&amp;gt; -n openresty-edge --containers
&lt;/code>&lt;/pre>
&lt;p>Example output:&lt;/p>
&lt;pre>&lt;code class="language-bash">$ kubectl top pod oredge-node-0 -n openresty-edge --containers
POD NAME CPU(cores) MEMORY(bytes)
oredge-node-0 oredge-node 7m 279Mi
oredge-node-0 oredge-node-log-collector 1m 31Mi
&lt;/code>&lt;/pre></description></item></channel></rss>