(三) Prometheus 監控思科交換機---Grafana 進行監控效果展現

Grafana Dashboard 進行監控效果展現

  • 由於 Prometheus 的頁面展現效果不是很好,通常就須要配合 Grafana 進行效果展現,Grafana更多地須要在瀏覽器進行操做
  • Prometheus 監控思科交換機文檔完整地址:https://blog.51cto.com/liujingyu/category9.htmlhtml

  • 總體邏輯效果圖
    (三) Prometheus 監控思科交換機---Grafana 進行監控效果展現

Grafana 鏈接 Prometheus 數據源(Data Source)

  • PS:我部署的 Grafana 是通過漢化的 7.2.0 版本(已上傳至阿里雲倉庫,公開版),對新手來講稍微友好一點,固然各位大神若是以爲不安全,或者喜歡用英文版本的,只須要去 Grafana 的官網下載部署最新版本便可。

(三) Prometheus 監控思科交換機---Grafana 進行監控效果展現
(三) Prometheus 監控思科交換機---Grafana 進行監控效果展現

Grafana 添加能夠監控交換機的模板,我我的修改了幾個,更貼合如今的使用環境

  • 採用 Job 作的區分,而不是一個 Job 作的多個 target
  • 一個 Job 對應多個 target 會有問題, Prometheus 會觸發 400 的訪問錯誤,而後咱們的監控項也沒辦法作更進一步的區分

邏輯解釋圖
(三) Prometheus 監控思科交換機---Grafana 進行監控效果展現json

具體模板:瀏覽器

  • 12492 detail
  • 10523 全部接口
  • 12489 SNMP Device Summary
  • 11169 顯示流量,單個交換機

示例圖:
(三) Prometheus 監控思科交換機---Grafana 進行監控效果展現
(三) Prometheus 監控思科交換機---Grafana 進行監控效果展現
(三) Prometheus 監控思科交換機---Grafana 進行監控效果展現
(三) Prometheus 監控思科交換機---Grafana 進行監控效果展現安全

根據 10523 的模板進行的了一下簡單修改,能夠根據 Job 進行區分app

snmp-exporter_rev3.jsonide

{
  "__inputs": [
    {
      "name": "DS_PROMETHEUS",
      "label": "Prometheus",
      "description": "",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "6.2.5"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "singlestat",
      "name": "Singlestat",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "limit": 100,
        "name": "Annotations & Alerts",
        "showIn": 0,
        "type": "dashboard"
      }
    ]
  },
  "description": "Bandwidth in and out of each interface of a SNMP device.流量單位bit/sec",
  "editable": true,
  "gnetId": 10523,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1562921841141,
  "links": [],
  "panels": [
    {
      "cacheTimeout": null,
      "colorBackground": false,
      "colorPostfix": true,
      "colorPrefix": false,
      "colorValue": false,
      "colors": [
        "#299c46",
        "rgba(237, 129, 40, 0.89)",
        "#d44a3a"
      ],
      "datasource": "${DS_PROMETHEUS}",
      "decimals": 1,
      "format": "dtdurations",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": false,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 3,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 70,
      "interval": null,
      "links": [],
      "mappingType": 1,
      "mappingTypes": [
        {
          "name": "value to text",
          "value": 1
        },
        {
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "options": {},
      "postfix": "",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "50%",
      "rangeMaps": [
        {
          "from": "null",
          "text": "N/A",
          "to": "null"
        }
      ],
      "repeat": null,
      "repeatDirection": "h",
      "sparkline": {
        "fillColor": "rgba(31, 118, 189, 0.18)",
        "full": false,
        "lineColor": "rgb(31, 120, 193)",
        "show": false
      },
      "tableColumn": "",
      "targets": [
        {
          "expr": "sysUpTime{instance=\"$Device\",job=\"$Job\"}/100",
          "format": "time_series",
          "instant": true,
          "intervalFactor": 1,
          "refId": "A"
        }
      ],
      "thresholds": "",
      "timeFrom": null,
      "timeShift": null,
      "title": "運行時長",
      "transparent": true,
      "type": "singlestat",
      "valueFontSize": "80%",
      "valueMaps": [
        {
          "op": "=",
          "text": "N/A",
          "value": "null"
        }
      ],
      "valueName": "current"
    },
    {
      "aliasColors": {
        "Out": "#C15C17"
      },
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_PROMETHEUS}",
      "editable": true,
      "error": false,
      "fill": 1,
      "gridPos": {
        "h": 7,
        "w": 6,
        "x": 0,
        "y": 3
      },
      "id": 1,
      "legend": {
        "alignAsTable": false,
        "avg": false,
        "current": true,
        "max": true,
        "min": false,
        "rightSide": false,
        "show": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "connected",
      "options": {},
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "repeat": "Interface",
      "seriesOverrides": [
        {
          "alias": "Out",
          "transform": "negative-Y"
        }
      ],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "irate(ifHCInOctets{job='$Job',instance='$Device',ifName='$Interface'}[5m]) * 8",
          "intervalFactor": 2,
          "legendFormat": "In",
          "refId": "A",
          "step": 60
        },
        {
          "expr": "irate(ifHCOutOctets{job='$Job',instance='$Device',ifName='$Interface'}[5m]) * 8",
          "intervalFactor": 2,
          "legendFormat": "Out",
          "refId": "B",
          "step": 60
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "$Interface",
      "tooltip": {
        "msResolution": false,
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "bps",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    }
  ],
  "schemaVersion": 18,
  "style": "dark",
  "tags": [
    "$Job",
    "交換機"
  ],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_PROMETHEUS}",
        "definition": "",
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "Job",
        "options": [],
        "query": "label_values(ifHCInOctets,  job)",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": null,
        "tags": [],
        "tagsQuery": null,
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_PROMETHEUS}",
        "definition": "",
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "Device",
        "options": [],
        "query": "query_result(sum by (instance)(ifHCInOctets{job=\"$Job\"}))",
        "refresh": 1,
        "regex": ".*instance=\"(.*?)\".*",
        "skipUrlSync": false,
        "sort": 1,
        "tagValuesQuery": null,
        "tags": [],
        "tagsQuery": null,
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_PROMETHEUS}",
        "definition": "",
        "hide": 0,
        "includeAll": true,
        "label": null,
        "multi": false,
        "name": "Interface",
        "options": [],
        "query": "query_result(ifHCInOctets{job=\"$Job\",instance=\"$Device\"})",
        "refresh": 1,
        "regex": ".*ifName=\"(.*?)\",.*",
        "skipUrlSync": false,
        "sort": 5,
        "tagValuesQuery": null,
        "tags": [],
        "tagsQuery": null,
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {
    "nowDelay": "",
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "time_options": [
      "5m",
      "15m",
      "1h",
      "6h",
      "12h",
      "24h",
      "2d",
      "7d",
      "30d"
    ]
  },
  "timezone": "browser",
  "title": "交換機端口詳細信息",
  "uid": "design-by-ljy",
  "version": 4
}
相關文章
相關標籤/搜索