Skip to content
This repository was archived by the owner on Aug 20, 2025. It is now read-only.

Conversation

@merrimanr
Copy link
Contributor

Contributor Comments

This PR fixes a bug in the ElasticsearchMetaalertDao class (description is in the Jira). I verified it in full dev using the following steps:

  1. Search for alerts in an index (you need a couple guids) with the http://node1:8082/swagger-ui.html#!/search-controller/searchUsingPOST endpoint. I used the alerts_ui_e2e data set that can be created with https://github.com/apache/metron/blob/master/metron-interface/metron-alerts/e2e/mock-data/setup.sh:
{
    "from": 0,
    "indices": [
      "alerts_ui_e2e"
    ],
    "query": "*",
    "size": 5
  }
  1. Pick a couple guids from the previous step and use the http://node1:8082/swagger-ui.html#!/meta-alert-controller/createUsingPOST endpoint to create a metaalert:
{
    "groups": [
      "string"
    ],
    "guidToIndices": {
      "c4c5e418-3938-099e-bb0d-37028a98dca8": "alerts_ui_e2e",
      "fa91598f-51b2-2b60-11f2-6fbabc162b7e": "alerts_ui_e2e"
    }
  }
  1. Use the http://node1:8082/swagger-ui.html#!/search-controller/searchUsingPOST endpoint to see validate the metaalert you created in the previous step:
{
    "from": 0,
    "indices": [
      "metaalert"
    ],
    "query": "*",
    "size": 5
  }
  1. Update one of the alerts with the http://node1:8082/swagger-ui.html#!/update-controller/patchUsingPATCH endpoint:
{
    "guid": "c4c5e418-3938-099e-bb0d-37028a98dca8",
    "index": "alerts_ui_e2e_index",
    "patch": [
      {
        "op": "add",
        "path": "/comments",
        "value": [
          {
            "comment": "aaa",
            "username": "admin",
            "timestamp": 1508251594109
          },
          {
            "comment": "aaa",
            "username": "admin",
            "timestamp": 1508251398188
          },
          {
            "comment": "abcd",
            "username": "admin",
            "timestamp": 1508251201985
          },
          {
            "comment": "ccc",
            "username": "admin",
            "timestamp": 1508244721089
          },
          {
            "comment": "c123",
            "username": "admin",
            "timestamp": 1508244381778
          }
        ]
      }
    ]
  }
  1. Rerun the metadata search with the http://node1:8082/swagger-ui.html#!/search-controller/searchUsingPOST endpoint:
{
    "from": 0,
    "indices": [
      "metaalert"
    ],
    "query": "*",
    "size": 5
  }

The alert you updated should also have the same update within the metaalert. Both alerts should also be present.

A couple of things I want to point out:

  • I ran into a NoSuchMethod error and had to remove an old jackson dependency from metron-elasticsearch pom.xml. It was a pretty old dependency and I haven't seen any issues since.
  • I added a "guid" field to MetaAlertCreateResponse class. I believe this makes it more useful when waiting on a metaalert create to propagate.
  • It was convenient to include both the patch and replace operations in the same test. I can split these out if desired (it will make the test more verbose and add a duplicate test setup).

Pull Request Checklist

Thank you for submitting a contribution to Apache Metron.
Please refer to our Development Guidelines for the complete guide to follow for contributions.
Please refer also to our Build Verification Guidelines 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:

  • Is there a JIRA ticket associated with this PR? If not one needs to be created at Metron Jira.
  • 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 && 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?

  • 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
    

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 is set up for your personal repository such that your branches are built there before submitting a pull request.

# Conflicts:
#	metron-platform/metron-elasticsearch/src/main/java/org/apache/metron/elasticsearch/dao/ElasticsearchMetaAlertDao.java
#	metron-platform/metron-elasticsearch/src/test/java/org/apache/metron/elasticsearch/integration/ElasticsearchMetaAlertIntegrationTest.java
@justinleet
Copy link
Contributor

+1 by inspection. Thank for contributing!

@asfgit asfgit closed this in 32a0a9d Oct 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants