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

feat: add path tag to file input #15133

Closed
RodrigoDornelles opened this issue Apr 9, 2024 · 2 comments · Fixed by #15330
Closed

feat: add path tag to file input #15133

RodrigoDornelles opened this issue Apr 9, 2024 · 2 comments · Fixed by #15330
Labels
feature request Requests for new plugin and for new features to existing plugins help wanted Request for community participation, code, contribution size/s 1 day effort, great beginniner issue

Comments

@RodrigoDornelles
Copy link

RodrigoDornelles commented Apr 9, 2024

Use Case

my use case would be as follows, I am using the hostname of the container in the folder path, I would like to retrieve it as host in my indexing. I think it would be interesting to have a path_tag configuration to extract this! or file_tag_fullname to set to true or false to get all filepath name with file.

Expected behavior

[[inputs.file]]
  files = ["/logs/*/*.log"]
  file_tag = "system"
  path_tag = "host"
  influx_timestamp_precision = "1s"

[[processors.regex]]
 [[processors.regex.tags]]
    key = "system"
    pattern = "^([a-z0-9]+)(-.+)"
    replacement = "${1}"
 [[processors.regex.tags]]
    key = "host"
    pattern = "^/logs/(\\w+)/$"
    replacement = "${1}"

get tags system and host

Actual behavior

only can get file.

Additional info

No response

@RodrigoDornelles RodrigoDornelles added the feature request Requests for new plugin and for new features to existing plugins label Apr 9, 2024
@powersj
Copy link
Contributor

powersj commented Apr 10, 2024

Happy to see a PR for this that would add a path_tag config option that adds the path, versus the file name, which is what file_tag does today. This would of course default to false and should probably have a warning as well about possible carnality in the config option comments.

@powersj powersj added help wanted Request for community participation, code, contribution size/s 1 day effort, great beginniner issue labels Apr 10, 2024
@Hipska
Copy link
Contributor

Hipska commented Apr 16, 2024

Hmm, I think it makes more sense to have an extra option to enable the full file name in the existing tag.

Current:

metric,file=telegraf.log msg="foobar"

New:

metric,file=/var/log/telegraf.log msg="foobar"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Requests for new plugin and for new features to existing plugins help wanted Request for community participation, code, contribution size/s 1 day effort, great beginniner issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants