You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by GitBox <gi...@apache.org> on 2020/04/20 00:36:37 UTC

[GitHub] [camel] atoulme opened a new pull request #3760: [CAMEL-14932] Add new Splunk HEC component

atoulme opened a new pull request #3760:
URL: https://github.com/apache/camel/pull/3760


   This adds a new component named `splunk-hec` after [Splunk HEC](https://dev.splunk.com/enterprise/docs/dataapps/httpeventcollector/).
   
   This allows sending data to Splunk using Apache Camel, over the HTTP Event Collector.
   
   The HTTP Event Collector is a simple HTTP REST endpoint where data may be posted with some metadata available to Splunk.


----------------------------------------------------------------
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] [camel] davsclaus commented on a change in pull request #3760: [CAMEL-14932] Add new Splunk HEC component

Posted by GitBox <gi...@apache.org>.
davsclaus commented on a change in pull request #3760:
URL: https://github.com/apache/camel/pull/3760#discussion_r411867669



##########
File path: components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECEndpoint.java
##########
@@ -0,0 +1,103 @@
+/*
+ * 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.camel.component.splunkhec;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.DefaultEndpoint;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The splunk component allows to publish events in Splunk using the HTTP Event Collector.
+ */
+@UriEndpoint(firstVersion = "3.3.0", scheme = "splunk-hec", title = "Splunk HEC", syntax = "splunk-hec:endpoint/token", label = "log,monitoring")
+public class SplunkHECEndpoint extends DefaultEndpoint {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SplunkHECEndpoint.class);
+    private static final Pattern URI_PARSER = Pattern.compile("splunk-hec\\:\\/?\\/?(\\w+):(\\d+)/(\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12})\\??.*");
+
+    @UriPath

Review comment:
       @UriPath must match the syntax `splunk-hec:endpoint/token`, eg having 2 UriPath named `endpoint` and `token`. Otherwise change the syntax to `splunk-hec:endpointUri` to match the current @UriPath name.




----------------------------------------------------------------
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] [camel] davsclaus commented on a change in pull request #3760: [CAMEL-14932] Add new Splunk HEC component

Posted by GitBox <gi...@apache.org>.
davsclaus commented on a change in pull request #3760:
URL: https://github.com/apache/camel/pull/3760#discussion_r411867389



##########
File path: components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECConfiguration.java
##########
@@ -0,0 +1,117 @@
+/*
+ * 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.camel.component.splunkhec;
+
+import java.net.UnknownHostException;
+
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
+import org.apache.camel.util.HostUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@UriParams
+public class SplunkHECConfiguration {
+    private static final transient Logger LOG = LoggerFactory.getLogger(SplunkHECConfiguration.class);
+
+    @UriParam(label = "producer")
+    private String index = "camel";
+    @UriParam(label = "producer")
+    private String sourceType = "camel";
+    @UriParam(label = "producer")
+    private String source = "camel";
+    @UriParam(label = "producer")
+    private String host;
+    @UriParam(label = "producer")
+    private boolean skipTlsVerify;
+    @UriParam(label = "producer")

Review comment:
       You need to specify default value in @UriParam when it has a value, also for the ones that has camel above.

##########
File path: components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECEndpoint.java
##########
@@ -0,0 +1,103 @@
+/*
+ * 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.camel.component.splunkhec;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.DefaultEndpoint;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The splunk component allows to publish events in Splunk using the HTTP Event Collector.
+ */
+@UriEndpoint(firstVersion = "3.3.0", scheme = "splunk-hec", title = "Splunk HEC", syntax = "splunk-hec:endpoint/token", label = "log,monitoring")
+public class SplunkHECEndpoint extends DefaultEndpoint {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SplunkHECEndpoint.class);
+    private static final Pattern URI_PARSER = Pattern.compile("splunk-hec\\:\\/?\\/?(\\w+):(\\d+)/(\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12})\\??.*");
+
+    @UriPath

Review comment:
       @UriPath must match the syntax `splunk-hec:endpoint/token`, eg having 2 UriPath named `endpoint` and `token`. Otherwise change the syntax to `splunk-hec:endpointUri` to match the current @UriParam name.




----------------------------------------------------------------
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] [camel] atoulme commented on a change in pull request #3760: [CAMEL-14932] Add new Splunk HEC component

Posted by GitBox <gi...@apache.org>.
atoulme commented on a change in pull request #3760:
URL: https://github.com/apache/camel/pull/3760#discussion_r411537053



