Grafana状态委员会

时间:2017-03-02 14:42:02

标签: json grafana

不确定这是否可行,但我们正在尝试使用singlestat面板在grafana中创建整体状态仪表板。我们使用模板将我们的主机分组到两个站点,并使用来自Icinga2中的hostalive的丢包值。我们希望singlestat面板显示主机的百分比,但有时我们会得到空值。这是我们小组的JSON:

{
  "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
  }
}

主机的轮询间隔是每十分钟一次,格拉夫纳板范围是“今天”并设置为每秒刷新一次。

1 个答案:

答案 0 :(得分: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
    }
  ],