You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metron.apache.org by merrimanr <gi...@git.apache.org> on 2017/09/01 21:37:09 UTC

[GitHub] metron pull request #729: METRON-1150: REST parseMessage endpoint fails with...

GitHub user merrimanr opened a pull request:

    https://github.com/apache/metron/pull/729

    METRON-1150: REST parseMessage endpoint fails with Unable to load <grok file> from either classpath or HDFS

    ## Contributor Comments
    This PR fixes a regression in the REST app related to parsing sample messages with Grok.  When parsing a sample message, the REST app now stores the temporary grok pattern in HDFS instead of the local file system. 
    
    This has been tested on full dev and can be verified in a couple different ways.  The `/api/v1/sensor/parser/config/parseMessage` endpoint should now correctly parse a sample message with Grok.  For example, this request:
    ```
    {
      "sampleData": "1461576382.642    161 127.0.0.1 TCP_MISS/200 103701 GET http://www.cnn.com/ - DIRECT/199.27.79.73 text/html",
      "sensorParserConfig": {
        "parserClassName": "org.apache.metron.parsers.GrokParser",
        "filterClassName": null,
        "sensorTopic": "squid",
        "writerClassName": null,
        "errorWriterClassName": null,
        "invalidWriterClassName": null,
        "readMetadata": false,
        "mergeMetadata": false,
        "parserConfig": {
          "grokPath": "./squid",
          "patternLabel": "SQUID_DELIMITED",
          "timestampField": "timestamp"
        },
        "fieldTransformations": [
          {
            "input": [],
            "output": [
              "full_hostname",
              "domain_without_subdomains"
            ],
            "transformation": "STELLAR",
            "config": {
              "full_hostname": "URL_TO_HOST(url)",
              "domain_without_subdomains": "DOMAIN_REMOVE_SUBDOMAINS(full_hostname)"
            }
          }
        ]
      },
      "grokStatement": "SQUID_DELIMITED %{NUMBER:timestamp}[^0-9]*%{INT:elapsed} %{IP:ip_src_addr} %{WORD:action}/%{NUMBER:code} %{NUMBER:bytes} %{WORD:method} %{NOTSPACE:url}[^0-9]*(%{IP:ip_dst_addr})?\n\n"
    }
    ```
    Should now properly return a parsed message.  This can also be verified with the management UI by editing a parser of type Grok (squid for example) and testing sample data in the Grok editor pane.
    
    I also removed the "grok.path.default" property from REST because it was no longer being used.
    
    ## Pull Request Checklist
    
    Thank you for submitting a contribution to Apache Metron.  
    Please refer to our [Development Guidelines](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=61332235) for the complete guide to follow for contributions.  
    Please refer also to our [Build Verification Guidelines](https://cwiki.apache.org/confluence/display/METRON/Verifying+Builds?show-miniview) for complete smoke testing guides.  
    
    
    In order to streamline the review of the contribution we ask you follow these guidelines and ask you to double check the following:
    
    ### For all changes:
    - [x] Is there a JIRA ticket associated with this PR? If not one needs to be created at [Metron Jira](https://issues.apache.org/jira/browse/METRON/?selectedTab=com.atlassian.jira.jira-projects-plugin:summary-panel). 
    - [x] Does your PR title start with METRON-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
    - [x] Has your PR been rebased against the latest commit within the target branch (typically master)?
    
    
    ### For code changes:
    - [x] Have you included steps to reproduce the behavior or problem that is being changed or addressed?
    - [x] Have you included steps or a guide to how the change may be verified and tested manually?
    - [x] Have you ensured that the full suite of tests and checks have been executed in the root metron folder via:
      ```
      mvn -q clean integration-test install && build_utils/verify_licenses.sh 
      ```
    
    - [x] Have you written or updated unit tests and or integration tests to verify your changes?
    - [x] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? 
    - [x] Have you verified the basic functionality of the build by building and running locally with Vagrant full-dev environment or the equivalent?
    
    ### For documentation related changes:
    - [x] Have you ensured that format looks appropriate for the output in which it is rendered by building and verifying the site-book? If not then run the following commands and the verify changes via `site-book/target/site/index.html`:
    
      ```
      cd site-book
      mvn site
      ```
    
    #### Note:
    Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.
    It is also recommended that [travis-ci](https://travis-ci.org) is set up for your personal repository such that your branches are built there before submitting a pull request.
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/merrimanr/incubator-metron METRON-1150

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/metron/pull/729.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #729
    
----
commit 1ccf4f372ace43ac5507e261ccf1e654ec374257
Author: merrimanr <me...@gmail.com>
Date:   2017-09-01T21:29:47Z

    initial commit

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] metron pull request #729: METRON-1150: REST parseMessage endpoint fails with...

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on a diff in the pull request:

    https://github.com/apache/metron/pull/729#discussion_r137305664
  
    --- Diff: metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/configuration/metron-rest-env.xml ---
    @@ -90,17 +90,11 @@
         </property>
         <property>
             <name>metron_temp_grok_path</name>
    -        <description>Temporary local file path where grok patterns are written during testing</description>
    -        <value>./patterns/temp</value>
    +        <description>Temporary HDFS file path where grok patterns are written during testing</description>
    --- End diff --
    
    So, we are creating a tmp sensor, to put the patterns in?


---

[GitHub] metron issue #729: METRON-1150: REST parseMessage endpoint fails with Unable...

Posted by merrimanr <gi...@git.apache.org>.
Github user merrimanr commented on the issue:

    https://github.com/apache/metron/pull/729
  
    Please see https://issues.apache.org/jira/browse/METRON-1150 for a description of why this is needed.  Let me know if that isn't clear enough or you need more info.


---

[GitHub] metron issue #729: METRON-1150: REST parseMessage endpoint fails with Unable...

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on the issue:

    https://github.com/apache/metron/pull/729
  
    question - can the rest service delete these temp files? From full_dev?
    
    I am seeing an issue where rest cannot delete files it creates because the permissions don't match the parent directory.


---

[GitHub] metron issue #729: METRON-1150: REST parseMessage endpoint fails with Unable...

Posted by merrimanr <gi...@git.apache.org>.
Github user merrimanr commented on the issue:

    https://github.com/apache/metron/pull/729
  
    Is it possible to submit smaller PRs for fixes like these that you've already done?  I'm sure there are several like this in your feature branch that are valuable.  It would also make it easier to review that feature branch.  It's pretty daunting the way it is now.  It would also keep us from duplicating work.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] metron issue #729: METRON-1150: REST parseMessage endpoint fails with Unable...

Posted by justinleet <gi...@git.apache.org>.
Github user justinleet commented on the issue:

    https://github.com/apache/metron/pull/729
  
    Thanks for the submission, this looks good.
    
    Regarding this also living in 777, I think this is worth bringing in on its own, given the nature of the fix.


---

[GitHub] metron pull request #729: METRON-1150: REST parseMessage endpoint fails with...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/metron/pull/729


---

[GitHub] metron issue #729: METRON-1150: REST parseMessage endpoint fails with Unable...

Posted by merrimanr <gi...@git.apache.org>.
Github user merrimanr commented on the issue:

    https://github.com/apache/metron/pull/729
  
    Just pushed out a small change to support parameter substitution in the metron_temp_grok_path parameter.  I verified this in full dev as well.  I also verified the temporary files are being deleted.


---

[GitHub] metron issue #729: METRON-1150: REST parseMessage endpoint fails with Unable...

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on the issue:

    https://github.com/apache/metron/pull/729
  
    Now that there is a feature branch there should be.
    
    This is the commit that has grok working with hdfs, obviously based on 777.
    
    https://github.com/ottobackwards/metron/commit/f0923a6ca4ca0cbfa5fe541311ebe20126a28bad



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] metron pull request #729: METRON-1150: REST parseMessage endpoint fails with...

Posted by merrimanr <gi...@git.apache.org>.
Github user merrimanr commented on a diff in the pull request:

    https://github.com/apache/metron/pull/729#discussion_r137284827
  
    --- Diff: metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/configuration/metron-rest-env.xml ---
    @@ -91,16 +91,10 @@
         <property>
             <name>metron_temp_grok_path</name>
             <description>Temporary local file path where grok patterns are written during testing</description>
    --- End diff --
    
    Done


---

[GitHub] metron pull request #729: METRON-1150: REST parseMessage endpoint fails with...

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on a diff in the pull request:

    https://github.com/apache/metron/pull/729#discussion_r137359517
  
    --- Diff: metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/configuration/metron-rest-env.xml ---
    @@ -90,17 +90,11 @@
         </property>
         <property>
             <name>metron_temp_grok_path</name>
    -        <description>Temporary local file path where grok patterns are written during testing</description>
    -        <value>./patterns/temp</value>
    +        <description>Temporary HDFS file path where grok patterns are written during testing</description>
    --- End diff --
    
    no, what I mean is the structure of /patterns is /patterns/sensor.
    Pre 777 sensor is a single grok file with parser name.
    Post it is a directory with the parser name, containing one or more grok files
    
    So putting something in /patterns  is kind of creating a faux parser area.



---

[GitHub] metron issue #729: METRON-1150: REST parseMessage endpoint fails with Unable...

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on the issue:

    https://github.com/apache/metron/pull/729
  
    This is also fixed in the feature branch


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] metron issue #729: METRON-1150: REST parseMessage endpoint fails with Unable...

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on the issue:

    https://github.com/apache/metron/pull/729
  
    I'm going to throw a quick review at this.  I do not want to hold it back, but this is the place to ask questions.  I want to understand these things for comparison


