You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by GitBox <gi...@apache.org> on 2021/06/14 07:42:54 UTC

[GitHub] [brooklyn-server] jcabrerizo opened a new pull request #1188: Basic functionality for logstore interface

jcabrerizo opened a new pull request #1188:
URL: https://github.com/apache/brooklyn-server/pull/1188


   This provides the backend for expose the server logs from two different logstore implementation:
   - Static logfiles
   - A ElasticSearch instance
   
   The API and the LogStore interface only exposes a query method that expect the parameters from the UI (PR TBD) and returns a list of POJO representing each entry found on the configured LogStore implementation.
   
   The configuration for each LogStore implementation has to be added to the `brooklyn.cfg` file:
   
   For ElasticSearch:
   ```
   brooklyn.logbook.logStore = org.apache.brooklyn.util.core.logbook.opensearch.OpenSearchLogStore
   brooklyn.logbook.openSearchLogStore.host = https://localhost:9200
   brooklyn.logbook.openSearchLogStore.index = brooklyn
   brooklyn.logbook.openSearchLogStore.user = admin
   brooklyn.logbook.openSearchLogStore.password = admin
   brooklyn.logbook.openSearchLogStore.verifySSl = false
   ```
   For the plain log file:
   ```
   brooklyn.logbook.logStore = org.apache.brooklyn.util.core.logbook.file.FileLogStore
   brooklyn.logbook.fileLogStore.path = /var/logs/brooklyn/brooklyn.debug.log
   ```
   
   There are some pending tasks to be implemented:
   
   - [ ] Add more unit test
   - [ ] Improve the plain log implementation
   - [ ] Add "tail" behaviour to keep updating the ui with new entries 


-- 
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



[GitHub] [brooklyn-server] jcabrerizo commented on a change in pull request #1188: Basic functionality for logstore interface

Posted by GitBox <gi...@apache.org>.
jcabrerizo commented on a change in pull request #1188:
URL: https://github.com/apache/brooklyn-server/pull/1188#discussion_r652450969



##########
File path: core/src/main/java/org/apache/brooklyn/util/core/logbook/opensearch/OpenSearchLogStore.java
##########
@@ -0,0 +1,227 @@
+/*
+ * 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.brooklyn.util.core.logbook.opensearch;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import net.minidev.json.JSONObject;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.util.core.logbook.BrooklynLogEntry;
+import org.apache.brooklyn.util.core.logbook.LogBookQueryParams;
+import org.apache.brooklyn.util.core.logbook.LogStore;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.text.Strings;
+import org.apache.http.HttpHeaders;
+import org.apache.http.HttpHost;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.ssl.SSLContextBuilder;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLContext;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.KeyManagementException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.apache.brooklyn.util.core.logbook.LogbookConfig.BASE_NAME_LOGBOOK;
+
+/**
+ * Implementation for expose log from ElasticSearch to the logbook API.
+ */
+public class OpenSearchLogStore implements LogStore {
+
+    /*
+     # example config for local default implementation
+     brooklyn.logbook.logStore = org.apache.brooklyn.util.core.logbook.opensearch.OpenSearchLogStore
+     brooklyn.logbook.openSearchLogStore.host = https://localhost:9200
+     brooklyn.logbook.openSearchLogStore.index = brooklyn8
+     brooklyn.logbook.openSearchLogStore.user = admin
+     brooklyn.logbook.openSearchLogStore.password = admin
+     brooklyn.logbook.openSearchLogStore.verifySSl = false
+     */
+    public final static String BASE_NAME_OPEN_SEARCH_LOG_STORE = BASE_NAME_LOGBOOK + ".openSearchLogStore";
+
+    public final static ConfigKey<String> LOGBOOK_LOG_STORE_HOST = ConfigKeys.newStringConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".host", "Log store host");
+
+    public final static ConfigKey<String> LOGBOOK_LOG_STORE_INDEX = ConfigKeys.newStringConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".index", "Log store index");
+
+    public final static ConfigKey<String> LOGBOOK_LOG_STORE_USER = ConfigKeys.newStringConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".user", "User name");
+
+    public final static ConfigKey<String> LOGBOOK_LOG_STORE_PASS = ConfigKeys.newStringConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".password", "User password");
+
+    public final static ConfigKey<String> LOGBOOK_LOG_STORE_APIKEY = ConfigKeys.newStringConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".apikey", "API key");
+
+    public final static ConfigKey<Boolean> LOGBOOK_LOG_STORE_VERIFY_SSL = ConfigKeys.newBooleanConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".verifySSl", "Verify SSL", true);

