Skip to content

Commit 4e223f1

Browse files
author
Pavel Siska
committed
output: add telemetry support to OutputPlugin
Add telemetry integration to OutputPlugin — exposes processed/dropped flow counters as a stats file in the telemetry directory
1 parent 53c6f56 commit 4e223f1

7 files changed

Lines changed: 55 additions & 2 deletions

File tree

include/ipfixprobe/outputPlugin.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,25 @@
1717
#include "flowifc.hpp"
1818
#include "plugin.hpp"
1919
#include "processPlugin.hpp"
20+
#include "telemetry-utils.hpp"
2021

2122
#include <cstdint>
2223
#include <memory>
2324
#include <string>
2425
#include <vector>
2526

27+
#include <telemetry.hpp>
28+
2629
namespace ipxp {
2730

2831
#define DEFAULT_EXPORTER_ID 1
2932

3033
/**
3134
* \brief Base class for flow exporters.
3235
*/
33-
class IPXP_API OutputPlugin : public Plugin {
36+
class IPXP_API OutputPlugin
37+
: public TelemetryUtils
38+
, public Plugin {
3439
public:
3540
using ProcessPlugins = std::vector<std::pair<std::string, std::shared_ptr<ProcessPlugin>>>;
3641
uint64_t m_flows_seen; /**< Number of flows received to export. */
@@ -53,6 +58,12 @@ class IPXP_API OutputPlugin : public Plugin {
5358
*/
5459
virtual int export_flow(const Flow& flow) = 0;
5560

61+
/**
62+
* \brief Set the telemetry directory for this plugin.
63+
* \param [in] output_dir The telemetry directory for this plugin.
64+
*/
65+
void set_telemetry_dirs(std::shared_ptr<telemetry::Directory> output_dir);
66+
5667
/**
5768
* \brief Force exporter to flush flows to collector.
5869
*/

src/core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ add_library(ipfixprobe-core STATIC
1111
workers.cpp
1212
workers.hpp
1313
inputPlugin.cpp
14+
outputPlugin.cpp
1415
pluginManager.cpp
1516
pluginManager.hpp
1617
)

src/core/ipfixprobe.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ bool process_plugin_args(ipxp_conf_t& conf, IpfixprobeOptParser& parser)
338338
if (outputPlugin == nullptr) {
339339
throw IPXPError("invalid output plugin " + output_name);
340340
}
341+
outputPlugin->set_telemetry_dirs(output_dir);
341342
conf.outputPlugin = outputPlugin;
342343
} catch (PluginError& e) {
343344
throw IPXPError(output_name + std::string(": ") + e.what());

src/core/outputPlugin.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @file
3+
* @brief Implementation of OutputPlugin telemetry integration
4+
* @author Pavel Siska <siska@cesnet.cz>
5+
* @date 2026
6+
*
7+
* This file contains the implementation of telemetry-related functions for
8+
* the OutputPlugin class. It provides functionality to register parser statistics
9+
* in the telemetry system and manage telemetry directories.
10+
*
11+
* Copyright (c) 2025 CESNET
12+
*
13+
* SPDX-License-Identifier: BSD-3-Clause
14+
*/
15+
16+
#include <ipfixprobe/outputPlugin.hpp>
17+
18+
namespace ipxp {
19+
20+
static telemetry::Content get_output_stats(const OutputPlugin* plugin)
21+
{
22+
telemetry::Dict dict;
23+
dict["processed"] = plugin->m_flows_seen;
24+
dict["dropped"] = plugin->m_flows_dropped;
25+
return dict;
26+
}
27+
28+
void OutputPlugin::set_telemetry_dirs(std::shared_ptr<telemetry::Directory> output_dir)
29+
{
30+
telemetry::FileOps statsOps = {[this]() { return get_output_stats(this); }, nullptr};
31+
32+
register_file(output_dir, "stats", statsOps);
33+
}
34+
35+
} // namespace ipxp

src/plugins/output/ipfix/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ set_target_properties(ipfixprobe-output-ipfix PROPERTIES
1313

1414
target_include_directories(ipfixprobe-output-ipfix PRIVATE
1515
${CMAKE_SOURCE_DIR}/include/
16+
${telemetry_SOURCE_DIR}/include
1617
)
1718

1819
target_link_libraries(ipfixprobe-output-ipfix PRIVATE

src/plugins/output/text/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ set_target_properties(ipfixprobe-output-text PROPERTIES
1010
VISIBILITY_INLINES_HIDDEN YES
1111
)
1212

13-
target_include_directories(ipfixprobe-output-text PRIVATE ${CMAKE_SOURCE_DIR}/include/)
13+
target_include_directories(ipfixprobe-output-text PRIVATE
14+
${CMAKE_SOURCE_DIR}/include/
15+
${telemetry_SOURCE_DIR}/include
16+
)
1417

1518
install(
1619
TARGETS ipfixprobe-output-text

src/plugins/output/unirec/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ set_target_properties(ipfixprobe-output-unirec PROPERTIES
1212

1313
target_include_directories(ipfixprobe-output-unirec PRIVATE
1414
${CMAKE_SOURCE_DIR}/include/
15+
${telemetry_SOURCE_DIR}/include
1516
)
1617

1718
target_link_libraries(ipfixprobe-output-unirec PRIVATE

0 commit comments

Comments
 (0)