This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new f0a7bf34258 camel-splunk-hec - Add endpoint url suffix configuration
to enable options and raw transports (#8774)
f0a7bf34258 is described below
commit f0a7bf34258740d1cf66af9efbc9c78f86fa0024
Author: Martin Kremers <[email protected]>
AuthorDate: Sat Nov 26 12:32:32 2022 +0100
camel-splunk-hec - Add endpoint url suffix configuration to enable options
and raw transports (#8774)
Signed-off-by: Martin Kremers <[email protected]>
---
.../splunkhec/SplunkHECEndpointConfigurer.java | 6 ++++++
.../splunkhec/SplunkHECEndpointUriFactory.java | 3 ++-
.../camel/component/splunkhec/splunk-hec.json | 1 +
.../splunkhec/SplunkHECConfiguration.java | 24 ++++++++++++++++++++++
.../component/splunkhec/SplunkHECProducer.java | 4 ++--
.../splunkhec/SplunkHECConfigurationTest.java | 6 ++++++
6 files changed, 41 insertions(+), 3 deletions(-)
diff --git
a/components/camel-splunk-hec/src/generated/java/org/apache/camel/component/splunkhec/SplunkHECEndpointConfigurer.java
b/components/camel-splunk-hec/src/generated/java/org/apache/camel/component/splunkhec/SplunkHECEndpointConfigurer.java
index 24bfee9ad62..b87621b0bff 100644
---
a/components/camel-splunk-hec/src/generated/java/org/apache/camel/component/splunkhec/SplunkHECEndpointConfigurer.java
+++
b/components/camel-splunk-hec/src/generated/java/org/apache/camel/component/splunkhec/SplunkHECEndpointConfigurer.java
@@ -35,6 +35,8 @@ public class SplunkHECEndpointConfigurer extends
PropertyConfigurerSupport imple
case "source":
target.getConfiguration().setSource(property(camelContext,
java.lang.String.class, value)); return true;
case "sourcetype":
case "sourceType":
target.getConfiguration().setSourceType(property(camelContext,
java.lang.String.class, value)); return true;
+ case "splunkendpoint":
+ case "splunkEndpoint":
target.getConfiguration().setSplunkEndpoint(property(camelContext,
java.lang.String.class, value)); return true;
case "time": target.getConfiguration().setTime(property(camelContext,
java.lang.Long.class, value)); return true;
default: return false;
}
@@ -57,6 +59,8 @@ public class SplunkHECEndpointConfigurer extends
PropertyConfigurerSupport imple
case "source": return java.lang.String.class;
case "sourcetype":
case "sourceType": return java.lang.String.class;
+ case "splunkendpoint":
+ case "splunkEndpoint": return java.lang.String.class;
case "time": return java.lang.Long.class;
default: return null;
}
@@ -80,6 +84,8 @@ public class SplunkHECEndpointConfigurer extends
PropertyConfigurerSupport imple
case "source": return target.getConfiguration().getSource();
case "sourcetype":
case "sourceType": return target.getConfiguration().getSourceType();
+ case "splunkendpoint":
+ case "splunkEndpoint": return
target.getConfiguration().getSplunkEndpoint();
case "time": return target.getConfiguration().getTime();
default: return null;
}
diff --git
a/components/camel-splunk-hec/src/generated/java/org/apache/camel/component/splunkhec/SplunkHECEndpointUriFactory.java
b/components/camel-splunk-hec/src/generated/java/org/apache/camel/component/splunkhec/SplunkHECEndpointUriFactory.java
index 6f56ca456b4..071689b1ac5 100644
---
a/components/camel-splunk-hec/src/generated/java/org/apache/camel/component/splunkhec/SplunkHECEndpointUriFactory.java
+++
b/components/camel-splunk-hec/src/generated/java/org/apache/camel/component/splunkhec/SplunkHECEndpointUriFactory.java
@@ -21,7 +21,7 @@ public class SplunkHECEndpointUriFactory extends
org.apache.camel.support.compon
private static final Set<String> SECRET_PROPERTY_NAMES;
private static final Set<String> MULTI_VALUE_PREFIXES;
static {
- Set<String> props = new HashSet<>(12);
+ Set<String> props = new HashSet<>(13);
props.add("bodyOnly");
props.add("headersOnly");
props.add("host");
@@ -31,6 +31,7 @@ public class SplunkHECEndpointUriFactory extends
org.apache.camel.support.compon
props.add("skipTlsVerify");
props.add("source");
props.add("sourceType");
+ props.add("splunkEndpoint");
props.add("splunkURL");
props.add("time");
props.add("token");
diff --git
a/components/camel-splunk-hec/src/generated/resources/org/apache/camel/component/splunkhec/splunk-hec.json
b/components/camel-splunk-hec/src/generated/resources/org/apache/camel/component/splunkhec/splunk-hec.json
index acb073ed6c7..5ff292cb02e 100644
---
a/components/camel-splunk-hec/src/generated/resources/org/apache/camel/component/splunkhec/splunk-hec.json
+++
b/components/camel-splunk-hec/src/generated/resources/org/apache/camel/component/splunkhec/splunk-hec.json
@@ -37,6 +37,7 @@
"index": { "kind": "parameter", "displayName": "Index", "group":
"producer", "label": "", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": "camel", "configurationClass":
"org.apache.camel.component.splunkhec.SplunkHECConfiguration",
"configurationField": "configuration", "description": "Splunk index to write
to" },
"source": { "kind": "parameter", "displayName": "Source", "group":
"producer", "label": "", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": "camel", "configurationClass":
"org.apache.camel.component.splunkhec.SplunkHECConfiguration",
"configurationField": "configuration", "description": "Splunk source argument"
},
"sourceType": { "kind": "parameter", "displayName": "Source Type",
"group": "producer", "label": "", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": "camel", "configurationClass":
"org.apache.camel.component.splunkhec.SplunkHECConfiguration",
"configurationField": "configuration", "description": "Splunk sourcetype
argument" },
+ "splunkEndpoint": { "kind": "parameter", "displayName": "Splunk Endpoint",
"group": "producer", "label": "", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": "\/services\/collector\/event",
"configurationClass":
"org.apache.camel.component.splunkhec.SplunkHECConfiguration",
"configurationField": "configuration", "description": "Splunk endpoint Defaults
to \/services\/collector\/event To writ [...]
"time": { "kind": "parameter", "displayName": "Time", "group": "producer",
"label": "", "required": false, "type": "integer", "javaType":
"java.lang.Long", "deprecated": false, "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.splunkhec.SplunkHECConfiguration",
"configurationField": "configuration", "description": "Time this even occurred.
By default, the time will be when this event hits the splunk server." },
"lazyStartProducer": { "kind": "parameter", "displayName": "Lazy Start
Producer", "group": "producer (advanced)", "label": "producer,advanced",
"required": false, "type": "boolean", "javaType": "boolean", "deprecated":
false, "autowired": false, "secret": false, "defaultValue": false,
"description": "Whether the producer should be started lazy (on the first
message). By starting lazy you can use this to allow CamelContext and routes to
startup in situations where a producer may other [...]
"https": { "kind": "parameter", "displayName": "Https", "group":
"security", "label": "security", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": true, "configurationClass":
"org.apache.camel.component.splunkhec.SplunkHECConfiguration",
"configurationField": "configuration", "description": "Contact HEC over https."
},
diff --git
a/components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECConfiguration.java
b/components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECConfiguration.java
index 078d003f0d0..6d1695ce67b 100644
---
a/components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECConfiguration.java
+++
b/components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECConfiguration.java
@@ -36,6 +36,8 @@ public class SplunkHECConfiguration {
private String source = "camel";
@UriParam
private String host;
+ @UriParam(defaultValue = "/services/collector/event")
+ private String splunkEndpoint = "/services/collector/event";
@UriParam(label = "security")
private boolean skipTlsVerify;
@UriParam(label = "security", defaultValue = "true")
@@ -99,6 +101,26 @@ public class SplunkHECConfiguration {
this.host = host;
}
+ /**
+ * Splunk endpoint
+ * Defaults to /services/collector/event
+ * To write RAW data like JSON use /services/collector/raw
+ * For a list of all endpoints refer to splunk documentation (HTTP Event
Collector REST API endpoints)
+ * Example for Spunk 8.2.x:
https://docs.splunk.com/Documentation/SplunkCloud/8.2.2203/Data/HECRESTendpoints
+ *
+ * To extract timestamps in Splunk>8.0
/services/collector/event?auto_extract_timestamp=true
+ * Remember to utilize RAW{} for questionmarks or slashes in parameters,
see:
+ * https://camel.apache.org/manual/faq/how-do-i-configure-endpoints.html
+ * #HowdoIconfigureendpoints-Configuringparametervaluesusingrawvalues
+ */
+ public void setSplunkEndpoint(String splunkEndpoint) {
+ this.splunkEndpoint = splunkEndpoint;
+ }
+
+ public String getSplunkEndpoint() {
+ return this.splunkEndpoint;
+ }
+
public boolean isSkipTlsVerify() {
return skipTlsVerify;
}
@@ -153,4 +175,6 @@ public class SplunkHECConfiguration {
public void setTime(Long time) {
this.time = time;
}
+
+
}
diff --git
a/components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECProducer.java
b/components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECProducer.java
index ec2cf813760..e1c5314ad04 100644
---
a/components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECProducer.java
+++
b/components/camel-splunk-hec/src/main/java/org/apache/camel/component/splunkhec/SplunkHECProducer.java
@@ -72,8 +72,8 @@ public class SplunkHECProducer extends DefaultProducer {
Map<String, Object> payload = createPayload(exchange.getIn());
HttpPost httppost = new HttpPost(
- (endpoint.getConfiguration().isHttps() ? "https" : "http") +
"://" + endpoint.getSplunkURL()
- + "/services/collector/event");
+ (endpoint.getConfiguration().isHttps() ? "https" : "http") +
"://"
+ + endpoint.getSplunkURL() +
endpoint.getConfiguration().getSplunkEndpoint());
httppost.addHeader("Authorization", " Splunk " + endpoint.getToken());
EntityTemplate entityTemplate = new EntityTemplate(outputStream ->
MAPPER.writer().writeValue(outputStream, payload));
diff --git
a/components/camel-splunk-hec/src/test/java/org/apache/camel/component/splunkhec/SplunkHECConfigurationTest.java
b/components/camel-splunk-hec/src/test/java/org/apache/camel/component/splunkhec/SplunkHECConfigurationTest.java
index c377994072b..fa8306e94e6 100644
---
a/components/camel-splunk-hec/src/test/java/org/apache/camel/component/splunkhec/SplunkHECConfigurationTest.java
+++
b/components/camel-splunk-hec/src/test/java/org/apache/camel/component/splunkhec/SplunkHECConfigurationTest.java
@@ -36,6 +36,12 @@ public class SplunkHECConfigurationTest {
assertEquals("mine", config.getHost());
}
+ @Test
+ public void testDefaultEndpoint() {
+ SplunkHECConfiguration config = new SplunkHECConfiguration();
+ assertEquals("/services/collector/event", config.getSplunkEndpoint());
+ }
+
@Test
public void testDefaultIndex() {
SplunkHECConfiguration config = new SplunkHECConfiguration();