Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New exec sink #935

Open
mamcx opened this issue Sep 26, 2019 · 6 comments
Open

New exec sink #935

mamcx opened this issue Sep 26, 2019 · 6 comments
Labels
needs: requirements Needs a a list of requirements before work can be begin sink: new A request for a new sink type: feature A value-adding code addition that introduce new functionality.

Comments

@mamcx
Copy link

mamcx commented Sep 26, 2019

I like to use vector to process logs to http://timescale.com. But because it not have that as sink, I was looking into implementing a http collector for that.

However, considering that vector can be used to aggregate multiple vector agents, how about a "universal" sink? So I could do:

[sinks.out_vector]
	type = "cmd"
	inputs = ["in"]
	cmd = echo {msg} // or psql, or whatever...

This way, it could cover much more cases where the sink is not available and build a small cli utility is the more easy way to get running...

@binarylogic binarylogic added needs: approval Needs review & approval before work can begin. type: new feature labels Oct 5, 2019
@binarylogic
Copy link
Contributor

@lukesteensen do you mind reviewing this and determining if this is valid or something we should do? I don't have enough context to say. Thanks.

@lukesteensen
Copy link
Member

Thanks for this idea @mamcx! It's definitely an interesting one.

My main hesitance is around the management of the long-running subprocess. There are a lot of cases to handle there and we'd probably be better off leaving that to a dedicated process manager like systemd or supervisord.

As an alternative, you could use the file source and point it at a named pipe instead of a normal file. You could then run your small cli utility under a normal process manager and simply connect that named pipe to its standard input.

We haven't specifically tested the file source against named pipes, but that's something we could definitely tackle. Does that seem like it would cover the use case you have in mind? I understand it's probably not quite as convenient, but hopefully it would be a bit more robust than building a process manager into vector itself.

Let me know what you think. Thanks again!

@mamcx
Copy link
Author

mamcx commented Oct 8, 2019

I was not thinking about long running commands, just one-shoot (alike cgi). Probably more robust? I think that a long running command is more probably a web server or similar or an interactive one.

@lukesteensen
Copy link
Member

Gotcha, yes I think that would be simpler and something we could consider. It's unlikely to be a high priority for our own development efforts, but I'd be happy to review a PR that added such a feature.

At a high level, the design would roughly be to use our prebuilt batching components combined with a Service implementation that spawned tokio-managed Commands with the incoming request wired up as the spawned process's stdin. We'd want to make sure to time out the command, retry on non-successful exit codes, etc.

@lukesteensen lukesteensen removed the needs: approval Needs review & approval before work can begin. label Oct 17, 2019
@yurtaev
Copy link

yurtaev commented Mar 13, 2020

Temporary workaround for me:

[transforms.sentry]
  type = "lua"
  inputs = ["some-source"]
  source = """
  command_template = 'SENTRY_DSN=%s sentry-cli send-event --no-environ -m "%s"'

  SENTRY_DSN = "https://*****@sentry.io/123"
  message = event["message']

  command = string.format(command_template, SENTRY_DSN, message)

  os.execute(command)
  """

@binarylogic binarylogic added type: feature A value-adding code addition that introduce new functionality. and removed type: new feature labels Jun 16, 2020
@binarylogic binarylogic added meta: idea Anything in the idea phase. Needs further discussion and consensus before work can begin. needs: approval Needs review & approval before work can begin. labels Aug 7, 2020
@jszwedko
Copy link
Member

Just noting this would be similar to fluentd's exec output: https://docs.fluentd.org/output/exec

@jszwedko jszwedko changed the title Support for pipe to ANY command? New exec sink Aug 1, 2022
@jszwedko jszwedko added sink: new A request for a new sink needs: requirements Needs a a list of requirements before work can be begin and removed meta: idea Anything in the idea phase. Needs further discussion and consensus before work can begin. needs: approval Needs review & approval before work can begin. labels Aug 1, 2022
@arshiyasolei arshiyasolei self-assigned this Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: requirements Needs a a list of requirements before work can be begin sink: new A request for a new sink type: feature A value-adding code addition that introduce new functionality.
Projects
None yet
Development

No branches or pull requests

6 participants