-
Notifications
You must be signed in to change notification settings - Fork 217
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
Integrated logstash converter into Data Prepper core #591
Integrated logstash converter into Data Prepper core #591
Conversation
Codecov Report
@@ Coverage Diff @@
## main #591 +/- ##
============================================
- Coverage 92.31% 91.61% -0.70%
+ Complexity 571 568 -3
============================================
Files 72 72
Lines 1731 1742 +11
Branches 144 144
============================================
- Hits 1598 1596 -2
- Misses 102 113 +11
- Partials 31 33 +2
Continue to review full report at Codecov.
|
@@ -33,7 +33,8 @@ public String convertLogstashConfigurationToPipeline(String logstashConfiguratio | |||
LogstashParser parser = new LogstashParser(tokens); | |||
final ParseTree tree = parser.config(); | |||
|
|||
org.opensearch.dataprepper.logstash.parser.LogstashVisitor visitor = new org.opensearch.dataprepper.logstash.parser.LogstashVisitor(); | |||
org.opensearch.dataprepper.logstash.parser.ModelConvertingLogstashVisitor visitor = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason you didn't import org.opensearch.dataprepper.logstash.parser.LogstashVisitor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prior to renaming LogstashVisitor
, it had a conflicting class name with an ANTLR-generated class. So it required the fully qualified name. Now that it is renamed, it can be imported.
String configurationFileLocation = args[0]; | ||
if (args[0].endsWith(".conf")) { | ||
LogstashConfigConverter logstashConfigConverter = new LogstashConfigConverter(); | ||
try { | ||
configurationFileLocation = logstashConfigConverter.convertLogstashConfigurationToPipeline( | ||
args[0], String.valueOf(Paths.get("data-prepper-core/build/libs/"))); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider pulling this out into a method that takes in the config file name to provide some context. Something like
private static String checkForLogstashConfAndConvert(String configurationFileLocation)
and use it like this:
configurationFileLocation = checkForLogstashConfigAndConvert(configurationFileLocation);
@@ -33,7 +33,8 @@ public String convertLogstashConfigurationToPipeline(String logstashConfiguratio | |||
LogstashParser parser = new LogstashParser(tokens); | |||
final ParseTree tree = parser.config(); | |||
|
|||
org.opensearch.dataprepper.logstash.parser.LogstashVisitor visitor = new org.opensearch.dataprepper.logstash.parser.LogstashVisitor(); | |||
org.opensearch.dataprepper.logstash.parser.ModelConvertingLogstashVisitor visitor = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prior to renaming LogstashVisitor
, it had a conflicting class name with an ANTLR-generated class. So it required the fully qualified name. Now that it is renamed, it can be imported.
configurationFileLocation = logstashConfigConverter.convertLogstashConfigurationToPipeline( | ||
args[0], String.valueOf(Paths.get("data-prepper-core/build/libs/"))); | ||
} catch (IOException e) { | ||
e.printStackTrace(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be using SLF4J logging for this. Somewhat like: LOG.error("custom error message", ex)
.
LogstashConfigConverter logstashConfigConverter = new LogstashConfigConverter(); | ||
try { | ||
configurationFileLocation = logstashConfigConverter.convertLogstashConfigurationToPipeline( | ||
args[0], String.valueOf(Paths.get("data-prepper-core/build/libs/"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the path at compile-time. But, when a user is running Data Prepper, this path will not exist. I think just using the current working directory is sufficient for now. It will need to be revisited along with implementing #305 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in reference to the string "data-prepper-core/build/libs/"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, just thinking where the .yaml file should be saved.
I think we can remove the 2nd parameter and save it in same directory as .conf file.
Signed-off-by: Asif Sohail Mohammed <[email protected]>
2b5c60f
to
e9bddab
Compare
Signed-off-by: Asif Sohail Mohammed <[email protected]>
e9bddab
to
60a88ec
Compare
Signed-off-by: Asif Sohail Mohammed [email protected]
Description
Issues Resolved
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.