Use CURL for OpenTelemetry Logs?? YES!

Поделиться
HTML-код
  • Опубликовано: 28 авг 2024
  • Yes! You really can use curl to send OpenTelemetry logs!
    This is the easy button. Send a curl to an OpenTelemetry collector and get a log line into your observability system.
    Transcript
    Open telemetry, metrics, logs, traces, processors, receivers. Where is the easy button?
    I just want to send a log line in and see something. Let's get straight to it. Now, everyone has curl,
    so what I really want is some way to use curl to send data into an open telemetry collector,
    process that data if I need to, and send it on out as a log entry or some other data type
    to my backend system. That's precisely what we're going to do now. We are going to use
    the webhook event receiver in the collector and send it on through to a backend. So let's get
    straight to it. As you'd expect, we need somewhere to send the data. I'm going to use open observe,
    so I'll start it here. This is just from their quick start guide, and you can see it's running
    on port 5080. So there we are. Find out how to ingest logs. I'm going to go to custom and then
    hotel collector and copy and paste this snippet into my collector configuration YAML file. I've
    made one change, though, which is to use it as an environment variable. So I'll need to set open
    observe key as an environment variable when I run the collector, but that's okay. The next thing I
    need is a receiver. That's a way to get data into the collector. And this is the magic. This is how
    why we can use curl. I'm going to use webhook event, and I'm going to set the endpoint. That's
    the endpoint that it makes available to local host on a port that I decide like 8088 and some other
    properties that you may care to set and a path of events. Now I want the ability to send any
    old data into the open telemetry collector and it gets exported as a log line. The problem is the
    open telemetry collected doesn't know when data was sent. So we need to enrich those log lines
    as they flow through the collector and add the timestamps. That's what you're seeing here. We're
    using the transform processor. We are adding a field called observed underscore time and setting
    the time to now. And we're doing the same with the time field. And then we're sending the data on out
    to open observe. Finally, we build our pipeline, which says we receive data at the webhook event
    receiver. We process it by adding the timestamp and we export it to open observe. So now that we've
    done that, let's run our collector and let's send a log line to the collector. Back in open
    observe, go to the homepage and we can now see one stream, click view more, click the explore icon.
    And there we are. There's my first log line in our back end. There's something else very special
    about this setup. We can send a curl message to the open telemetry collector and use the open
    telemetry's multicasting capability to send that curl to as many different endpoints as we like.
    So we can use this as kind of a message bus if you need to. This opens up so many possibilities
    basically anywhere that you have curl available and can run curl, you can now get log lines into
    your observability systems. So think about GitHub actions, think about CICD pipelines,
    think about shell scripts. This is a really, really key starting point for observability,
    especially for those who aren't steeped in observability and tracing history and aren't
    comfortable yet with those more advanced topics. As always, I hope this has been helpful to get
    you started on your observability journey. If it has, please like, subscribe, all that good stuff
    and I'll see you next time. Thanks, bye.

Комментарии •