diff --git a/system/metrics/sinks/CMakeLists.txt b/system/metrics/sinks/CMakeLists.txt index d5d6f756fcf..a46652b191c 100644 --- a/system/metrics/sinks/CMakeLists.txt +++ b/system/metrics/sinks/CMakeLists.txt @@ -1,5 +1,5 @@ ############################################################################### -# HPCC SYSTEMS software Copyright (C) 2021 HPCC Systems®. +# HPCC SYSTEMS software Copyright (C) 20214HPCC Systems®. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,3 +17,4 @@ HPCC_ADD_SUBDIRECTORY (file) HPCC_ADD_SUBDIRECTORY (log) HPCC_ADD_SUBDIRECTORY (prometheus) +HPCC_ADD_SUBDIRECTORY (elastic) diff --git a/system/metrics/sinks/elastic/CMakeLists.txt b/system/metrics/sinks/elastic/CMakeLists.txt new file mode 100644 index 00000000000..e789eb3fdcb --- /dev/null +++ b/system/metrics/sinks/elastic/CMakeLists.txt @@ -0,0 +1,33 @@ +################################################################################ +# 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. +################################################################################ + +project(hpccmetrics_elasticsink) + +set ( srcs + elasticSink.cpp + ) + +include_directories( + ${HPCC_SOURCE_DIR}/system/include + ${HPCC_SOURCE_DIR}/system/jlib + ${HPCC_SOURCE_DIR}/system/httplib +) + +SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${STRICT_CXX_FLAGS}") +ADD_DEFINITIONS( -DELASTICSINK_EXPORTS ) +HPCC_ADD_LIBRARY( hpccmetrics_elasticsink SHARED ${srcs} ) +TARGET_LINK_LIBRARIES( hpccmetrics_elasticsink jlib) +INSTALL ( TARGETS hpccmetrics_elasticsink RUNTIME DESTINATION ${EXEC_DIR} LIBRARY DESTINATION ${LIB_DIR} ) diff --git a/system/metrics/sinks/elastic/elasticSink.cpp b/system/metrics/sinks/elastic/elasticSink.cpp new file mode 100644 index 00000000000..0c3a4bba890 --- /dev/null +++ b/system/metrics/sinks/elastic/elasticSink.cpp @@ -0,0 +1,51 @@ +/*############################################################################## + 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 +#include "platform.h" + +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, "file", pSettingsTree), + ignoreZeroMetrics(false) +{ + ignoreZeroMetrics = pSettingsTree->getPropBool("@ignoreZeroMetrics", true); +} + + +void ElasticMetricSink::prepareToStartCollecting() +{ + +} + + +void ElasticMetricSink::doCollection() +{ + +} + + +void ElasticMetricSink::collectingHasStopped() +{ + ; +} + diff --git a/system/metrics/sinks/elastic/elasticSink.hpp b/system/metrics/sinks/elastic/elasticSink.hpp new file mode 100644 index 00000000000..74dec839679 --- /dev/null +++ b/system/metrics/sinks/elastic/elasticSink.hpp @@ -0,0 +1,59 @@ +/*############################################################################## + 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. +############################################################################## */ + + +#pragma once + +#include "jmetrics.hpp" +#include "jptree.hpp" +#include "jstring.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 + +#include "nlohmann/json.hpp" + + +#ifdef ELASTICINK_EXPORTS +#define ELASTICSINK_API DECL_EXPORT +#else +#define ELASTICSINK_API DECL_IMPORT +#endif + +class ELASTICSINK_API ElasticMetricSink : public hpccMetrics::PeriodicMetricSink +{ +public: + explicit ElasticMetricSink(const char *name, const IPropertyTree *pSettingsTree); + ~ElasticMetricSink() override = default; + +protected: + void prepareToStartCollecting() override; + void collectingHasStopped() override; + void doCollection() override; + +protected: + StringBuffer indexName; + bool ignoreZeroMetrics; +};