Collecting Application Logs from Log File
Overview
This documentation provides detailed instructions on configuring the OpenTelemetry Collector to read logs from a file and push them to SigNoz, enabling you to analyze your application logs effectively.
Sample Log File
As an example, we can create a sample log file called app.log
with the following dummy data:
This is log line 1
This is log line 2
This is log line 3
This file represents a log file of your application. You can choose any file that contains your application's log entries.
Setup
1. Install OpenTelemetry Collector
The OpenTelemetry Collector provides a vendor-neutral way to collect, process, and export your telemetry data such as logs, metrics, and traces.
Follow this guide to install the OpenTelemetry Collector as an agent on your Virtual Machine.
2. Configure Filelog Receiver
Modify the config.yaml
file created during the installation of the OpenTelemetry Collector to include the filelog
receiver. Specify the path to your app.log
file and set the start_at
parameter.
receivers:
filelog/app:
include: [ /tmp/app.log ] # Include the full path to your log file
start_at: end
The start_at: end
configuration ensures that only newly added logs are transmitted. To include historical logs, set start_at
to beginning
.
3. Update Pipeline Configuration
Update the pipeline settings in config.yaml
to include the new filelog receiver:
service:
pipelines:
logs:
receivers: [otlp, filelog/app]
processors: [batch]
exporters: [otlp]
Restart the OpenTelemetry Collector for the changes to take effect. Follow this guide for restart instructions.
4. Verify Export
The logs will be visible in the Logs Tab of SigNoz. As more entires are added to app.log
it will reflect Logs tab.