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

Integrated logstash converter into Data Prepper core #591

Merged
merged 2 commits into from
Nov 15, 2021

Conversation

asifsmohammed
Copy link
Collaborator

@asifsmohammed asifsmohammed commented Nov 13, 2021

Signed-off-by: Asif Sohail Mohammed [email protected]

Description

  • Integrated Logstash converter into Data Prepper core
  • Updated LogstashVisitor class name

Issues Resolved

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

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.

@asifsmohammed asifsmohammed requested a review from a team as a code owner November 13, 2021 08:09
@codecov-commenter
Copy link

codecov-commenter commented Nov 13, 2021

Codecov Report

Merging #591 (60a88ec) into main (368795f) will decrease coverage by 0.69%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             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     
Impacted Files Coverage Δ
...ava/com/amazon/dataprepper/DataPrepperExecute.java 0.00% <0.00%> (ø)
...com/amazon/dataprepper/pipeline/ProcessWorker.java 85.71% <0.00%> (-5.72%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 368795f...60a88ec. Read the comment docs.

@@ -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 =
Copy link
Member

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

Copy link
Member

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.

Comment on lines 37 to 46
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();
}
}
Copy link
Member

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 =
Copy link
Member

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();
Copy link
Member

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/")));
Copy link
Member

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 .

Copy link
Member

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/".

Copy link
Collaborator Author

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.

dlvenable
dlvenable previously approved these changes Nov 13, 2021
@dlvenable dlvenable merged commit f677480 into opensearch-project:main Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants