This repository has been archived by the owner on Mar 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Specific tables case
Collignon-Ducret Rémi edited this page Mar 20, 2019
·
2 revisions
Table panel accept a custom data format to easily build the table of your dream. To do it, you have to let in the stack a unique element with the structure below:
{
'columns' [
{
'text' 'columnA'
'type' 'number'
'sort' true
'desc' true
}
{
'text' 'columnA'
'type' 'number'
}
]
'rows' [
[ 10 10 ]
[ 100 200 ]
]
}
This script will result into:
columnA | columnA |
---|---|
10 | 10 |
100 | 200 |
Building a table to count the number of server in a datacenter
[ 'token' 'my.series' { 'datacenter' '~.*' } ] FIND
{} SWAP
<% // Itere on each time series
LABELS 'datacenter' GET 'datacenter' STORE // get the series datacenter label value
<% $datacenter CONTAINSKEY %> // if the result map contains a key with the datacenter value
<%
DUP $datacenter GET 1 + $datacenter PUT // add 1 to the map
%>
<%
1 $datacenter PUT // init the datacenter with value 1
%>
IFTE
%> FOREACH 'data' STORE
{
'columns' [
{
'text' 'Datacenter'
'type' 'string'
}
{
'text' 'server count'
'type' 'number'
'sort' true
'desc' false
}
]
'rows' [
$data KEYLIST // Get the list of object keys
$data VALUELIST // get the list of object values
] ZIP // build an array with [ [ key1 value 1] [ key2 value2 ] ]
}