Review comment:
       Good 🔍 I fixed the typo




-- 
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



[GitHub] [brooklyn-server] algairim commented on a change in pull request #1188: Basic functionality for logstore interface

Posted by GitBox <gi...@apache.org>.
algairim commented on a change in pull request #1188:
URL: https://github.com/apache/brooklyn-server/pull/1188#discussion_r652431142



##########
File path: core/src/main/java/org/apache/brooklyn/util/core/logbook/opensearch/BrooklynOpenSearchModel.java
##########
@@ -0,0 +1,100 @@
+/*
+ * 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.brooklyn.util.core.logbook.opensearch;
+
+import org.apache.brooklyn.util.core.logbook.BrooklynLogEntry;
+
+import java.util.List;
+
+class BrooklynOpenSearchModel {
+    OpenSearchHitsWrapper hits;
+    Integer took;
+    Boolean timed_out;
+
+    public OpenSearchHitsWrapper getHits() {
+        return hits;
+    }
+
+    public void setHits(OpenSearchHitsWrapper hits) {
+        this.hits = hits;
+    }
+
+    public Integer getTook() {
+        return took;
+    }
+
+    public void setTook(Integer took) {
+        this.took = took;
+    }
+
+    public Boolean getTimed_out() {
+        return timed_out;
+    }
+
+    public void setTimed_out(Boolean timed_out) {
+        this.timed_out = timed_out;
+    }
+
+    static class OpenSearchHitsWrapper {
+        List<OpenSearchHit> hits;
+
+        public List<OpenSearchHit> getHits() {
+            return hits;
+        }
+
+        public void setHits(List<OpenSearchHit> hits) {
+            this.hits = hits;
+        }
+    }
+
+    static class OpenSearchHit {
+        String _index;
+        String _type;

Review comment:
       Is underscore necessary?




-- 
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



[GitHub] [brooklyn-server] algairim commented on a change in pull request #1188: Basic functionality for logstore interface

Posted by GitBox <gi...@apache.org>.
algairim commented on a change in pull request #1188:
URL: https://github.com/apache/brooklyn-server/pull/1188#discussion_r652432566



##########
File path: core/src/main/java/org/apache/brooklyn/util/core/logbook/opensearch/OpenSearchLogStore.java
##########
@@ -0,0 +1,227 @@
+/*
+ * 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.brooklyn.util.core.logbook.opensearch;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import net.minidev.json.JSONObject;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.util.core.logbook.BrooklynLogEntry;
+import org.apache.brooklyn.util.core.logbook.LogBookQueryParams;
+import org.apache.brooklyn.util.core.logbook.LogStore;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.text.Strings;
+import org.apache.http.HttpHeaders;
+import org.apache.http.HttpHost;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.ssl.SSLContextBuilder;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLContext;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.KeyManagementException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.apache.brooklyn.util.core.logbook.LogbookConfig.BASE_NAME_LOGBOOK;
+
+/**
+ * Implementation for expose log from ElasticSearch to the logbook API.
+ */
+public class OpenSearchLogStore implements LogStore {
+
+    /*
+     # example config for local default implementation
+     brooklyn.logbook.logStore = org.apache.brooklyn.util.core.logbook.opensearch.OpenSearchLogStore
+     brooklyn.logbook.openSearchLogStore.host = https://localhost:9200
+     brooklyn.logbook.openSearchLogStore.index = brooklyn8
+     brooklyn.logbook.openSearchLogStore.user = admin
+     brooklyn.logbook.openSearchLogStore.password = admin
+     brooklyn.logbook.openSearchLogStore.verifySSl = false
+     */
+    public final static String BASE_NAME_OPEN_SEARCH_LOG_STORE = BASE_NAME_LOGBOOK + ".openSearchLogStore";
+
+    public final static ConfigKey<String> LOGBOOK_LOG_STORE_HOST = ConfigKeys.newStringConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".host", "Log store host");
+
+    public final static ConfigKey<String> LOGBOOK_LOG_STORE_INDEX = ConfigKeys.newStringConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".index", "Log store index");
+
+    public final static ConfigKey<String> LOGBOOK_LOG_STORE_USER = ConfigKeys.newStringConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".user", "User name");
+
+    public final static ConfigKey<String> LOGBOOK_LOG_STORE_PASS = ConfigKeys.newStringConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".password", "User password");
+
+    public final static ConfigKey<String> LOGBOOK_LOG_STORE_APIKEY = ConfigKeys.newStringConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".apikey", "API key");
+
+    public final static ConfigKey<Boolean> LOGBOOK_LOG_STORE_VERIFY_SSL = ConfigKeys.newBooleanConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".verifySSl", "Verify SSL", true);

