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

[GitHub] metron pull request #763: METRON-1190: Fix Meta Alert Type handling in calcu...

GitHub user justinleet opened a pull request:

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

    METRON-1190: Fix Meta Alert Type handling in calculation of scores

    ## Contributor Comments
    Migrating the create method to not pass anything as an object array and instead to use a list.  At that point, it should all be one type going in.  Still need to spin up in fulldev to make sure nothing odd happens.
    
    To test, make sure both create and patch work correctly.
    
    ## 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)? 
    - [ ] 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/justinleet/metron METRON-1190

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

    https://github.com/apache/metron/pull/763.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 #763
    
----
commit b39188fb0067eaf9cf6869360988cb0f14f95cc1
Author: justinjleet <ju...@gmail.com>
Date:   2017-09-15T15:39:28Z

    METRON-1190: Fix Meta Alert Type handling in calculation of scores

commit b97ec589ac7650fbf671256bad3b355642a58a09
Author: justinjleet <ju...@gmail.com>
Date:   2017-09-15T15:42:33Z

    Correcting a comment I happened to notice

----


---

[GitHub] metron pull request #763: METRON-1190: Fix Meta Alert Type handling in calcu...

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

    https://github.com/apache/metron/pull/763#discussion_r139225592
  
    --- Diff: metron-platform/metron-elasticsearch/src/main/java/org/apache/metron/elasticsearch/dao/ElasticsearchMetaAlertDao.java ---
    @@ -275,13 +275,13 @@ protected Document buildCreateDocument(MultiGetResponse multiGetResponse, List<S
             alertList.add(response.getSource());
           }
         }
    -    metaSource.put(ALERT_FIELD, alertList.toArray());
    +    metaSource.put(ALERT_FIELD, alertList);
    --- End diff --
    
    Updated the PR description to make the reasoning more obvious to anyone glancing there first.


---

[GitHub] metron issue #763: METRON-1190: Fix Meta Alert Type handling in calculation ...

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

    https://github.com/apache/metron/pull/763
  
    @nickwallen Some of that is provided in metron-indexing/README.md, but I'm definitely not opposed to fleshing that stuff out more.


---

[GitHub] metron issue #763: METRON-1190: Fix Meta Alert Type handling in calculation ...

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

    https://github.com/apache/metron/pull/763
  
    Outside of this PR, we might need to better doc the expected behavior for meta-alerts (or maybe I just need to find the existing docs for that.)


---

[GitHub] metron issue #763: METRON-1190: Fix Meta Alert Type handling in calculation ...

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

    https://github.com/apache/metron/pull/763
  
    +1 LGTM based on what you have explained.  


---

[GitHub] metron issue #763: METRON-1190: Fix Meta Alert Type handling in calculation ...

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

    https://github.com/apache/metron/pull/763
  
    Correction to what I said earlier: the update side isn't directly actually controlled by the `ElasticsearchMetaAlertDao` itself, it's controlled by the `IndexDao`'s building of the document that is done in `patch` and passed to the `update` method.  The fix to `create` ensures that what the `ElasticsearchMetaAlertDao` (which extends `IndexDao`) is consistent with the typing that the parent class does.


---

[GitHub] metron pull request #763: METRON-1190: Fix Meta Alert Type handling in calcu...

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

    https://github.com/apache/metron/pull/763#discussion_r139225095
  
    --- Diff: metron-platform/metron-elasticsearch/src/main/java/org/apache/metron/elasticsearch/dao/ElasticsearchMetaAlertDao.java ---
    @@ -275,13 +275,13 @@ protected Document buildCreateDocument(MultiGetResponse multiGetResponse, List<S
             alertList.add(response.getSource());
           }
         }
    -    metaSource.put(ALERT_FIELD, alertList.toArray());
    +    metaSource.put(ALERT_FIELD, alertList);
    --- End diff --
    
    If you look at the first two commits, they were originally to do the JIRA as noted (handle both).  The solution of the last commit is to just not use arrays at all. In actuality though, both constructions of the alert field are controlled by the DAO itself, so there's no reason to use arrays at all.
    
    Basically, this PR solves the underlying problem (The two paths used different types), rather than the symptom (That two different types went into the same method).


---

[GitHub] metron issue #763: METRON-1190: Fix Meta Alert Type handling in calculation ...

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

    https://github.com/apache/metron/pull/763
  
    Thanks for the pointer.  Duh, I should have looked there.  I'll read up on that


---

[GitHub] metron issue #763: METRON-1190: Fix Meta Alert Type handling in calculation ...

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

    https://github.com/apache/metron/pull/763
  
    It was hard for me to grok how `ElasticsearchDAO` and `ElasticsearchMetaAlertDAO` differ and how the `ElasticsearchMetaAlertDAO` uses another `IndexDAO` under-the-hood.  I think more cow bell (I mean javadocs) would help here.  But that is all outside the scope of the work you've done here.


---

[GitHub] metron pull request #763: METRON-1190: Fix Meta Alert Type handling in calcu...

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

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


---

[GitHub] metron issue #763: METRON-1190: Fix Meta Alert Type handling in calculation ...

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

    https://github.com/apache/metron/pull/763
  
    The relevant method that things go into is `calculateMetaScores`.  Didn't mention that in the initial setup.  This is used by `handleMetaUpdate` and `update` (in the case of an update to a metalert itself), but they were both passing in different field types for the alert field.


---

[GitHub] metron pull request #763: METRON-1190: Fix Meta Alert Type handling in calcu...

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

    https://github.com/apache/metron/pull/763#discussion_r139223469
  
    --- Diff: metron-platform/metron-elasticsearch/src/main/java/org/apache/metron/elasticsearch/dao/ElasticsearchMetaAlertDao.java ---
    @@ -275,13 +275,13 @@ protected Document buildCreateDocument(MultiGetResponse multiGetResponse, List<S
             alertList.add(response.getSource());
           }
         }
    -    metaSource.put(ALERT_FIELD, alertList.toArray());
    +    metaSource.put(ALERT_FIELD, alertList);
    --- End diff --
    
    @justinleet  "The alerts field can actually come as two different types List<Object> vs Object[] during calculation of meta score fields."
    
    
    Your changes here seem simple enough.  Before we used arrays, now using Lists.  But I am not following how this solves the problem you describe in JIRA.  
    
    Where is the code that would handle/transform/standardize items that come in as either Array or List? 


---