OpenTelemetry
Non-sampled logs (e.g., access logs) are excellent sources of usage information. Combined with OpenTelemetry open standard for log forwarding, you can easily extract usage information from your logs and forward them to OpenMeter.
Prerequisites
You will need an OpenTelemetry-compatible log-forwarding solution. The easiest way to get started is to use the OpenTelemetry Collector.
Configuration
First, create a new YAML file for the collector configuration. You will have to
use the otel_log
Benthos input:
This is a custom input plugin that is not part of the official Benthos distribution. You can find the source code of the plugin here.
Next, you need to configure the mapping from your log schema to CloudEvents using bloblang:
this.record.attributes
contains the log attributes extracted by the
otel_log
input plugin.
Finally, you need to configure the OpenMeter output:
Read more about configuring Benthos in the Benthos collector guide.
Check out a fully working example here.
Installation
Check out the Benthos collector guide for installation instructions.