elastic / elastic-agent

Elastic Agent - single, unified way to add monitoring for logs, metrics, and other types of data to a host.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[OTel mode] Provide `elastic-otel` executable as a shortcut to `elastic-agent otel`

ycombinator opened this issue · comments

Describe the enhancement:

Currently, to run Elastic Agent in OTel mode, users must run ./elastic-agent otel ... (or the Windows equivalent). It would be convenient if users could simply run something like ./elastic-otel ... instead.

Describe a specific use case for the enhancement or feature:

For users who are familiar with OpenTelemetry but not with Elastic Agent, the less we expose Elastic Agent concepts to such users the better.

What is the definition of done?

  • Users should be able to run ./elastic-otel... in addition to ./elastic-agent otel ....
  • These two commands should be functionally identical.

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@belimawr Starting to look on how to implement that, I think one way to do it will to create a simlink elastic-otel in the magefile package command does it make sense?

@belimawr Starting to look on how to implement that, I think one way to do it will to create a simlink elastic-otel in the magefile package command does it make sense?

Because it needs to run the elastic-agent command with arguments, I believe a simlink will not works and we also need to support this on Windows.

Because we use cobra for the CLI commands and arguments, it's easy to just create a new binary with the otel command as the entrypoint. Then we can add a simlink to the root folder in the same way we do with elastic-agent.

We need to measure how much we increase the on disk footprint of the agent with this addition.

One quirk of the current Windows packaging is that symlinks in the zip are replaced with copies of the binary and then converted back to symlinks at install time (zip doesn't/didn't have support for symlinks when this was done).

We need to measure how much we increase the on disk footprint of the agent with this addition.

I completely forgot about it 🤦‍♂️. I was thinking only about the implementation side of things.

Another option would be to use a shell script + windows equivalent that that just calls ./elastic-agent otel <ARGS>.

I just don't know if there is any Windows specific quirk about doing it.

@cmacknz @belimawr just get a discussion with @ycombinator and one possible solution here maybe more portable will be to create a new golang binary that call ./elastic-agent otel <ARGS> what do you think of that solution? it seems more portable than a shell script

A separate binary is more portable than a shell script, but shell scripts don't need to be compiled for every architecture, don't need to be signed on Windows+Mac, should take up less space on disk, and more importantly won't show up as another source of CVEs in security scans.

I think the best path is actually just a shell script that invokes ./elastic-agent otel <ARGS> for us. You'll have to write it twice, once for MacOS+Linux and once for Windows, but it should be simple in both cases. This isn't the first platform dependent thing we've had to do so this isn't a con.

Two fun notes on this:

  1. Every currently supported version of Windows 10 and Windows 11 and Windows server (except maybe some really old ltsb versions) include tar and can natively open .tar.gz files
  2. Zip doesn't compress across files so every symlink of agent adds 21mb to the zip and 71mb to the pre-install on disk footprint.