##########
File path: components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECProducer.java
##########
@@ -0,0 +1,122 @@
+/*
+ * 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.camel.component.splunkhec;
+
+
+import java.io.ByteArrayOutputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.support.DefaultProducer;
+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.entity.ContentType;
+import org.apache.http.entity.EntityTemplate;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.ssl.SSLContextBuilder;
+
+/**
+ * The Splunk HEC producer.
+ */
+public class SplunkHECProducer extends DefaultProducer {
+    private static final ObjectMapper MAPPER = new ObjectMapper();
+    private SplunkHECEndpoint endpoint;
+    private CloseableHttpClient httpClient;
+
+
+    public SplunkHECProducer(SplunkHECEndpoint endpoint) {
+        super(endpoint);
+        this.endpoint = endpoint;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        HttpClientBuilder builder = HttpClients.custom().
+                setUserAgent("Camel Splunk HEC/" + getEndpoint().getCamelContext().getVersion()).
+                setMaxConnTotal(10);
+        if (endpoint.getConfiguration().isSkiptlsverify()) {
+            SSLContextBuilder sslbuilder = new SSLContextBuilder();
+            sslbuilder.loadTrustMaterial(null, (chain, authType) -> true);
+            SSLConnectionSocketFactory sslsf = new
+                    SSLConnectionSocketFactory(sslbuilder.build(), NoopHostnameVerifier.INSTANCE);
+            builder.setSSLSocketFactory(sslsf);
+        }
+        httpClient = builder.build();
+    }
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        Map<String, Object> payload = createPayload(exchange.getIn());
+
+        HttpPost httppost = new HttpPost((endpoint.getConfiguration().isHttps() ? "https" : "http") + "://" + endpoint.getSplunkURL() + "/services/collector/event");
+        httppost.addHeader("Authorization", " Splunk " + endpoint.getToken());
+
+        EntityTemplate entityTemplate = new EntityTemplate(outputStream -> MAPPER.writer().writeValue(outputStream, payload));
+        entityTemplate.setContentType(ContentType.APPLICATION_JSON.getMimeType());
+
+        httppost.setEntity(entityTemplate);
+        try (CloseableHttpResponse response = httpClient.execute(httppost)) {
+            if (response.getStatusLine().getStatusCode() != 200) {
+                ByteArrayOutputStream output = new ByteArrayOutputStream();
+                response.getEntity().writeTo(output);
+
+                throw new RuntimeException(response.getStatusLine().toString() + "\n" + new String(output.toByteArray(), StandardCharsets.UTF_8));
+            }
+        }
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+        httpClient.close();

Review comment:
       I'm seeing file and seda behave differently there. I think `super.doStop()` should be first so it logs the stop operation. If the client throws an exception, at least you get the log before.




----------------------------------------------------------------
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] [camel] oscerd commented on a change in pull request #3760: [CAMEL-14932] Add new Splunk HEC component

Posted by GitBox <gi...@apache.org>.
oscerd commented on a change in pull request #3760:
URL: https://github.com/apache/camel/pull/3760#discussion_r411137346



##########
File path: core/camel-componentdsl/src/generated/resources/metadata.json
##########
@@ -6612,6 +6612,28 @@
     "producerOnly": false,
     "lenientProperties": false
   },
+  "SplunkHecComponentBuilderFactory": {
+    "kind": "component",
+    "name": "splunk-hec",
+    "title": "Splunk HEC",
+    "description": "The splunk component allows to publish events in Splunk using the HTTP Event Collector.",
+    "deprecated": false,
+    "deprecationNote": "log,monitoring",
+    "firstVersion": "3.2.0",

Review comment:
       Firstversion is 3.3.0




----------------------------------------------------------------
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] [camel] atoulme commented on issue #3760: [CAMEL-14932] Add new Splunk HEC component

Posted by GitBox <gi...@apache.org>.
atoulme commented on issue #3760:
URL: https://github.com/apache/camel/pull/3760#issuecomment-618212979


   Thanks for merging. I think I didn't take care of `@UriPath` correctly, it's been a while.


----------------------------------------------------------------
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] [camel] dmvolod commented on a change in pull request #3760: [CAMEL-14932] Add new Splunk HEC component

Posted by GitBox <gi...@apache.org>.
dmvolod commented on a change in pull request #3760:
URL: https://github.com/apache/camel/pull/3760#discussion_r411212681



