Overte C++ Documentation
DomainServerExporter.h
1 //
2 // DomainServerExporter.h
3 // domain-server/src
4 //
5 // Created by Dale Glass on 3 Apr 2020.
6 // Copyright 2020 Dale Glass
7 //
8 // Prometheus exporter
9 //
10 // Distributed under the Apache License, Version 2.0.
11 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
12 //
13 
14 #ifndef DOMAINSERVEREXPORTER_H
15 #define DOMAINSERVEREXPORTER_H
16 
17 #include <QObject>
18 #include "HTTPManager.h"
19 #include "Node.h"
20 #include <QTextStream>
21 #include <QJsonObject>
22 #include <QRegularExpression>
23 #include <QHash>
24 
25 
26 
34 class DomainServerExporter : public HTTPRequestHandler
35 {
36 public:
37  typedef enum {
38  Untyped, /* Works the same as Gauge, with the difference of signalling that the actual type is unknown */
39  Counter, /* Value only goes up. Eg, number of packets received */
40  Gauge, /* Current numerical value that can go up or down. Current temperature, memory usage, etc */
41  Histogram, /* Samples sorted in buckets gathered over time */
42  Summary
43  } MetricType;
44 
46  ~DomainServerExporter() = default;
47  bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false) override;
48 
49 private:
50  QString escapeName(const QString &name);
51  void generateMetricsForNode(QTextStream& stream, const SharedNodePointer& node);
52  void generateMetricsFromJson(QTextStream& stream, QString originalPath, QString path, QHash<QString, QString> labels, const QJsonObject& obj);
53 };
54 
55 #endif // DOMAINSERVEREXPORTER_H
Prometheus exporter for domain stats.
Definition: DomainServerExporter.h:35
Handles a single HTTP connection.
Definition: HTTPConnection.h:43