Ubuntu
This document describes a sample setup for sending logs to Last9 via OpenTelemetry collector from Ubuntu instance
Installing OpenTelenetry collector on Ubuntu instance
Use Last9’s OpenTelemetry endpoint to ingest logs from Ubuntu instances using Otel Collector.
Prerequisites:
There are multiple ways to install the Otel Collector. One possible way is to use the package. Every Collector release includes APK, DEB, and RPM packaging for Linux amd64/arm64/i386 systems.
sudo apt-get updatesudo apt-get -y install wget systemctlwget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.110.0/otelcol-contrib_0.110.0_linux_amd64.debsudo dpkg -i otelcol-contrib_0.110.0_linux_amd64.deb
More installation options can be found here.
Sample Otel collector Configuration:
The default path for otel config is /etc/otelcol-contrib/config.yaml
.
You can edit it and update it using the configuration below. The configuration for operators is essential to extract the timestamp and severity.
For JSON logs, you can use json_parser
and use its keys for log attributes. For non-structured logs, use the regex_parser
.
The configuration provides a sample example of a JSON parser.
receivers: otlp: protocols: grpc: endpoint: 0.0.0.0:4317 http: endpoint: 0.0.0.0:4318
# Detailed configuration options can be found at https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/filelogreceiver filelog: # File path to read logs from. You can add multiple files here. include: [/var/log/app/*.log] include_file_path: true operators: - type: json_parser - type: severity_parser parse_from: attributes.level mapping: critical: 50 error: 40 warning: 30 info: 20 debug: 10
processors: transform/add_timestamp: log_statements: - context: log statements: - set(observed_time, Now()) - set(time, Now()) attributes: actions: - key: test.name value: "jammytest" action: insert - key: deployment.environment value: "production" action: insert - key: otel.processed value: true action: insert batch: timeout: 1s send_batch_size: 1024
exporters: debug: verbosity: detailed otlp/last9: endpoint: <last9_otlp_endpoint> headers: "Authorization": <last9_auth_header>
service: pipelines: logs: receivers: [filelog] processors: [attributes, batch, transform/add_timestamp] exporters: [debug, otlp/last9]
Run the otel collector using systemctl
command
sudo systemctl start otelcol-contribsudo systemctl status otelcol-contribsudo systemctl restart otelcol-contrib
Checking logs of otel collector
sudo journalctl -u otelcol-contrib -f
This will enable logs from the Ubuntu machine to be sent to Last9. To see the data in action, visit the Logs Dashboard.
Verification
Login to Last9 and visit the Logs panel.
Troubleshooting
Please get in touch with us on Discord or Email if you have any questions.