13#ifndef RTCTK_COMPONENTFRAMEWORK_TELEGRAFADAPTER_HPP
14#define RTCTK_COMPONENTFRAMEWORK_TELEGRAFADAPTER_HPP
18#include <boost/asio.hpp>
19#include <mal/utility/Uri.hpp>
25using FieldValue = std::variant<int64_t, uint64_t, float, double, bool, std::string>;
50 std::map<std::string, std::string>
tags;
57 std::map<std::string, FieldValue>
fields;
65 std::optional<std::chrono::nanoseconds>
timestamp = std::nullopt;
83std::vector<InfluxPoint>
85 const std::string& states_str,
86 const std::map<std::string, std::string>& base_tags);
110 explicit TelegrafAdapter(
const elt::mal::Uri& uri, std::string component);
126 std::map<std::string, std::string>
BaseTags();
137 void SendPoints(
const std::vector<InfluxPoint>& points);
140 static const std::size_t MTU = 1500;
142 boost::asio::io_service m_io_service;
143 boost::asio::ip::udp::socket m_socket;
144 boost::asio::ip::udp::endpoint m_endpoint;
147 std::string m_component;
149 log4cplus::Logger m_logger;
150 bool m_enabled =
true;
std::map< std::string, std::string > BaseTags()
Constructs and returns a map of base tags for InfluxDB.
Definition telegrafAdapter.cpp:78
TelegrafAdapter(const TelegrafAdapter &)=delete
This class cannot be copy constructed.
TelegrafAdapter()=delete
Do not allow construction with no arguments.
void SendPoints(const std::vector< InfluxPoint > &points)
Sends vector of points to Telegraf using UDP and Influx line protocol.
Definition telegrafAdapter.cpp:86
TelegrafAdapter & operator=(const TelegrafAdapter &)=delete
This class cannot be copy assigned.
~TelegrafAdapter()=default
Logging Support Library based on log4cplus.
Definition commandReplier.cpp:22
std::vector< InfluxPoint > ParseStateToInfluxPoints(const std::string &component_name, const std::string &states_str, const std::map< std::string, std::string > &base_tags)
Definition telegrafAdapter.cpp:213
std::variant< int64_t, uint64_t, float, double, bool, std::string > FieldValue
Definition telegrafAdapter.hpp:25
Represents a single data point for InfluxDB.
Definition telegrafAdapter.hpp:37
std::string ToLineProtocol() const
Encodes data to InfluxDB line protocol format.
Definition telegrafAdapter.cpp:128
std::optional< std::chrono::nanoseconds > timestamp
Optional timestamp of the measurement.
Definition telegrafAdapter.hpp:65
std::map< std::string, std::string > tags
Tags are indexed key–value pairs used for efficient filtering.
Definition telegrafAdapter.hpp:50
std::string table_name
Name of the table.
Definition telegrafAdapter.hpp:43
std::map< std::string, FieldValue > fields
Fields hold the measured data values.
Definition telegrafAdapter.hpp:57