---

[GitHub] metron pull request #729: METRON-1150: REST parseMessage endpoint fails with...

Posted by merrimanr <gi...@git.apache.org>.
Github user merrimanr commented on a diff in the pull request:

    https://github.com/apache/metron/pull/729#discussion_r137362276
  
    --- Diff: metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/configuration/metron-rest-env.xml ---
    @@ -90,17 +90,11 @@
         </property>
         <property>
             <name>metron_temp_grok_path</name>
    -        <description>Temporary local file path where grok patterns are written during testing</description>
    -        <value>./patterns/temp</value>
    +        <description>Temporary HDFS file path where grok patterns are written during testing</description>
    --- End diff --
    
    If you think it would make it easier for 777 we can deafult this temp path to something else.  It could be any path that makes sense. 
    
    When we switch to using a directory containing one or more grok files this will likely need to be updated anyways.  For now this is meant to fix the UI which is currently broken.


---

[GitHub] metron issue #729: METRON-1150: REST parseMessage endpoint fails with Unable...

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on the issue:

    https://github.com/apache/metron/pull/729
  
    The fix in 777 removes the need for a temp path/ temp file for this.  If this resolves in the mean time that is great, but I'm not sure that it will replace what is in the feature branch.  I'll have to see when I merge it in, which I hope is not a disaster.


