-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b20b29
commit 2f4bd62
Showing
4 changed files
with
106 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/*############################################################################## | ||
HPCC SYSTEMS software Copyright (C) 2024 HPCC Systems®. | ||
Licensed 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 "elasticSink.hpp" | ||
|
||
#include "nlohmann/json.hpp" | ||
|
||
//including cpp-httplib single header file REST client | ||
// doesn't work with format-nonliteral as an error | ||
// | ||
#if defined(__clang__) || defined(__GNUC__) | ||
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Wformat-nonliteral" | ||
#endif | ||
|
||
#undef INVALID_SOCKET | ||
#include "httplib.h" | ||
|
||
#if defined(__clang__) || defined(__GNUC__) | ||
#pragma GCC diagnostic pop | ||
#endif | ||
|
||
using namespace hpccMetrics; | ||
|
||
extern "C" MetricSink* getSinkInstance(const char *name, const IPropertyTree *pSettingsTree) | ||
{ | ||
MetricSink *pSink = new ElasticMetricSink(name, pSettingsTree); | ||
return pSink; | ||
} | ||
|
||
|
||
ElasticMetricSink::ElasticMetricSink(const char *name, const IPropertyTree *pSettingsTree) : | ||
PeriodicMetricSink(name, "elastic", pSettingsTree) | ||
{ | ||
ignoreZeroMetrics = pSettingsTree->getPropBool("@ignoreZeroMetrics", true); | ||
pSettingsTree->getProp("@elasticHost", elasticHost); | ||
|
||
httplib::Client elasticClient(elasticHost.str()); | ||
|
||
nlohmann::json json_data = { | ||
{"key1", "value1"}, | ||
{"key2", "value2"} | ||
}; | ||
|
||
std::string json_string = json_data.dump(); | ||
|
||
auto res = elasticClient.Post("/elastichost", json_string, "application/json"); | ||
|
||
lastStatus = res->status; | ||
|
||
} | ||
|
||
|
||
void ElasticMetricSink::prepareToStartCollecting() | ||
{ | ||
|
||
} | ||
|
||
|
||
void ElasticMetricSink::doCollection() | ||
{ | ||
|
||
} | ||
|
||
|
||
void ElasticMetricSink::collectingHasStopped() | ||
{ | ||
; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters