martinzink commented on a change in pull request #1219:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1219#discussion_r781281741
##########
File path: PROCESSORS.md
##########
@@ -50,7 +50,9 @@
- [PutS3Object](#puts3object)
- [PutSFTP](#putsftp)
- [PutSQL](#putsql)
+- [PutSplunkHTTP](#putsplunkhttp)
Review comment:
Reordered it in
https://github.com/apache/nifi-minifi-cpp/pull/1219/commits/412fa041455d782eedc52bdfb24c680ae7e56808#diff-fd2410931e7fdc4bf8b3ce23f5f7a27c7aacdf9337320626d86d806448c90b9bL52
##########
File path: extensions/splunk/PutSplunkHTTP.cpp
##########
@@ -0,0 +1,176 @@
+/**
+ * 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.
+ */
+
+
+#include "PutSplunkHTTP.h"
+
+#include <vector>
+#include <utility>
+
+#include "SplunkAttributes.h"
+
+#include "core/Resource.h"
+#include "utils/StringUtils.h"
+#include "client/HTTPClient.h"
+#include "utils/HTTPClient.h"
+#include "utils/OptionalUtils.h"
+
+#include "rapidjson/document.h"
+
+
+namespace org::apache::nifi::minifi::extensions::splunk {
+
+const core::Property
PutSplunkHTTP::Source(core::PropertyBuilder::createProperty("Source")
+ ->withDescription("Basic field describing the source of the event. If
unspecified, the event will use the default defined in splunk.")
+ ->supportsExpressionLanguage(true)->build());
+
+const core::Property
PutSplunkHTTP::SourceType(core::PropertyBuilder::createProperty("Source Type")
+ ->withDescription("Basic field describing the source type of the event. If
unspecified, the event will use the default defined in splunk.")
+ ->supportsExpressionLanguage(true)->build());
+
+const core::Property
PutSplunkHTTP::Host(core::PropertyBuilder::createProperty("Host")
+ ->withDescription("Basic field describing the host of the event. If
unspecified, the event will use the default defined in splunk.")
+ ->supportsExpressionLanguage(true)->build());
+
+const core::Property
PutSplunkHTTP::Index(core::PropertyBuilder::createProperty("Index")
+ ->withDescription("Identifies the index where to send the event. If
unspecified, the event will use the default defined in splunk.")
+ ->supportsExpressionLanguage(true)->build());
+
+const core::Property
PutSplunkHTTP::ContentType(core::PropertyBuilder::createProperty("Content Type")
+ ->withDescription("The media type of the event sent to Splunk. If not set,
\"mime.type\" flow file attribute will be used. "
+ "In case of neither of them is specified, this
information will not be sent to the server.")
+ ->supportsExpressionLanguage(true)->build());
+
+
+const core::Relationship PutSplunkHTTP::Success("success", "FlowFiles that are
sent successfully to the destination are sent to this relationship.");
+const core::Relationship PutSplunkHTTP::Failure("failure", "FlowFiles that
failed to send to the destination are sent to this relationship.");
+
+void PutSplunkHTTP::initialize() {
+ setSupportedRelationships({Success, Failure});
+ setSupportedProperties({Hostname, Port, Token, SplunkRequestChannel,
SSLContext, Source, SourceType, Host, Index, ContentType});
+}
+
+void PutSplunkHTTP::onSchedule(const std::shared_ptr<core::ProcessContext>&
context, const std::shared_ptr<core::ProcessSessionFactory>& sessionFactory) {
+ SplunkHECProcessor::onSchedule(context, sessionFactory);
+}
+
+
+namespace {
+std::optional<std::string> getContentType(core::ProcessContext& context, const
core::FlowFile& flow_file) {
+ return context.getProperty(PutSplunkHTTP::ContentType) | utils::orElse
([&flow_file] {return flow_file.getAttribute("mime.type");});
+}
+
+
+std::string getEndpoint(core::ProcessContext& context, const
gsl::not_null<std::shared_ptr<core::FlowFile>>& flow_file) {
+ std::stringstream endpoint;
+ endpoint << "/services/collector/raw";
+ std::vector<std::string> parameters;
+ std::string prop_value;
+ if (context.getProperty(PutSplunkHTTP::SourceType, prop_value, flow_file)) {
+ parameters.push_back("sourcetype=" + prop_value);
+ }
+ if (context.getProperty(PutSplunkHTTP::Source, prop_value, flow_file)) {
+ parameters.push_back("source=" + prop_value);
+ }
+ if (context.getProperty(PutSplunkHTTP::Host, prop_value, flow_file)) {
+ parameters.push_back("host=" + prop_value);
+ }
+ if (context.getProperty(PutSplunkHTTP::Index, prop_value, flow_file)) {
+ parameters.push_back("index=" + prop_value);
+ }
+ if (!parameters.empty()) {
+ endpoint << "?" << utils::StringUtils::join("&", parameters);
+ }
+ return endpoint.str();
+}
+
+bool addAttributesFromClientResponse(core::FlowFile& flow_file,
utils::HTTPClient& client) {
+ rapidjson::Document response_json;
+ rapidjson::ParseResult parse_result =
response_json.Parse<rapidjson::kParseStopWhenDoneFlag>(client.getResponseBody().data());
+ bool result = true;
+ if (parse_result.IsError())
+ return false;
+
+ if (response_json.HasMember("code") && response_json["code"].IsInt())
+ flow_file.addAttribute(SPLUNK_RESPONSE_CODE,
std::to_string(response_json["code"].GetInt()));
+ else
+ result = false;
+
+ if (response_json.HasMember("ackId") && response_json["ackId"].IsUint64())
+ flow_file.addAttribute(SPLUNK_ACK_ID,
std::to_string(response_json["ackId"].GetUint64()));
Review comment:
Good catch, it wasnt intentional. I very well can image situations where
we wanna retry after a failed PutSplunkHTTP.
fixed it in
https://github.com/apache/nifi-minifi-cpp/pull/1219/commits/412fa041455d782eedc52bdfb24c680ae7e56808#diff-2633ef573b024e894869a6a974a55671c3468db3eff99e4cdc646a081a700efdR122-R123
##########
File path: extensions/splunk/QuerySplunkIndexingStatus.cpp
##########
@@ -0,0 +1,191 @@
+/**
+ * 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.
+ */
+
+
+#include "QuerySplunkIndexingStatus.h"
+
+#include <unordered_map>
+#include <utility>
+
+#include "SplunkAttributes.h"
+
+#include "core/Resource.h"
+#include "client/HTTPClient.h"
+#include "utils/HTTPClient.h"
+
+#include "rapidjson/document.h"
+#include "rapidjson/stringbuffer.h"
+#include "rapidjson/writer.h"
+
+namespace org::apache::nifi::minifi::extensions::splunk {
+
+const core::Property
QuerySplunkIndexingStatus::MaximumWaitingTime(core::PropertyBuilder::createProperty("Maximum
Waiting Time")
+ ->withDescription("The maximum time the processor tries to acquire
acknowledgement confirmation for an index, from the point of registration. "
+ "After the given amount of time, the processor considers
the index as not acknowledged and transfers the FlowFile to the
\"unacknowledged\" relationship.")
+ ->withDefaultValue("1 hour")->isRequired(true)->build());
Review comment:
:+1: done
https://github.com/apache/nifi-minifi-cpp/pull/1219/commits/412fa041455d782eedc52bdfb24c680ae7e56808#diff-a2db2ff59dd1ebf5f1e3e053781c55708df909e3009ee21015da3fe04218def4R40
##########
File path: extensions/splunk/QuerySplunkIndexingStatus.cpp
##########
@@ -0,0 +1,191 @@
+/**
+ * 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.
+ */
+
+
+#include "QuerySplunkIndexingStatus.h"
+
+#include <unordered_map>
+#include <utility>
+
+#include "SplunkAttributes.h"
+
+#include "core/Resource.h"
+#include "client/HTTPClient.h"
+#include "utils/HTTPClient.h"
+
+#include "rapidjson/document.h"
+#include "rapidjson/stringbuffer.h"
+#include "rapidjson/writer.h"
+
+namespace org::apache::nifi::minifi::extensions::splunk {
+
+const core::Property
QuerySplunkIndexingStatus::MaximumWaitingTime(core::PropertyBuilder::createProperty("Maximum
Waiting Time")
+ ->withDescription("The maximum time the processor tries to acquire
acknowledgement confirmation for an index, from the point of registration. "
+ "After the given amount of time, the processor considers
the index as not acknowledged and transfers the FlowFile to the
\"unacknowledged\" relationship.")
+ ->withDefaultValue("1 hour")->isRequired(true)->build());
+
+const core::Property
QuerySplunkIndexingStatus::MaxQuerySize(core::PropertyBuilder::createProperty("Maximum
Query Size")
+ ->withDescription("The maximum number of acknowledgement identifiers the
outgoing query contains in one batch. "
+ "It is recommended not to set it too low in order to
reduce network communication.")
+ ->withDefaultValue("1000")->isRequired(true)->build());
Review comment:
:+1: done
https://github.com/apache/nifi-minifi-cpp/pull/1219/commits/412fa041455d782eedc52bdfb24c680ae7e56808#diff-a2db2ff59dd1ebf5f1e3e053781c55708df909e3009ee21015da3fe04218def4R45
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]