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

Set measurement name based on matched pattern in logparser #3484

Closed
botzill opened this issue Nov 17, 2017 · 6 comments · Fixed by #4433
Closed

Set measurement name based on matched pattern in logparser #3484

botzill opened this issue Nov 17, 2017 · 6 comments · Fixed by #4433
Assignees
Labels
area/tail feature request Requests for new plugin and for new features to existing plugins
Milestone

Comments

@botzill
Copy link

botzill commented Nov 17, 2017

Hi.

Seems to not be possible to define smth like this? Can we somehow define it without redefining the hole [[inputs.logparser]] again?

[[inputs.logparser]]
  files = ["/var/log/supervisor/app.log"]
  from_beginning = false
  watch_method = "poll"
  [inputs.logparser.grok]
    measurement = "measurement_1"
    custom_pattern_files = ["..."]
    patterns = ["..."]
  [inputs.logparser.grok]
    measurement = "measurement_2"
    custom_pattern_files = ["..."]
    patterns = ["..."]
  [inputs.logparser.tags]
    app = "tag1"

@danielnelson
Copy link
Contributor

The best you can do is to have a multiple patterns:

[[inputs.logparser]]
  files = ["/var/log/supervisor/app.log"]
  from_beginning = false
  watch_method = "poll"
  [inputs.logparser.grok]
    patterns = [
      "pattern1",
      "pattern2"
    ]
    custom_pattern_files = [
	  "CP1 ...",
	  "CP2 ..."
    ]

Once you have that working you may also want to combine your patterns for increased performance:

[[inputs.logparser]]
  files = ["/var/log/supervisor/app.log"]
  from_beginning = false
  watch_method = "poll"
  [inputs.logparser.grok]
    patterns = [
      "%{PATTERN1}|%{PATTERN2}"
    ]
    custom_pattern_files = [
      "PATTERN1 ...",
      "PATTERN2 ...",
	  "CP1 ...",
	  "CP2 ..."
    ]

Unfortunately you won't be able to name the measurements differently.

@danielnelson danielnelson added the discussion Topics for discussion label Nov 17, 2017
@botzill
Copy link
Author

botzill commented Nov 17, 2017

I see. Don't you think such option with be useful ?

@danielnelson danielnelson added area/tail feature request Requests for new plugin and for new features to existing plugins and removed discussion Topics for discussion labels Nov 17, 2017
@danielnelson danielnelson reopened this Nov 17, 2017
@danielnelson danielnelson changed the title Multiple [inputs.logparser.grok] for [[inputs.logparser]] Set measurement name based on matched pattern in logparser Nov 17, 2017
@danielnelson
Copy link
Contributor

I think it will be useful, though I will have to think about how this can be expressed in the configuration. Perhaps we could have parameter like patterns that is a table so that the individual patterns can be named.

@maxunt maxunt self-assigned this Jul 12, 2018
@maxunt
Copy link
Contributor

maxunt commented Jul 12, 2018

We could add a new modifier for grok patterns, such as "name", that when matched would change the measurement name to the parsed grok field

@danielnelson
Copy link
Contributor

I think this would be a good thing to do, but it wouldn't allow you to set the measurement to a value not in the parsed data. @botzill would this meet your requirements?

@danielnelson
Copy link
Contributor

@botzill with the change in #4433 you can set the measurement name from a matched pattern. This isn't exactly what is described above, but I think it will be a good solution for setting a dynamic measurement name, and it fits in well with the existing grok pattern language. Please let us know if it doesn't work for your use-case and we can consider additional changes.

@danielnelson danielnelson added this to the 1.8.0 milestone Aug 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/tail feature request Requests for new plugin and for new features to existing plugins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants