Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
dcdb
dcdb
Commits
c156ea45
Commit
c156ea45
authored
Jun 02, 2020
by
Daniele Tafani
Browse files
Added smoothing to Grafana.
parent
16a940c8
Changes
7
Hide whitespace changes
Inline
Side-by-side
analytics/config/smoothing.conf
View file @
c156ea45
smoother
smt1
{
interval
10000
;
smoother
smt1
{
;
interval
10000
;
minValues
10
;
duplicate
false
;
separator
"-"
;
exclude
"/cpu[0-9]*/"
;
;
output
{
;
;
sensor
avg300
{
;
mqttsuffix
/
avg300
;
range
300000
; }
;
;
sensor
avg3600
{
;
mqttsuffix
/
avg3600
;
range
3600000
; }
; }
;}
;
smoother
grafanaFine
{
;
interval
1000
;
minValues
10
;
duplicate
false
;
separator
"-"
;
exclude
"/cpu[0-9]*/"
;
;
output
{
;
;
sensor
avg10
{
;
mqttsuffix
/
avg10
;
range
10000
; }
;
; }
;}
smoother
grafanaCoarse
{
interval
1000
minValues
10
duplicate
false
separator
"-"
...
...
@@ -8,9 +46,9 @@ smoother smt1 {
output
{
sensor
avg300
{
mqttsuffix
/
avg300
range
300000
}
mqttsuffix
/
avg300
range
300000
}
sensor
avg3600
{
mqttsuffix
/
avg3600
...
...
collectagent/config/collectagent.conf
View file @
c156ea45
...
...
@@ -41,3 +41,13 @@ cassandra {
debugLog
false
}
analytics
{
filter
"/test/"
}
operatorPlugins
{
operatorPlugin
smoothing
{
config
/
Users
/
di34bap
/
Projects
/
dcdb
-
devel
/
dcdb
/
analytics
/
config
/
smoothing
.
conf
}
}
dcdbpusher/config/dcdbpusher.conf
View file @
c156ea45
...
...
@@ -29,22 +29,14 @@ restAPI {
}
plugins
{
plugin
perfevent
{
path
./
config
}
plugin
procfs
{
path
./
config
}
plugin
sysfs
{
path
./
plugin
tester
{
config
}
}
operatorPlugins
{
operatorPlugin
smoothing
{
config
/
Users
/
di34bap
/
Projects
/
dcdb
-
devel
/
dcdb
/
analytics
/
config
/
smoothing
.
conf
}
}
dcdbpusher/config/tester.conf
View file @
c156ea45
...
...
@@ -3,7 +3,7 @@ global {
}
template_group
def1
{
interval
10
00
interval
10
minValues
3
startValue
0
}
...
...
grafana/RestAPI.cpp
View file @
c156ea45
...
...
@@ -206,13 +206,38 @@ void::RestAPI::POST_query(endpointArgs) {
for
(
auto
&
sensorName
:
sensors
)
{
DCDB
::
Sensor
sensor
(
_connection
,
sensorName
);
std
::
list
<
DCDB
::
SensorDataStoreReading
>
results
;
DCDB
::
SensorDataStore
sensorDataStore
(
_connection
);
_sensorConfig
->
getPublicSensorByName
(
ps
,
sensorName
.
c_str
());
if
(
ps
.
interval
&&
!
ps
.
operations
.
empty
())
{
//Estimate the number of requested datapoints, for all sensors' data plotted in the panel. The number is calculated assuming all sensors plotted on the same panel have the same sampling period. If we exceed the maximum, then apply smoothing.
uint64_t
grafanaInterval
=
end
.
getRaw
()
-
start
.
getRaw
();
if
((
int
)((
grafanaInterval
/
ps
.
interval
)
*
sensors
.
size
())
>
MAX_DATAPOINTS
)
{
//Choose a smoother
if
(
grafanaInterval
/
10000000000
<
MAX_DATAPOINTS
&&
ps
.
operations
.
find
(
"-avg10"
)
!=
ps
.
operations
.
end
())
sensorName
+=
"-avg10"
;
else
if
(
grafanaInterval
/
300000000000
<
MAX_DATAPOINTS
&&
ps
.
operations
.
find
(
"-avg300"
)
!=
ps
.
operations
.
end
())
sensorName
+=
"-avg300"
;
else
if
(
ps
.
operations
.
find
(
"-avg3600"
)
!=
ps
.
operations
.
end
())
//Hourly averages should be fine for intervals of years.
sensorName
+=
"-avg3600"
;
}
}
//We need the Sensor ID, since smoothed sensors are not published.
DCDB
::
SensorId
sid
(
sensorName
);
sid
.
setRsvd
(
start
.
getWeekstamp
());
//Shoot the query for this sensor.
std
::
list
<
DCDB
::
SensorDataStoreReading
>
results
;
sensor
.
query
(
results
,
start
,
end
,
DCDB
::
AGGREGATE_NONE
);
sensorDataStore
.
query
(
results
,
sid
,
start
,
end
,
DCDB
::
AGGREGATE_NONE
);
//Format the output for the response to Grafana.
std
::
string
datapoints
=
"["
;
for
(
auto
&
r
:
results
)
...
...
grafana/RestAPI.h
View file @
c156ea45
...
...
@@ -43,6 +43,8 @@
#include <boost/asio.hpp>
#define MAX_DATAPOINTS 100000
/**
* @brief Class providing a RESTful API to Grafana via network (HTTPs only).
*
...
...
grafana/config/grafana.conf
View file @
c156ea45
...
...
@@ -15,9 +15,9 @@ hierarchy {
restAPI
{
address
127
.
0
.
0
.
1
:
8081
certificate
../..
/
deps
/
openssl
-
1
.
1
.
1
c
/
test
/
certs
/
ca
-
cert
.
pem
privateKey
../..
/
deps
/
openssl
-
1
.
1
.
1
c
/
test
/
certs
/
ca
-
key
.
pem
dhFile
../..
/
deps
/
openssl
-
1
.
1
.
1
c
/
crypto
/
dh
/
dh2048
.
pem
certificate
/
Users
/
di34bap
/
Projects
/
dcdb
-
devel
/
deps
/
openssl
-
1
.
1
.
1
c
/
test
/
certs
/
ca
-
cert
.
pem
privateKey
/
Users
/
di34bap
/
Projects
/
dcdb
-
devel
/
deps
/
openssl
-
1
.
1
.
1
c
/
test
/
certs
/
ca
-
key
.
pem
dhFile
/
Users
/
di34bap
/
Projects
/
dcdb
-
devel
/
deps
/
openssl
-
1
.
1
.
1
c
/
crypto
/
dh
/
dh2048
.
pem
user
user1
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment