You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@metron.apache.org by GitBox <gi...@apache.org> on 2019/09/10 21:31:25 UTC

[GitHub] [metron] nickwallen opened a new pull request #1506: METRON-2188 Upgrade to HBase 2.0.2

nickwallen opened a new pull request #1506: METRON-2188 Upgrade to HBase 2.0.2
URL: https://github.com/apache/metron/pull/1506
 
 
   This upgrades the feature branch `feature/METRON-2088-support-hdp-3.1` to HBase 2.0.2.  The scope of the changes include:
   
   * Replace `HBaseTestingUtility` API references that are no longer supported.
   * Replace references of `Put.add` with `Put.addColumn`.
   * Replaced references of `Cell.getQualifier` and `Cell.getValue`.
   * Update the `MockHTable` to function with HBase 2.0.2.
   * Update the Enrichment Coprocessor to reflect changes made in the coprocessor APIs.
   
   
   ## Acceptance Testing
   
   This PR should be tested using the centos7 development environment.  
   
   1. Start up the centos7 dev environment.
       ```
       cd metron-deployment/development/centos7
       vagrant destroy -f
       vagrant up
       ```
   
   ### Basics
   
   Ensure that we can continue to parse, enrich, and index telemetry.  Verify data is flowing through the system, from parsing to indexing
   
   1. Open Ambari and navigate to the Metron service http://node1:8080/#/main/services/METRON/summary
   
   1. Open the Alerts UI.  Verify alerts show up in the main UI - click the search icon (you may need to wait a moment for them to appear)
   
   1. Go to the Alerts UI and ensure that an ever increasing number of telemetry from Bro, Snort, and YAF are visible by watching the total alert count increase over time.
   
   1. Ensure that geoip enrichment is occurring.  The telemetry should contain fields like `enrichments:geo:ip_src_addr:location_point`.
   
   1. Head back to Ambari and select the Kibana service http://node1:8080/#/main/services/KIBANA/summary
   
   1. Open the Kibana dashboard via the "Metron UI" option in the quick links
   
   1. Verify the dashboard is populating
   
   ###  Streaming Enrichments
   
     1. Create a Streaming Enrichment [by following these instructions](https://cwiki.apache.org/confluence/display/METRON/2016/06/16/Metron+Tutorial+-+Fundamentals+Part+6%3A+Streaming+Enrichment).
   
     1. Launch the Stellar REPL.
         ```
         source /etc/default/metron
         cd $METRON_HOME
         $METRON_HOME/bin/stellar -z $ZOOKEEPER
         ```
   
     1. Define the streaming enrichment and save it as a new source of telemetry.
   
         ```
         [Stellar]>>> conf := SHELL_EDIT(conf)
         {
           "parserClassName": "org.apache.metron.parsers.csv.CSVParser",
           "writerClassName": "org.apache.metron.writer.hbase.SimpleHbaseEnrichmentWriter",
           "sensorTopic": "user",
           "parserConfig": {
             "shew.table": "enrichment",
             "shew.cf": "t",
             "shew.keyColumns": "ip",
             "shew.enrichmentType": "user",
             "columns": {
               "user": 0,
               "ip": 1
             }
           }
         }
         [Stellar]>>>
         [Stellar]>>> CONFIG_PUT("PARSER", conf, "user")
         ```
   
     1. Go to the Management UI and start the new parser called 'user'.
   
     1. Create some test telemetry.
         ```
         [Stellar]>>> msgs := ["user1,192.168.1.1", "user2,192.168.1.2", "user3,192.168.1.3"]
         [user1,192.168.1.1, user2,192.168.1.2, user3,192.168.1.3]
         [Stellar]>>> KAFKA_PUT("user", msgs)
         3
         [Stellar]>>> KAFKA_PUT("user", msgs)
         3
         [Stellar]>>> KAFKA_PUT("user", msgs)
         3
         ```
   
     1. Ensure that the enrichments are persisted in HBase.
         ```
         [Stellar]>>> ENRICHMENT_GET('user', '192.168.1.1', 'enrichment', 't')
         {original_string=user1,192.168.1.1, guid=a6caf3c1-2506-4eb7-b33e-7c05b77cd72c, user=user1, timestamp=1551813589399, source.type=user}
   
         [Stellar]>>> ENRICHMENT_GET('user', '192.168.1.2', 'enrichment', 't')
         {original_string=user2,192.168.1.2, guid=49e4b8fa-c797-44f0-b041-cfb47983d54a, user=user2, timestamp=1551813589399, source.type=user}
   
         [Stellar]>>> ENRICHMENT_GET('user', '192.168.1.3', 'enrichment', 't')
         {original_string=user3,192.168.1.3, guid=324149fd-6c4c-42a3-b579-e218c032ea7f, user=user3, timestamp=1551813589402, source.type=user}
         ```
   
   ### Enrichment Coprocessor
   
     1. Confirm that the 'user' enrichment added in the previous section was 'found' by the coprocessor.
           * Go to Swagger. 
           * Click the `sensor-enrichment-config-controller` option.
           * Click the `GET /api/v1/sensor/enrichment/config/list/available/enrichments` option.
   
     1. Click the "Try it out!" button. You should see a array returned with the value of each enrichment type that you have loaded.
       ```
       [
         "user"
       ]
       ```
   
   ### Enrichment Stellar Functions in Storm
   
     1. Follow [instructions similar to these](https://cwiki.apache.org/confluence/display/METRON/2016/04/28/Metron+Tutorial+-+Fundamentals+Part+2%3A+Creating+a+New+Enrichment) to load
     the user data.
   
     1. Create a simple file called `user.csv`.
       ```
       jdoe,192.168.138.2
       ```
       
     1. Create a file called `user-extractor.json`.
         ```
         {
           "config": {
             "columns": {
               "user": 0,
               "ip": 1
             },
             "indicator_column": "ip",
             "separator": ",",
             "type": "user"
           },
           "extractor": "CSV"
         }
         ```
   
     1. Import the data.
         ```
         source /etc/default/metron
         $METRON_HOME/bin/flatfile_loader.sh -i ./user.csv -t enrichment -c t -e ./user-extractor.json
         ```
   
     1. Validate that the enrichment loaded successfully.
         ```
         [root@node1 0.7.2]# source /etc/default/metron
         [root@node1 0.7.2]# $METRON_HOME/bin/stellar -z $ZOOKEEPER
         
         [Stellar]>>> ip_dst_addr := "192.168.138.2"
         192.168.138.2
         
         [Stellar]>>> ENRICHMENT_GET('user', ip_dst_addr, 'enrichment', 't')
         {ip=192.168.138.2, user=jdoe}
         ```
   
     1. Use the User data to enrich the telemetry.  Run the following commands in the REPL.
         ```
         [Stellar]>>> bro := SHELL_EDIT()
         {
          "enrichment" : {
            "fieldMap": {
              "stellar" : {
                "config" : {
                  "users" : "ENRICHMENT_GET('user', ip_dst_addr, 'enrichment', 't')"
                }
              }
            }
          },
          "threatIntel": {
            "fieldMap": {},
            "fieldToTypeMap": {}
          }
         }
         [Stellar]>>> CONFIG_PUT("ENRICHMENT", bro, "bro")
         ```
   
     1. Wait for the new configuration to be picked up by the running topology.
   
     1. Review the Bro telemetry indexed into Elasticsearch.  Look for records where the `ip_dst_addr` is `192.168.138.2`. Ensure that some of the messages have the following fields created from the enrichment.
         * `users:user`
         * `users:ip`
         ```
         {
           "_index": "bro_index_2019.08.13.20",
           "_type": "bro_doc",
           "_id": "AWyMxSJFg1bv3MpSt284",
           ...
           "_source": {          
             "ip_dst_addr": "192.168.138.2",
             "ip_src_addr": "192.168.138.158",
             "timestamp": 1565729823979,
             "source:type": "bro",
             "guid": "6778beb4-569d-478f-b1c9-8faaf475ac2f"
             ...
             "users:user": "jdoe",
             "users:ip": "192.168.138.2",
             ...
           },
           ...
         }
         ```
   
   ### Legacy HBase Adapter
   
   We are going to perform the same enrichment, but instead using the legacy HBase Adapter.
   
     1. Use the User data to enrich the telemetry.  Run the following commands in the REPL.
         ```
         [Stellar]>>> yaf := SHELL_EDIT()
         {
           "enrichment" : {
             "fieldMap" : {
               "hbaseEnrichment" : [ "ip_dst_addr" ]
             },
             "fieldToTypeMap" : {
                "ip_dst_addr" : [ "user" ]
             },
             "config" : {
               "typeToColumnFamily" : {
                 "user" : "t"
               }
             }
           },
           "threatIntel" : { },
           "configuration" : { }
         }
         [Stellar]>>> CONFIG_PUT("ENRICHMENT", yaf, "yaf")
         ```
       
     1. Wait for the new configuration to be picked up by the running topology.
   
     1. Review the YAF telemetry indexed into Elasticsearch.  Look for records where the `ip_dst_addr` is `192.168.138.2`. Ensure that some of the messages have the following fields created from the enrichment.
         * `enrichments:hbaseEnrichment:ip_dst_addr:user:ip`
         * `enrichments:hbaseEnrichment:ip_dst_addr:user:user`
         ```
         {
           "_index": "yaf_index_2019.08.15.03",
           "_type": "yaf_doc",
           "_id": "AWyTZAwEIFY9jxc2THLF",
           "_version": 1,
           "_score": null,
           "_source": {
             "source:type": "yaf",
             "ip_dst_addr": "192.168.138.2",
             "ip_src_addr": "192.168.138.158",
             "guid": "6c73c09d-f099-4646-b653-762adce121fe",
             ...
             "enrichments:hbaseEnrichment:ip_dst_addr:user:ip": "192.168.138.2",
             "enrichments:hbaseEnrichment:ip_dst_addr:user:user": "jdoe",
           }
         }
         ```   
         
   #### Profiler in the REPL
   
   1. Test a profile in the REPL according to [these instructions](https://github.com/apache/metron/tree/master/metron-analytics/metron-profiler-repl#getting-started).
   
       ```
       [Stellar]>>> values := PROFILER_FLUSH(profiler)
       [{period={duration=900000, period=1723089, start=1550780100000, end=1550781000000}, profile=hello-world, groups=[], value=4, entity=192.168.138.158}]
       ```
   
   #### Streaming Profiler
    
   1. Deploy that profile to the Streaming Profiler in Storm.
   
       ```
       [Stellar]>>> CONFIG_PUT("PROFILER", conf)
       ```
   
   1. Wait for the Streaming Profiler in Storm to flush and retrieve the measurement from HBase.  
   
       For the impatient, you can reset the period duration to 1 minute. Alternatively, you can allow the Profiler topology to work for a minute or two and then kill the `profiler` topology which will force it to flush a profile measurement to HBase.
   
       Retrieve the measurement from HBase.  Prior to this PR, it was not possible to query HBase from the REPL.
       ```
       [Stellar]>>> PROFILE_GET("hello-world","192.168.138.158",PROFILE_FIXED(30,"DAYS"))
       [2979]
       ```
   
   
   ## Pull Request Checklist
   
   ### For all changes:
   - [ ] 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).
   - [ ] 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.
   - [ ] Has your PR been rebased against the latest commit within the target branch (typically master)?
   
   
   ### For code changes:
   - [ ] Have you included steps to reproduce the behavior or problem that is being changed or addressed?
   - [ ] Have you included steps or a guide to how the change may be verified and tested manually?
   - [ ] 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 && dev-utilities/build-utils/verify_licenses.sh 
     ```
   
   - [ ] Have you written or updated unit tests and or integration tests to verify your changes?
   - [ ] 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:
   - [ ] 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
     ```
   
   - [ ] Have you ensured that any documentation diagrams have been updated, along with their source files, using [draw.io](https://www.draw.io/)? See [Metron Development Guidelines](https://cwiki.apache.org/confluence/display/METRON/Development+Guidelines) for instructions.
   
   #### 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.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services