##########
File path: components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECConfiguration.java
##########
@@ -0,0 +1,117 @@
+/*
+ * 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.camel.component.splunkhec;
+
+import java.net.UnknownHostException;
+
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
+import org.apache.camel.util.HostUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@UriParams
+public class SplunkHECConfiguration {
+    private static final transient Logger LOG = LoggerFactory.getLogger(SplunkHECConfiguration.class);
+
+    @UriParam(label = "producer")
+    private String index = "camel";
+    @UriParam(label = "producer")
+    private String sourceType = "camel";
+    @UriParam(label = "producer")
+    private String source = "camel";
+    @UriParam(label = "host")
+    private String host;
+    @UriParam(label = "skiptlsverify")
+    private boolean skiptlsverify;

Review comment:
       @atoulme it would be nice to use camel case, however it's a little bit tautology for Camel project :) 




----------------------------------------------------------------
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] [camel] atoulme commented on a change in pull request #3760: [CAMEL-14932] Add new Splunk HEC component

Posted by GitBox <gi...@apache.org>.
atoulme commented on a change in pull request #3760:
URL: https://github.com/apache/camel/pull/3760#discussion_r411539438



##########
File path: core/camel-componentdsl/src/generated/resources/metadata.json
##########
@@ -6612,6 +6612,28 @@
     "producerOnly": false,
     "lenientProperties": false
   },
+  "SplunkHecComponentBuilderFactory": {
+    "kind": "component",
+    "name": "splunk-hec",
+    "title": "Splunk HEC",
+    "description": "The splunk component allows to publish events in Splunk using the HTTP Event Collector.",
+    "deprecated": false,
+    "deprecationNote": "log,monitoring",
+    "firstVersion": "3.2.0",

Review comment:
       Fixed.




----------------------------------------------------------------
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] [camel] atoulme commented on a change in pull request #3760: [CAMEL-14932] Add new Splunk HEC component

Posted by GitBox <gi...@apache.org>.
atoulme commented on a change in pull request #3760:
URL: https://github.com/apache/camel/pull/3760#discussion_r411539558



##########
File path: components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECConfiguration.java
##########
@@ -0,0 +1,117 @@
+/*
+ * 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.camel.component.splunkhec;
+
+import java.net.UnknownHostException;
+
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
+import org.apache.camel.util.HostUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@UriParams
+public class SplunkHECConfiguration {
+    private static final transient Logger LOG = LoggerFactory.getLogger(SplunkHECConfiguration.class);
+
+    @UriParam(label = "producer")
+    private String index = "camel";
+    @UriParam(label = "producer")
+    private String sourceType = "camel";
+    @UriParam(label = "producer")
+    private String source = "camel";
+    @UriParam(label = "host")
+    private String host;
+    @UriParam(label = "skiptlsverify")
+    private boolean skiptlsverify;

Review comment:
       Sure thing. Fixed!




----------------------------------------------------------------
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] [camel] atoulme commented on issue #3760: [CAMEL-14932] Add new Splunk HEC component

Posted by GitBox <gi...@apache.org>.
atoulme commented on issue #3760:
URL: https://github.com/apache/camel/pull/3760#issuecomment-618213872


   Thanks for updating and polishing my code, very appreciated. I look forward to using this connector!


----------------------------------------------------------------
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] [camel] omarsmak commented on a change in pull request #3760: [CAMEL-14932] Add new Splunk HEC component

Posted by GitBox <gi...@apache.org>.
omarsmak commented on a change in pull request #3760:
URL: https://github.com/apache/camel/pull/3760#discussion_r411163810



##########
File path: components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECProducer.java
##########
@@ -0,0 +1,122 @@
+/*
+ * 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.camel.component.splunkhec;
+
+
+import java.io.ByteArrayOutputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.support.DefaultProducer;
+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.entity.ContentType;
+import org.apache.http.entity.EntityTemplate;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.ssl.SSLContextBuilder;
+
+/**
+ * The Splunk HEC producer.
+ */
+public class SplunkHECProducer extends DefaultProducer {
+    private static final ObjectMapper MAPPER = new ObjectMapper();
+    private SplunkHECEndpoint endpoint;
+    private CloseableHttpClient httpClient;
+
+
+    public SplunkHECProducer(SplunkHECEndpoint endpoint) {
+        super(endpoint);
+        this.endpoint = endpoint;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        HttpClientBuilder builder = HttpClients.custom().
+                setUserAgent("Camel Splunk HEC/" + getEndpoint().getCamelContext().getVersion()).
+                setMaxConnTotal(10);
+        if (endpoint.getConfiguration().isSkiptlsverify()) {
+            SSLContextBuilder sslbuilder = new SSLContextBuilder();
+            sslbuilder.loadTrustMaterial(null, (chain, authType) -> true);
+            SSLConnectionSocketFactory sslsf = new
+                    SSLConnectionSocketFactory(sslbuilder.build(), NoopHostnameVerifier.INSTANCE);
+            builder.setSSLSocketFactory(sslsf);
+        }
+        httpClient = builder.build();
+    }
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        Map<String, Object> payload = createPayload(exchange.getIn());
+
+        HttpPost httppost = new HttpPost((endpoint.getConfiguration().isHttps() ? "https" : "http") + "://" + endpoint.getSplunkURL() + "/services/collector/event");
+        httppost.addHeader("Authorization", " Splunk " + endpoint.getToken());
+
+        EntityTemplate entityTemplate = new EntityTemplate(outputStream -> MAPPER.writer().writeValue(outputStream, payload));
+        entityTemplate.setContentType(ContentType.APPLICATION_JSON.getMimeType());
+
+        httppost.setEntity(entityTemplate);
+        try (CloseableHttpResponse response = httpClient.execute(httppost)) {
+            if (response.getStatusLine().getStatusCode() != 200) {
+                ByteArrayOutputStream output = new ByteArrayOutputStream();
+                response.getEntity().writeTo(output);
+
+                throw new RuntimeException(response.getStatusLine().toString() + "\n" + new String(output.toByteArray(), StandardCharsets.UTF_8));
+            }
+        }
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+        httpClient.close();

Review comment:
       Isn't better to have `httpClient.close` before `super.doStop()`?




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