---

[GitHub] metron issue #729: METRON-1150: REST parseMessage endpoint fails with Unable...

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on the issue:

    https://github.com/apache/metron/pull/729
  
    +1.  The issues I was seeing where a problem in my own code ( surprise right? ). This fix is correct and appropriate for the scope it seeks to address.  It is really good work.  


---

[GitHub] metron pull request #729: METRON-1150: REST parseMessage endpoint fails with...

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on a diff in the pull request:

    https://github.com/apache/metron/pull/729#discussion_r137305828
  
    --- Diff: metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/configuration/metron-rest-env.xml ---
    @@ -90,17 +90,11 @@
         </property>
         <property>
             <name>metron_temp_grok_path</name>
    -        <description>Temporary local file path where grok patterns are written during testing</description>
    -        <value>./patterns/temp</value>
    +        <description>Temporary HDFS file path where grok patterns are written during testing</description>
    +        <value>/apps/metron/patterns/tmp</value>
             <display-name>Metron temp grok path</display-name>
    --- End diff --
    
    This should not be hard coded, the user can change the metron hdfs root


---

[GitHub] metron pull request #729: METRON-1150: REST parseMessage endpoint fails with...

Posted by merrimanr <gi...@git.apache.org>.
Github user merrimanr commented on a diff in the pull request:

    https://github.com/apache/metron/pull/729#discussion_r137354784
  
    --- Diff: metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/configuration/metron-rest-env.xml ---
    @@ -90,17 +90,11 @@
         </property>
         <property>
             <name>metron_temp_grok_path</name>
    -        <description>Temporary local file path where grok patterns are written during testing</description>
    -        <value>./patterns/temp</value>
    +        <description>Temporary HDFS file path where grok patterns are written during testing</description>
    +        <value>/apps/metron/patterns/tmp</value>
             <display-name>Metron temp grok path</display-name>
    --- End diff --
    
    Done


