

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 設定 Grafana for SiteWise Edge
<a name="windows-grafana"></a>

 Grafana® 可讓您為工業資料建立本機即時監控儀表板。透過視覺化儲存在 InfluxDB® 中的資料，您可以為操作員提供設備效能、程序效率和潛在問題的即時洞見。在邊緣的這種可見性對於時間敏感的操作和在網路中斷期間維持持續性至關重要。

## 設定資料來源
<a name="windows-grafana-data-source-config"></a>

將 Grafana 連接到 InfluxDB 資料庫會為您的工業資料建立強大的視覺化層。此連線可啟用即時監控儀表板，讓運算子在沒有雲端相依性的情況下做出明智的決策。

1. 在瀏覽器中導覽至 [http://127.0.0.1:3000](http://127.0.0.1:3000)，在本機存取您的 Grafana 執行個體。如果需要啟用 TLS，您可以參考 *Grafana Labs 文件*中的[設定 Grafana HTTPS 以取得安全 Web 流量](https://grafana.com/docs/grafana/latest/setup-grafana/set-up-https/)。

1. 新增 InfluxDB 資料來源，指向 Node-RED 寫入資料的 InfluxDB 時間序列儲存貯體。例如 `WindFarmData`。此連線會在儲存的資料與視覺化平台之間建立連結。

1. 如需詳細說明，請參閱 *Grafana Labs 文件*中的[設定 InfluxDB 資料來源](https://grafana.com/docs/grafana/latest/datasources/influxdb/configure-influxdb-data-source/)。

### 為 SiteWise Edge 資料建立 Grafana 儀表板
<a name="windows-grafana-create-dashboard"></a>

建立儀表板是建置本機監控解決方案的最後一步。儀表板提供工業資料的視覺化呈現，讓您更輕鬆地一目了然地識別趨勢、異常和潛在問題。
+ 依照指南建立儀表板。如需詳細資訊，請參閱 *Grafana Labs 文件*中的[建置您的第一個儀表板](https://grafana.com/docs/grafana/latest/getting-started/build-first-dashboard/)。此範本假設您的儲存貯體已命名，`WindFarmData`且測量結果為 `TurbineData`。

  您也可以透過匯入提供的範例儀表板範本來使用快速入門指南，快速為 Node-RED 在上一節中產生的資料建立具有時間序列圖的儀表板。此範本提供一個起點，您可以自訂以滿足您的特定監控需求。

  ```
  {
    "__inputs": [
      {
        "name": "DS_WINDFARM-DEMO",
        "label": "windfarm-demo",
        "description": "",
        "type": "datasource",
        "pluginId": "influxdb",
        "pluginName": "InfluxDB"
      }
    ],
    "__elements": {},
    "__requires": [
      {
        "type": "grafana",
        "id": "grafana",
        "name": "Grafana",
        "version": "11.6.0-pre"
      },
      {
        "type": "datasource",
        "id": "influxdb",
        "name": "InfluxDB",
        "version": "1.0.0"
      },
      {
        "type": "panel",
        "id": "timeseries",
        "name": "Time series",
        "version": ""
      }
    ],
    "annotations": {
      "list": [
        {
          "builtIn": 1,
          "datasource": {
            "type": "grafana",
            "uid": "-- Grafana --"
          },
          "enable": true,
          "hide": true,
          "iconColor": "rgba(0, 211, 255, 1)",
          "name": "Annotations & Alerts",
          "type": "dashboard"
        }
      ]
    },
    "editable": true,
    "fiscalYearStartMonth": 0,
    "graphTooltip": 0,
    "id": null,
    "links": [],
    "panels": [
      {
        "datasource": {
          "type": "influxdb",
          "uid": "${DS_WINDFARM-DEMO}"
        },
        "fieldConfig": {
          "defaults": {
            "color": {
              "mode": "palette-classic"
            },
            "custom": {
              "axisBorderShow": false,
              "axisCenteredZero": false,
              "axisColorMode": "text",
              "axisLabel": "",
              "axisPlacement": "auto",
              "barAlignment": 0,
              "barWidthFactor": 0.6,
              "drawStyle": "line",
              "fillOpacity": 0,
              "gradientMode": "none",
              "hideFrom": {
                "legend": false,
                "tooltip": false,
                "viz": false
              },
              "insertNulls": false,
              "lineInterpolation": "linear",
              "lineWidth": 1,
              "pointSize": 5,
              "scaleDistribution": {
                "type": "linear"
              },
              "showPoints": "auto",
              "spanNulls": false,
              "stacking": {
                "group": "A",
                "mode": "none"
              },
              "thresholdsStyle": {
                "mode": "off"
              }
            },
            "mappings": [],
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {
                  "color": "green"
                },
                {
                  "color": "red",
                  "value": 80
                }
              ]
            }
          },
          "overrides": []
        },
        "gridPos": {
          "h": 8,
          "w": 12,
          "x": 0,
          "y": 0
        },
        "id": 1,
        "options": {
          "legend": {
            "calcs": [],
            "displayMode": "list",
            "placement": "bottom",
            "showLegend": true
          },
          "tooltip": {
            "hideZeros": false,
            "mode": "single",
            "sort": "none"
          }
        },
        "pluginVersion": "11.6.0-pre",
        "targets": [
          {
            "datasource": {
              "type": "influxdb",
              "uid": "${DS_WINDFARM-DEMO}"
            },
            "query": "from(bucket: \"{{WindFarmData}}\")\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n  |> filter(fn: (r) => r[\"_measurement\"] == \"{{TurbineData}}\")\n  |> filter(fn: (r) => r[\"_field\"] == \"value\")\n  |> filter(fn: (r) => r[\"name\"] == \"/Renton/WindFarm/Turbine/WindSpeed\")\n  |> filter(fn: (r) => r[\"quality\"] == \"GOOD\")\n  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n  |> yield(name: \"mean\")",
            "refId": "A"
          }
        ],
        "title": "Panel Title",
        "type": "timeseries"
      }
    ],
    "schemaVersion": 41,
    "tags": [],
    "templating": {
      "list": []
    },
    "time": {
      "from": "now-6h",
      "to": "now"
    },
    "timepicker": {},
    "timezone": "browser",
    "title": "demo dashboard",
    "uid": "fejc0t08o6d4wb",
    "version": 1,
    "weekStart": ""
  }
  ```