2017-03-02 102 views
0

不確定這是否可行,但我們正在嘗試使用單一面板在grafana中創建總體狀態儀表板。我們使用模板將主機分組到兩個站點,並使用Icinga2中主機端的丟包值。我們希望單個小組顯示主機的百分比,但有時我們會得到空值。這是我們從面板的JSON:Grafana狀態板

{ 
    "id": 2, 
    "title": "Host Group 2", 
    "span": 6, 
    "type": "singlestat", 
    "targets": [ 
    { 
     "target": "icinga2.$group1.host.hostalive.perfdata.pl.value", 
     "refId": "A", 
     "hide": true 
    }, 
    { 
     "target": "keepLastValue(averageSeries(#A))", 
     "refId": "B", 
     "textEditor": true, 
     "targetFull": "keepLastValue(averageSeries(icinga2.$group1.host.hostalive.perfdata.pl.value), 10000)" 
    } 
    ], 
    "links": [], 
    "datasource": null, 
    "maxDataPoints": "", 
    "interval": null, 
    "cacheTimeout": null, 
    "format": "percent", 
    "prefix": "", 
    "postfix": "", 
    "nullText": null, 
    "valueMaps": [ 
    { 
     "value": "null", 
     "op": "=", 
     "text": "N/A" 
    } 
    ], 
    "mappingTypes": [ 
    { 
     "name": "value to text", 
     "value": 1 
    }, 
    { 
     "name": "range to text", 
     "value": 2 
    } 
    ], 
    "rangeMaps": [ 
    { 
     "from": "null", 
     "to": "null", 
     "text": "N/A" 
    } 
    ], 
    "mappingType": 1, 
    "nullPointMode": "connected", 
    "valueName": "current", 
    "prefixFontSize": "50%", 
    "valueFontSize": "80%", 
    "postfixFontSize": "50%", 
    "thresholds": "50, 100", 
    "colorBackground": true, 
    "colorValue": false, 
    "colors": [ 
    "rgba(50, 172, 45, 0.97)", 
    "rgba(237, 129, 40, 0.89)", 
    "rgba(245, 54, 54, 0.9)" 
    ], 
    "sparkline": { 
    "show": false, 
    "full": false, 
    "lineColor": "rgb(31, 120, 193)", 
    "fillColor": "rgba(31, 118, 189, 0.18)" 
    }, 
    "gauge": { 
    "show": false, 
    "minValue": 0, 
    "maxValue": 100, 
    "thresholdMarkers": true, 
    "thresholdLabels": false 
    } 
} 

輪詢間隔爲主機爲每十幾分鍾,grafana板範圍是「今天」,並設置爲每秒刷新一次。

回答

0

明白了keeplastvalue。

"targets": [ 
    { 
     "hide": true, 
     "refId": "A", 
     "target": "exclude(keepLastValue(icinga2.$group1.host.hostalive.perfdata.pl.value, 144), '1-99')", 
     "textEditor": true 
    }, 
    { 
     "refId": "B", 
     "target": "averageSeries(#A)", 
     "targetFull": "averageSeries(icinga2.$group1.host.hostalive.perfdata.pl.value)", 
     "textEditor": false 
    } 
    ],