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

Support template syntax in hostname and tags field for LogDNA sink #3777

Closed
romatthe opened this issue Sep 9, 2020 · 2 comments · Fixed by #4884
Closed

Support template syntax in hostname and tags field for LogDNA sink #3777

romatthe opened this issue Sep 9, 2020 · 2 comments · Fixed by #4884
Assignees
Labels
have: should We should have this feature, but is not required. It is medium priority. meta: good first issue Anything that is good for new contributors. type: enhancement A value-adding code change that enhances its existing functionality.

Comments

@romatthe
Copy link
Contributor

romatthe commented Sep 9, 2020

I'm currently trying to set up vector to ship logs from the docker source to the LogDNA sink. The LogDNA sink has a field hostname that it will use to determine the "source" of the log event. I tried using the template syntax to set the hostname based on the container_name field set by the docker source, but it seems this field does not accept the template syntax.

Here's a simple example of what I'm trying to set up

[sources.in]
  type = "docker"

[transforms.extract_app]
  # General
  type = "regex_parser"
  inputs = ["in"]
  drop_field = true
  field = "image"
  patterns = ['(.*/)*(?P<app>[a-zA-Z-]*):']

  # Types
  types.app = "string"

[sinks.console]
  # Encoding
  encoding.codec = "json"

  # General
  inputs = ["extract_app"]
  type = "console"

[sinks.logdna]
  type = "logdna"
  inputs = ["extract_app"]
  api_key = "${LOGDNA_API_KEY}"
  hostname = "{{ container_name }}"      # <---- This specifically...
  tags = ["{{ container_id }}"]                   # <---- ... and this

Without the ability to set this dynamically, it seems to me that there is no reliable way to indicate to LogDNA what instance this log is coming from.

The same goes for tags. I wanted to apply some tags that that take in some of the fields from the docker log output.

Would it be possible to support the use of templates in these fields?

@lukesteensen lukesteensen added have: should We should have this feature, but is not required. It is medium priority. meta: good first issue Anything that is good for new contributors. provider: logdna type: enhancement A value-adding code change that enhances its existing functionality. labels Sep 11, 2020
@juchiast
Copy link
Contributor

juchiast commented Sep 17, 2020

As I understand, template's values come from events, LogDNA batches many events together so each event could render a different hostname value. Should we group events that have the same hostname and tags?

@binarylogic
Copy link
Contributor

Yes, this will require partitioning. The aws_cloudwatch_logs sink demonstrates this. Because these values are at the request level we'll need to partition requests across their unique values.

Let us know if you have any other questions. The sink partition code can be somewhat complex and we want to simplify that over time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
have: should We should have this feature, but is not required. It is medium priority. meta: good first issue Anything that is good for new contributors. type: enhancement A value-adding code change that enhances its existing functionality.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants