DEV Community

Adam Gardner
Adam Gardner

Posted on

Trasform your logs to metrics (and do maths with metrics) using the OpenTelemetry Collector

Logs are everywhere... But they're expensive to store, retrieve and process. And sometimes you only need metrics.

Did you know the OpenTelemetry is perfectly suited to be the place that you transform your logs to metrics? Log in, metrics out. Plus, did you know you can do maths in the collector?

In this video I show you how to do it using the transform processor to extract the values from the log then the signal to metrics connector.

First I use something structured and easy: JSON.

{ "foo": 1234, "bar": "5432", "baz": "Here is the number: 57 status = complete" }
Enter fullscreen mode Exit fullscreen mode

Next I extract and generate metrics from an unstructured textual log line:

Purchase complete. Product price=6. Quantity=3. Product ID=987. user_id=123
Enter fullscreen mode Exit fullscreen mode

Finally I take the product price and quantity and multiply them (in realtime) to produce a third metric (order total).

Top comments (0)