---

[GitHub] metron issue #729: METRON-1150: REST parseMessage endpoint fails with Unable...

Posted by merrimanr <gi...@git.apache.org>.
Github user merrimanr commented on the issue:

    https://github.com/apache/metron/pull/729
  
    Is `/apps/metron/patterns/tmp` a reasonable place to keep temporary grok files?  Is there another location that would be better?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] metron pull request #729: METRON-1150: REST parseMessage endpoint fails with...

Posted by justinleet <gi...@git.apache.org>.
Github user justinleet commented on a diff in the pull request:

    https://github.com/apache/metron/pull/729#discussion_r137273563
  
    --- Diff: metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/configuration/metron-rest-env.xml ---
    @@ -91,16 +91,10 @@
         <property>
             <name>metron_temp_grok_path</name>
             <description>Temporary local file path where grok patterns are written during testing</description>
    --- End diff --
    
    Description should be "Temporary HDFS file path" instead of "Temporary local file path"


---

[GitHub] metron pull request #729: METRON-1150: REST parseMessage endpoint fails with...

Posted by merrimanr <gi...@git.apache.org>.
Github user merrimanr commented on a diff in the pull request:

    https://github.com/apache/metron/pull/729#discussion_r137353301
  
    --- Diff: metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/configuration/metron-rest-env.xml ---
    @@ -90,17 +90,11 @@
         </property>
         <property>
             <name>metron_temp_grok_path</name>
    -        <description>Temporary local file path where grok patterns are written during testing</description>
    -        <value>./patterns/temp</value>
    +        <description>Temporary HDFS file path where grok patterns are written during testing</description>
    --- End diff --
    
    No.  The parse and init methods are called directly on the configured MessageParser class so there is no need to persist a tmp parser config or anything like that.


---

[GitHub] metron issue #729: METRON-1150: REST parseMessage endpoint fails with Unable...

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on the issue:

    https://github.com/apache/metron/pull/729
  
    +1 by inspection, @merrimanr I would run this up in full dev one more time after your last change to make sure nothing wacky goes on with ambari and ambari format().



---

[GitHub] metron issue #729: METRON-1150: REST parseMessage endpoint fails with Unable...

Posted by justinleet <gi...@git.apache.org>.
Github user justinleet commented on the issue:

    https://github.com/apache/metron/pull/729
  
    I'm guessing it probably doesn't replace the changes in the feature branch, especially if it remove the need for temp path. I'm looking at this as the fix until that branch comes in, honestly.
    
    I'm +1 by inspection, assuming @ottobackwards is good with it also since there's impact it sounds like he's a bit worried about.


---