[GitHub] metron pull request #853: METRON-1337: List of facets should not be hardcode...
Github user asfgit closed the pull request at: https://github.com/apache/metron/pull/853 ---
[GitHub] metron pull request #853: METRON-1337: List of facets should not be hardcode...
Github user mmiklavc commented on a diff in the pull request: https://github.com/apache/metron/pull/853#discussion_r171015228 --- Diff: metron-platform/metron-indexing/src/main/java/org/apache/metron/indexing/dao/search/SearchRequest.java --- @@ -101,16 +99,16 @@ public void setSort(List sort) { this.sort = sort; } - public OptionalgetFields() { -return fields == null || fields.size() == 0 ? Optional.empty() : Optional.of(fields); + public List getFields() { +return fields; } public void setFields(List fields) { this.fields = fields; } - public Optional
getFacetFields() { -return facetFields == null || facetFields.size() == 0 ? Optional.empty() : Optional.of(facetFields); + public List getFacetFields() { +return facetFields; --- End diff -- Ok, sounds reasonable ---
[GitHub] metron pull request #853: METRON-1337: List of facets should not be hardcode...
Github user ottobackwards commented on a diff in the pull request: https://github.com/apache/metron/pull/853#discussion_r170125479 --- Diff: metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/AlertServiceImpl.java --- @@ -37,15 +47,21 @@ @Service public class AlertServiceImpl implements AlertService { --- End diff -- I think that is great. At some point, if we are going to do this a few times we should have a standard naming convention ( separators at least or something). But that isn't a thing for this PR ---
[GitHub] metron pull request #853: METRON-1337: List of facets should not be hardcode...
Github user merrimanr commented on a diff in the pull request: https://github.com/apache/metron/pull/853#discussion_r170120909 --- Diff: metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/AlertServiceImpl.java --- @@ -37,15 +47,21 @@ @Service public class AlertServiceImpl implements AlertService { --- End diff -- Name is changed in the latest commit. Let me know what you think. ---
[GitHub] metron pull request #853: METRON-1337: List of facets should not be hardcode...
Github user ottobackwards commented on a diff in the pull request: https://github.com/apache/metron/pull/853#discussion_r169515112 --- Diff: metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/AlertServiceImpl.java --- @@ -37,15 +47,21 @@ @Service public class AlertServiceImpl implements AlertService { --- End diff -- That seems reasonable ---
[GitHub] metron pull request #853: METRON-1337: List of facets should not be hardcode...
Github user merrimanr commented on a diff in the pull request: https://github.com/apache/metron/pull/853#discussion_r169455383 --- Diff: metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/AlertServiceImpl.java --- @@ -37,15 +47,21 @@ @Service public class AlertServiceImpl implements AlertService { --- End diff -- Sure I can do that. Since these settings are specific to the Alerts UI, should we include "ui" too? Should the REST service also follow a similar pattern? ---
[GitHub] metron pull request #853: METRON-1337: List of facets should not be hardcode...
Github user ottobackwards commented on a diff in the pull request: https://github.com/apache/metron/pull/853#discussion_r169441455 --- Diff: metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/AlertServiceImpl.java --- @@ -37,15 +47,21 @@ @Service public class AlertServiceImpl implements AlertService { --- End diff -- can we make the type metron_alert? alert seems a little generic ---
[GitHub] metron pull request #853: METRON-1337: List of facets should not be hardcode...
Github user merrimanr commented on a diff in the pull request: https://github.com/apache/metron/pull/853#discussion_r168817020 --- Diff: metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/HBaseConfig.java --- @@ -0,0 +1,61 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.config; + +import org.apache.hadoop.hbase.HBaseConfiguration; +import org.apache.hadoop.hbase.client.HTableInterface; +import org.apache.metron.hbase.HTableProvider; +import org.apache.metron.rest.MetronRestConstants; +import org.apache.metron.rest.RestException; +import org.apache.metron.rest.service.GlobalConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.springframework.core.env.Environment; + +import java.io.IOException; + +import static org.apache.metron.rest.MetronRestConstants.TEST_PROFILE; +import static org.apache.metron.rest.repository.UserSettingsRepository.USER_SETTINGS_HBASE_TABLE; + +@Configuration +@Profile("!" + TEST_PROFILE) --- End diff -- We don't want to use this Configuration if tests are running. There is a separate TestConfig that setups up mock, inmemory components, etc. ---
[GitHub] metron pull request #853: METRON-1337: List of facets should not be hardcode...
Github user merrimanr commented on a diff in the pull request: https://github.com/apache/metron/pull/853#discussion_r168816712 --- Diff: metron-platform/metron-indexing/src/main/java/org/apache/metron/indexing/dao/search/SearchRequest.java --- @@ -101,16 +99,16 @@ public void setSort(List sort) { this.sort = sort; } - public OptionalgetFields() { -return fields == null || fields.size() == 0 ? Optional.empty() : Optional.of(fields); + public List getFields() { +return fields; } public void setFields(List fields) { this.fields = fields; } - public Optional
getFacetFields() { -return facetFields == null || facetFields.size() == 0 ? Optional.empty() : Optional.of(facetFields); + public List getFacetFields() { +return facetFields; --- End diff -- Because null and an empty array mean 2 different things. See point 6 here: https://github.com/apache/metron/pull/853#issuecomment-356350839. ---
[GitHub] metron pull request #853: METRON-1337: List of facets should not be hardcode...
Github user merrimanr commented on a diff in the pull request: https://github.com/apache/metron/pull/853#discussion_r168816212 --- Diff: metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/rest_commands.py --- @@ -179,6 +203,35 @@ def status_rest_application(self, env): self.__params.metron_rest_port, self.__params.metron_user) +def create_hbase_tables(self): +Logger.info("Creating HBase Tables") +metron_service.create_hbase_table(self.__params, + self.__params.user_settings_hbase_table, + self.__params.user_settings_hbase_cf) +Logger.info("Done creating HBase Tables") +self.set_hbase_configured() + +def set_hbase_acls(self): +Logger.info("Setting HBase ACLs") +if self.__params.security_enabled: +kinit(self.__params.kinit_path_local, + self.__params.hbase_keytab_path, + self.__params.hbase_principal_name, + execute_user=self.__params.hbase_user) + +cmd = "echo \"grant '{0}', 'RW', '{1}'\" | hbase shell -n" --- End diff -- Good catch. ---
[GitHub] metron pull request #853: METRON-1337: List of facets should not be hardcode...
Github user mmiklavc commented on a diff in the pull request: https://github.com/apache/metron/pull/853#discussion_r168809125 --- Diff: metron-platform/metron-indexing/src/main/java/org/apache/metron/indexing/dao/search/SearchRequest.java --- @@ -101,16 +99,16 @@ public void setSort(List sort) { this.sort = sort; } - public OptionalgetFields() { -return fields == null || fields.size() == 0 ? Optional.empty() : Optional.of(fields); + public List getFields() { +return fields; } public void setFields(List fields) { this.fields = fields; } - public Optional
getFacetFields() { -return facetFields == null || facetFields.size() == 0 ? Optional.empty() : Optional.of(facetFields); + public List getFacetFields() { +return facetFields; --- End diff -- If we're going to change the interface, what about ``` return facetFields == null ? new ArrayList() : facetFields; ``` so it's not null. ---
[GitHub] metron pull request #853: METRON-1337: List of facets should not be hardcode...
Github user mmiklavc commented on a diff in the pull request: https://github.com/apache/metron/pull/853#discussion_r168810966 --- Diff: metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/HBaseConfig.java --- @@ -0,0 +1,61 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.config; + +import org.apache.hadoop.hbase.HBaseConfiguration; +import org.apache.hadoop.hbase.client.HTableInterface; +import org.apache.metron.hbase.HTableProvider; +import org.apache.metron.rest.MetronRestConstants; +import org.apache.metron.rest.RestException; +import org.apache.metron.rest.service.GlobalConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.springframework.core.env.Environment; + +import java.io.IOException; + +import static org.apache.metron.rest.MetronRestConstants.TEST_PROFILE; +import static org.apache.metron.rest.repository.UserSettingsRepository.USER_SETTINGS_HBASE_TABLE; + +@Configuration +@Profile("!" + TEST_PROFILE) --- End diff -- Test profile? ---
[GitHub] metron pull request #853: METRON-1337: List of facets should not be hardcode...
Github user mmiklavc commented on a diff in the pull request: https://github.com/apache/metron/pull/853#discussion_r168802913 --- Diff: metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/scripts/rest_commands.py --- @@ -179,6 +203,35 @@ def status_rest_application(self, env): self.__params.metron_rest_port, self.__params.metron_user) +def create_hbase_tables(self): +Logger.info("Creating HBase Tables") +metron_service.create_hbase_table(self.__params, + self.__params.user_settings_hbase_table, + self.__params.user_settings_hbase_cf) +Logger.info("Done creating HBase Tables") +self.set_hbase_configured() + +def set_hbase_acls(self): +Logger.info("Setting HBase ACLs") +if self.__params.security_enabled: +kinit(self.__params.kinit_path_local, + self.__params.hbase_keytab_path, + self.__params.hbase_principal_name, + execute_user=self.__params.hbase_user) + +cmd = "echo \"grant '{0}', 'RW', '{1}'\" | hbase shell -n" --- End diff -- Do we check that the REST API has the hbase client also installed on the node? This would be needed for this to work for > 1 nodes. ---
[GitHub] metron pull request #853: METRON-1337: List of facets should not be hardcode...
GitHub user merrimanr opened a pull request: https://github.com/apache/metron/pull/853 METRON-1337: List of facets should not be hardcoded ## Contributor Comments This PR makes the list of facet fields in the Alerts UI configurable. There is now a "search.facet.fields" setting in https://github.com/apache/metron/blob/master/metron-interface/metron-rest/src/main/resources/application.yml that is a comma-separate list of fields to be used as facets. Originally a comment was made that the "host" field wasn't commonly used so I removed that from the default list. I can think of two options for exposing this configuration: - through an AlertProfile that is specific to each user, stored in a relational database and can be edited through REST - a setting that is exposed in Ambari I chose to include the first option in this PR to get the conversation going. Is one of these preferable? The AlertProfile approach allows this setting to be changed at runtime and each user has their own list of facet fields. But it is not versioned like it would if it were in Ambari. Do we prefer one over the other? Do we want both with Ambari being the default when an AlertProfile doesn't exist for a user? Are there other options I'm not thinking of? This works similar to how default search indices work: it is managed in the REST layer and can be overriden by including facet fields in a search request. However it seemed useful to allow a way to explicitly NOT include facets in a query so it works slightly different than indices. A missing facetFields property in the request will use the defaults while an empty array will disable facets. A missing indices property or an empty array will use the default indices. Is this the correct behavior? This has been tested in full dev and the UI e2e tests pass when run in isolation. There is currently an effort to stabilize the e2e tests as a follow on to https://github.com/apache/metron/pull/803 so I did not try to solve that here. I will add some documentation around configuring the facet field list and facetFields behavior in a search request once we come to a consensus on the solution. Another issue I would like to point out. When I added facetFields to the AlertProfile object it required a database update because that new field needed to be added to the database. This would become an issue if someone were upgrading from a previous version. Is this acceptable if we document it for future upgrades? Is a relational database the right solution or should we consider a more flexible storage option? ## 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- where 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