Review comment:
       Or a camel-case `Ssl`




-- 
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



[GitHub] [brooklyn-server] algairim commented on a change in pull request #1188: Basic functionality for logstore interface

Posted by GitBox <gi...@apache.org>.
algairim commented on a change in pull request #1188:
URL: https://github.com/apache/brooklyn-server/pull/1188#discussion_r652432566



##########
File path: core/src/main/java/org/apache/brooklyn/util/core/logbook/opensearch/OpenSearchLogStore.java
##########
@@ -0,0 +1,227 @@
+/*
+ * 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.brooklyn.util.core.logbook.opensearch;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import net.minidev.json.JSONObject;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.util.core.logbook.BrooklynLogEntry;
+import org.apache.brooklyn.util.core.logbook.LogBookQueryParams;
+import org.apache.brooklyn.util.core.logbook.LogStore;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.text.Strings;
+import org.apache.http.HttpHeaders;
+import org.apache.http.HttpHost;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.ssl.SSLContextBuilder;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLContext;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.KeyManagementException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.apache.brooklyn.util.core.logbook.LogbookConfig.BASE_NAME_LOGBOOK;
+
+/**
+ * Implementation for expose log from ElasticSearch to the logbook API.
+ */
+public class OpenSearchLogStore implements LogStore {
+
+    /*
+     # example config for local default implementation
+     brooklyn.logbook.logStore = org.apache.brooklyn.util.core.logbook.opensearch.OpenSearchLogStore
+     brooklyn.logbook.openSearchLogStore.host = https://localhost:9200
+     brooklyn.logbook.openSearchLogStore.index = brooklyn8
+     brooklyn.logbook.openSearchLogStore.user = admin
+     brooklyn.logbook.openSearchLogStore.password = admin
+     brooklyn.logbook.openSearchLogStore.verifySSl = false
+     */
+    public final static String BASE_NAME_OPEN_SEARCH_LOG_STORE = BASE_NAME_LOGBOOK + ".openSearchLogStore";
+
+    public final static ConfigKey<String> LOGBOOK_LOG_STORE_HOST = ConfigKeys.newStringConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".host", "Log store host");
+
+    public final static ConfigKey<String> LOGBOOK_LOG_STORE_INDEX = ConfigKeys.newStringConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".index", "Log store index");
+
+    public final static ConfigKey<String> LOGBOOK_LOG_STORE_USER = ConfigKeys.newStringConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".user", "User name");
+
+    public final static ConfigKey<String> LOGBOOK_LOG_STORE_PASS = ConfigKeys.newStringConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".password", "User password");
+
+    public final static ConfigKey<String> LOGBOOK_LOG_STORE_APIKEY = ConfigKeys.newStringConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".apikey", "API key");
+
+    public final static ConfigKey<Boolean> LOGBOOK_LOG_STORE_VERIFY_SSL = ConfigKeys.newBooleanConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".verifySSl", "Verify SSL", true);

Review comment:
       Or a camel-case `verifySsl`




-- 
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



[GitHub] [brooklyn-server] algairim commented on pull request #1188: Basic functionality for logstore interface

Posted by GitBox <gi...@apache.org>.
algairim commented on pull request #1188:
URL: https://github.com/apache/brooklyn-server/pull/1188#issuecomment-862134488


   Looks ok in general. Some JavaDocs would be really appreciated.


-- 
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



[GitHub] [brooklyn-server] jcabrerizo commented on a change in pull request #1188: Basic functionality for logstore interface

Posted by GitBox <gi...@apache.org>.
jcabrerizo commented on a change in pull request #1188:
URL: https://github.com/apache/brooklyn-server/pull/1188#discussion_r652445218



