Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion include/ipfixprobe/outputPlugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,25 @@
#include "flowifc.hpp"
#include "plugin.hpp"
#include "processPlugin.hpp"
#include "telemetry-utils.hpp"

#include <cstdint>
#include <memory>
#include <string>
#include <vector>

#include <telemetry.hpp>

namespace ipxp {

#define DEFAULT_EXPORTER_ID 1

/**
* \brief Base class for flow exporters.
*/
class IPXP_API OutputPlugin : public Plugin {
class IPXP_API OutputPlugin
: public TelemetryUtils
, public Plugin {
public:
using ProcessPlugins = std::vector<std::pair<std::string, std::shared_ptr<ProcessPlugin>>>;
uint64_t m_flows_seen; /**< Number of flows received to export. */
Expand All @@ -53,6 +58,12 @@ class IPXP_API OutputPlugin : public Plugin {
*/
virtual int export_flow(const Flow& flow) = 0;

/**
* \brief Set the telemetry directory for this plugin.
* \param [in] output_dir The telemetry directory for this plugin.
*/
void set_telemetry_dirs(std::shared_ptr<telemetry::Directory> output_dir);

/**
* \brief Force exporter to flush flows to collector.
*/
Expand Down
1 change: 1 addition & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ add_library(ipfixprobe-core STATIC
workers.cpp
workers.hpp
inputPlugin.cpp
outputPlugin.cpp
pluginManager.cpp
pluginManager.hpp
)
Expand Down
1 change: 1 addition & 0 deletions src/core/ipfixprobe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ bool process_plugin_args(ipxp_conf_t& conf, IpfixprobeOptParser& parser)
if (outputPlugin == nullptr) {
throw IPXPError("invalid output plugin " + output_name);
}
outputPlugin->set_telemetry_dirs(output_dir);
conf.outputPlugin = outputPlugin;
} catch (PluginError& e) {
throw IPXPError(output_name + std::string(": ") + e.what());
Expand Down
35 changes: 35 additions & 0 deletions src/core/outputPlugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* @file
* @brief Implementation of OutputPlugin telemetry integration
* @author Pavel Siska <siska@cesnet.cz>
* @date 2026
*
* This file contains the implementation of telemetry-related functions for
* the OutputPlugin class. It provides functionality to register parser statistics
* in the telemetry system and manage telemetry directories.
*
* Copyright (c) 2025 CESNET
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#include <ipfixprobe/outputPlugin.hpp>

namespace ipxp {

static telemetry::Content get_output_stats(const OutputPlugin* plugin)
{
telemetry::Dict dict;
dict["processed"] = plugin->m_flows_seen;
dict["dropped"] = plugin->m_flows_dropped;
return dict;
}

void OutputPlugin::set_telemetry_dirs(std::shared_ptr<telemetry::Directory> output_dir)
{
telemetry::FileOps statsOps = {[this]() { return get_output_stats(this); }, nullptr};

register_file(output_dir, "stats", statsOps);
}

} // namespace ipxp
1 change: 1 addition & 0 deletions src/plugins/output/ipfix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set_target_properties(ipfixprobe-output-ipfix PROPERTIES

target_include_directories(ipfixprobe-output-ipfix PRIVATE
${CMAKE_SOURCE_DIR}/include/
${telemetry_SOURCE_DIR}/include
)

target_link_libraries(ipfixprobe-output-ipfix PRIVATE
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/output/text/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ set_target_properties(ipfixprobe-output-text PROPERTIES
VISIBILITY_INLINES_HIDDEN YES
)

target_include_directories(ipfixprobe-output-text PRIVATE ${CMAKE_SOURCE_DIR}/include/)
target_include_directories(ipfixprobe-output-text PRIVATE
${CMAKE_SOURCE_DIR}/include/
${telemetry_SOURCE_DIR}/include
)

install(
TARGETS ipfixprobe-output-text
Expand Down
1 change: 1 addition & 0 deletions src/plugins/output/unirec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ set_target_properties(ipfixprobe-output-unirec PROPERTIES

target_include_directories(ipfixprobe-output-unirec PRIVATE
${CMAKE_SOURCE_DIR}/include/
${telemetry_SOURCE_DIR}/include
)

target_link_libraries(ipfixprobe-output-unirec PRIVATE
Expand Down
Loading