Monitoring  3.3.4
O2 Monitoring library
InfluxDB.h
Go to the documentation of this file.
1 // Copyright CERN and copyright holders of ALICE O2. This software is
2 // distributed under the terms of the GNU General Public License v3 (GPL
3 // Version 3), copied verbatim in the file "COPYING".
4 //
5 // See http://alice-o2.web.cern.ch/license for full licensing information.
6 //
7 // In applying this license CERN does not waive the privileges and immunities
8 // granted to it by virtue of its status as an Intergovernmental Organization
9 // or submit itself to any jurisdiction.
10 
15 
16 #ifndef ALICEO2_MONITORING_BACKENDS_INFLUXDB_H
17 #define ALICEO2_MONITORING_BACKENDS_INFLUXDB_H
18 
19 #include "Monitoring/Backend.h"
20 #include "../Transports/TransportInterface.h"
21 #include "../MonLogger.h"
22 #include <chrono>
23 #include <string>
24 
25 namespace o2
26 {
28 namespace monitoring
29 {
31 namespace backends
32 {
33 
37 class InfluxDB final : public Backend
38 {
39  public:
42  InfluxDB(std::unique_ptr<transports::TransportInterface> transport);
43 
45  ~InfluxDB() = default;
46 
50  inline unsigned long convertTimestamp(const std::chrono::time_point<std::chrono::system_clock>& timestamp);
51 
54  void send(const Metric& metric) override;
55 
58  void send(std::vector<Metric>&& metrics) override;
59 
63  void addGlobalTag(std::string_view name, std::string_view value) override;
64 
67  std::string toInfluxLineProtocol(const Metric& metric);
68 
69  private:
70  std::unique_ptr<transports::TransportInterface> mTransport;
71  std::string tagSet;
72 
75  void escape(std::string& escaped);
76 };
77 
78 } // namespace backends
79 } // namespace monitoring
80 } // namespace o2
81 
82 #endif // ALICEO2_MONITORING_BACKENDS_INFLUXDB_H
~InfluxDB()=default
Default destructor.
void addGlobalTag(std::string_view name, std::string_view value) override
Definition: InfluxDB.cxx:114
Definition: Backend.h:23
unsigned long convertTimestamp(const std::chrono::time_point< std::chrono::system_clock > &timestamp)
Definition: InfluxDB.cxx:45
std::string toInfluxLineProtocol(const Metric &metric)
Definition: InfluxDB.cxx:84
Backend pure virtual interface.
Definition: Backend.h:33
Backend that sends metrics to InfluxDB time-series databse.
Definition: InfluxDB.h:37
Represents a metric including value, type of the value, name, timestamp and tags. ...
Definition: Metric.h:37
InfluxDB(std::unique_ptr< transports::TransportInterface > transport)
Definition: InfluxDB.cxx:39
void send(const Metric &metric) override
Definition: InfluxDB.cxx:76