##########
File path: core/src/main/java/org/apache/brooklyn/util/core/logbook/opensearch/BrooklynOpenSearchModel.java
##########
@@ -0,0 +1,100 @@
+/*
+ * 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.brooklyn.util.core.logbook.opensearch;
+
+import org.apache.brooklyn.util.core.logbook.BrooklynLogEntry;
+
+import java.util.List;
+
+class BrooklynOpenSearchModel {
+    OpenSearchHitsWrapper hits;
+    Integer took;
+    Boolean timed_out;
+
+    public OpenSearchHitsWrapper getHits() {
+        return hits;
+    }
+
+    public void setHits(OpenSearchHitsWrapper hits) {
+        this.hits = hits;
+    }
+
+    public Integer getTook() {
+        return took;
+    }
+
+    public void setTook(Integer took) {
+        this.took = took;
+    }
+
+    public Boolean getTimed_out() {
+        return timed_out;
+    }
+
+    public void setTimed_out(Boolean timed_out) {
+        this.timed_out = timed_out;
+    }
+
+    static class OpenSearchHitsWrapper {
+        List<OpenSearchHit> hits;
+
+        public List<OpenSearchHit> getHits() {
+            return hits;
+        }
+
+        public void setHits(List<OpenSearchHit> hits) {
+            this.hits = hits;
+        }
+    }
+
+    static class OpenSearchHit {
+        String _index;
+        String _type;

Review comment:
       I use the same field name returned by elastic search. Alternatively the fields can be annotated with ` @JsonProperty("class")` but I preferred to keep it as it is unless it's not clear enough 




-- 
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



[GitHub] [brooklyn-server] algairim commented on a change in pull request #1188: Basic functionality for logstore interface

Posted by GitBox <gi...@apache.org>.
algairim commented on a change in pull request #1188:
URL: https://github.com/apache/brooklyn-server/pull/1188#discussion_r652431522



##########
File path: core/src/main/java/org/apache/brooklyn/util/core/logbook/opensearch/OpenSearchLogStore.java
##########
@@ -0,0 +1,227 @@
+/*
+ * 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.brooklyn.util.core.logbook.opensearch;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import net.minidev.json.JSONObject;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.util.core.logbook.BrooklynLogEntry;
+import org.apache.brooklyn.util.core.logbook.LogBookQueryParams;
+import org.apache.brooklyn.util.core.logbook.LogStore;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.text.Strings;
+import org.apache.http.HttpHeaders;
+import org.apache.http.HttpHost;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.ssl.SSLContextBuilder;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLContext;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.KeyManagementException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.apache.brooklyn.util.core.logbook.LogbookConfig.BASE_NAME_LOGBOOK;
+
+/**
+ * Implementation for expose log from ElasticSearch to the logbook API.
+ */
+public class OpenSearchLogStore implements LogStore {
+
+    /*
+     # example config for local default implementation
+     brooklyn.logbook.logStore = org.apache.brooklyn.util.core.logbook.opensearch.OpenSearchLogStore
+     brooklyn.logbook.openSearchLogStore.host = https://localhost:9200
+     brooklyn.logbook.openSearchLogStore.index = brooklyn8
+     brooklyn.logbook.openSearchLogStore.user = admin
+     brooklyn.logbook.openSearchLogStore.password = admin
+     brooklyn.logbook.openSearchLogStore.verifySSl = false
+     */
+    public final static String BASE_NAME_OPEN_SEARCH_LOG_STORE = BASE_NAME_LOGBOOK + ".openSearchLogStore";
+
+    public final static ConfigKey<String> LOGBOOK_LOG_STORE_HOST = ConfigKeys.newStringConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".host", "Log store host");
+
+    public final static ConfigKey<String> LOGBOOK_LOG_STORE_INDEX = ConfigKeys.newStringConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".index", "Log store index");
+
+    public final static ConfigKey<String> LOGBOOK_LOG_STORE_USER = ConfigKeys.newStringConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".user", "User name");
+
+    public final static ConfigKey<String> LOGBOOK_LOG_STORE_PASS = ConfigKeys.newStringConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".password", "User password");
+
+    public final static ConfigKey<String> LOGBOOK_LOG_STORE_APIKEY = ConfigKeys.newStringConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".apikey", "API key");
+
+    public final static ConfigKey<Boolean> LOGBOOK_LOG_STORE_VERIFY_SSL = ConfigKeys.newBooleanConfigKey(
+            BASE_NAME_OPEN_SEARCH_LOG_STORE + ".verifySSl", "Verify SSL", true);

Review comment:
       SSL property must have capital `L` at the end.




-- 
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