воскресенье, 28 декабря 2025 г.

Мониторинг виртуализации Vsphere

Мониторинг для отслеживания DRS и HA, места нахождения ВМ, загрузки CPU гипервизоров и кол-ва ВМ на каждом и их перемещения между гипервизорами.

стек: Zabbix-> Grafana

1) Визуализация "migration path", показывает как за период ВМ меняли гипервизор,  выглядит примерно так:


В заббикс собираем через дискавери "text" на каждую ВМ "Hypervisor name"


Применяем трансформации:



Используем настройки отображения (table) и подсвечиваем красным строку если в ней встречаются одновременно в строке "-abs\d" и "-atd\d: , чтобы работало преобразовываем в String.

  



2) Матрица распределения ВМ по хостам:
выглядит примерно так:


собираем тоже самое, что и в 1)
трансформации и настройки отображения ниже:


3) Вид, где сейчас находится один хост и цветом в каком цоде.
выглядит так: 


собираем тоже что и в 1)
трансформации и настройки:


4) Зависимости между CPU и кол-вом ВМ на едином графике.
выбор гипервизора показывает 2 линии одновременно: CPU/ВМ
Выглядит так:

и так (выбран хост):

собираем 



трансформации и настройки:



Общий код дашборда:

{
  "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": 557,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "datasource": {
        "type": "alexanderzobnin-zabbix-datasource",
        "uid": "cAAtMFJIz"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": "left",
            "cellOptions": {
              "type": "auto"
            },
            "filterable": true,
            "inspect": false,
            "minWidth": 50
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "host"
            },
            "properties": [
              {
                "id": "custom.width",
                "value": 140
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Hypervisor name (uniqueValues)"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Путь миграций , -> текущий сервер крайний справа (Красным ВМ мигрирует между ЦОД-ами)"
              },
              {
                "id": "custom.cellOptions",
                "value": {
                  "type": "color-text"
                }
              },
              {
                "id": "mappings",
                "value": [
                  {
                    "options": {
                      "pattern": "^(?=.*-atd\\d+)(?=.*-abs\\d+).*$",
                      "result": {
                        "color": "dark-red",
                        "index": 0
                      }
                    },
                    "type": "regex"
                  }
                ]
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Hypervisor name (distinctCount)"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Миграций"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Путь миграций , -> текущий сервер крайний справа1"
            },
            "properties": [
              {
                "id": "custom.width",
                "value": 1544
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Миграций"
            },
            "properties": [
              {
                "id": "custom.width",
                "value": 85
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 8,
        "w": 20,
        "x": 0,
        "y": 0
      },
      "id": 7,
      "options": {
        "cellHeight": "sm",
        "footer": {
          "countRows": true,
          "enablePagination": false,
          "fields": "",
          "reducer": [
            "count"
          ],
          "show": true
        },
        "showHeader": true,
        "sortBy": [
          {
            "desc": true,
            "displayName": "Миграций"
          }
        ]
      },
      "pluginVersion": "9.5.21",
      "targets": [
        {
          "application": {
            "filter": ""
          },
          "countTriggersBy": "",
          "datasource": {
            "type": "alexanderzobnin-zabbix-datasource",
            "uid": "cAAtMFJIz"
          },
          "evaltype": "0",
          "functions": [],
          "group": {
            "filter": "Virtual machines PROD"
          },
          "host": {
            "filter": "/.*/"
          },
          "itServiceFilter": "",
          "item": {
            "filter": "Hypervisor name"
          },
          "itemTag": {
            "filter": "Application: General"
          },
          "macro": {
            "filter": ""
          },
          "options": {
            "count": false,
            "disableDataAlignment": false,
            "showDisabledItems": false,
            "skipEmptyValues": false,
            "useTrends": "default",
            "useZabbixValueMapping": false
          },
          "proxy": {
            "filter": ""
          },
          "queryType": "2",
          "refId": "A",
          "resultFormat": "time_series",
          "schema": 12,
          "slaFilter": "",
          "slaInterval": "none",
          "slaProperty": "sla",
          "table": {
            "skipEmptyValues": false
          },
          "tags": {
            "filter": ""
          },
          "textFilter": "",
          "trigger": {
            "filter": ""
          },
          "useCaptureGroups": false
        }
      ],
      "title": "PROD Migrations path",
      "transformations": [
        {
          "id": "joinByLabels",
          "options": {
            "join": [
              "host"
            ],
            "value": "item"
          }
        },
        {
          "id": "filterByValue",
          "options": {
            "filters": [
              {
                "config": {
                  "id": "isNull",
                  "options": {}
                },
                "fieldName": "Hypervisor name"
              }
            ],
            "match": "any",
            "type": "exclude"
          }
        },
        {
          "id": "groupBy",
          "options": {
            "fields": {
              "Hypervisor name": {
                "aggregations": [
                  "distinctCount",
                  "uniqueValues"
                ],
                "operation": "aggregate"
              },
              "host": {
                "aggregations": [],
                "operation": "groupby"
              }
            }
          }
        },
        {
          "id": "convertFieldType",
          "options": {
            "conversions": [
              {
                "destinationType": "enum",
                "targetField": "Hypervisor name (allValues)"
              },
              {
                "destinationType": "string",
                "targetField": "Hypervisor name (uniqueValues)"
              }
            ],
            "fields": {}
          }
        }
      ],
      "type": "table"
    },
    {
      "datasource": {
        "type": "alexanderzobnin-zabbix-datasource",
        "uid": "cAAtMFJIz"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": "left",
            "cellOptions": {
              "type": "color-text"
            },
            "filterable": true,
            "inspect": true,
            "minWidth": 50
          },
          "mappings": [
            {
              "options": {
                "pattern": "/(^.+\\-atd.+$)/",
                "result": {
                  "color": "blue",
                  "index": 0,
                  "text": "$1"
                }
              },
              "type": "regex"
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "host"
            },
            "properties": [
              {
                "id": "custom.width",
                "value": 123
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Hypervisor name (lastNotNull)"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Last host (blue is RCOD)"
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 8,
        "w": 4,
        "x": 20,
        "y": 0
      },
      "id": 11,
      "options": {
        "cellHeight": "sm",
        "footer": {
          "countRows": true,
          "enablePagination": false,
          "fields": "",
          "reducer": [
            "count"
          ],
          "show": true
        },
        "showHeader": true,
        "sortBy": [
          {
            "desc": false,
            "displayName": "host"
          }
        ]
      },
      "pluginVersion": "9.5.21",
      "targets": [
        {
          "application": {
            "filter": ""
          },
          "countTriggersBy": "",
          "datasource": {
            "type": "alexanderzobnin-zabbix-datasource",
            "uid": "cAAtMFJIz"
          },
          "evaltype": "0",
          "functions": [],
          "group": {
            "filter": "Virtual machines PROD"
          },
          "host": {
            "filter": "/.*/"
          },
          "itServiceFilter": "",
          "item": {
            "filter": "Hypervisor name"
          },
          "itemTag": {
            "filter": "Application: General"
          },
          "macro": {
            "filter": ""
          },
          "options": {
            "count": false,
            "disableDataAlignment": false,
            "showDisabledItems": false,
            "skipEmptyValues": false,
            "useTrends": "default",
            "useZabbixValueMapping": false
          },
          "proxy": {
            "filter": ""
          },
          "queryType": "2",
          "refId": "A",
          "resultFormat": "time_series",
          "schema": 12,
          "slaFilter": "",
          "slaInterval": "none",
          "slaProperty": "sla",
          "table": {
            "skipEmptyValues": false
          },
          "tags": {
            "filter": ""
          },
          "textFilter": "",
          "trigger": {
            "filter": ""
          },
          "useCaptureGroups": false
        }
      ],
      "timeFrom": "10m",
      "title": "PROD VM by ESXI host",
      "transformations": [
        {
          "id": "joinByLabels",
          "options": {
            "join": [
              "host"
            ],
            "value": "item"
          }
        },
        {
          "id": "filterByValue",
          "options": {
            "filters": [
              {
                "config": {
                  "id": "isNull",
                  "options": {}
                },
                "fieldName": "Hypervisor name"
              }
            ],
            "match": "any",
            "type": "exclude"
          }
        },
        {
          "id": "groupBy",
          "options": {
            "fields": {
              "Hypervisor name": {
                "aggregations": [
                  "lastNotNull"
                ],
                "operation": "aggregate"
              },
              "host": {
                "aggregations": [],
                "operation": "groupby"
              }
            }
          }
        },
        {
          "id": "convertFieldType",
          "options": {
            "conversions": [
              {
                "destinationType": "enum",
                "targetField": "Hypervisor name (allValues)"
              }
            ],
            "fields": {}
          }
        }
      ],
      "type": "table"
    },
    {
      "datasource": {
        "type": "alexanderzobnin-zabbix-datasource",
        "uid": "cAAtMFJIz"
      },
      "fieldConfig": {
        "defaults": {
          "custom": {
            "align": "auto",
            "cellOptions": {
              "type": "auto"
            },
            "filterable": true,
            "inspect": false
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 24,
        "x": 0,
        "y": 8
      },
      "id": 6,
      "interval": "5m",
      "options": {
        "cellHeight": "sm",
        "footer": {
          "countRows": true,
          "fields": "",
          "reducer": [
            "count"
          ],
          "show": true
        },
        "showHeader": true,
        "sortBy": []
      },
      "pluginVersion": "9.5.21",
      "targets": [
        {
          "application": {
            "filter": ""
          },
          "countTriggersBy": "",
          "datasource": {
            "type": "alexanderzobnin-zabbix-datasource",
            "uid": "cAAtMFJIz"
          },
          "evaltype": "0",
          "functions": [],
          "group": {
            "filter": "Virtual machines PROD"
          },
          "host": {
            "filter": "/.*/"
          },
          "itServiceFilter": "",
          "item": {
            "filter": "Hypervisor name"
          },
          "itemTag": {
            "filter": "Application: General"
          },
          "macro": {
            "filter": ""
          },
          "options": {
            "count": false,
            "disableDataAlignment": false,
            "showDisabledItems": true,
            "skipEmptyValues": false,
            "useTrends": "default",
            "useZabbixValueMapping": false
          },
          "proxy": {
            "filter": ""
          },
          "queryType": "2",
          "refId": "A",
          "resultFormat": "time_series",
          "schema": 12,
          "slaFilter": "",
          "slaInterval": "none",
          "slaProperty": "sla",
          "table": {
            "skipEmptyValues": false
          },
          "tags": {
            "filter": ""
          },
          "textFilter": "",
          "trigger": {
            "filter": ""
          },
          "useCaptureGroups": false
        }
      ],
      "timeFrom": "10m",
      "title": "PROD VMs by Esxi Hosts",
      "transformations": [
        {
          "id": "joinByLabels",
          "options": {
            "join": [
              "host"
            ],
            "value": "item"
          }
        },
        {
          "id": "filterByValue",
          "options": {
            "filters": [
              {
                "config": {
                  "id": "isNull",
                  "options": {}
                },
                "fieldName": "Hypervisor name"
              }
            ],
            "match": "all",
            "type": "exclude"
          }
        },
        {
          "disabled": true,
          "id": "filterFieldsByName",
          "options": {
            "include": {
              "names": [
                "Hypervisor name",
                "host"
              ]
            }
          }
        },
        {
          "id": "joinByField",
          "options": {
            "byField": "Hypervisor name",
            "mode": "inner"
          }
        },
        {
          "id": "groupingToMatrix",
          "options": {
            "columnField": "Hypervisor name",
            "emptyValue": "null",
            "rowField": "host",
            "valueField": "host"
          }
        }
      ],
      "type": "table"
    },
    {
      "datasource": {
        "type": "alexanderzobnin-zabbix-datasource",
        "uid": "cAAtMFJIz"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "axisSoftMax": 100,
            "axisSoftMin": 0,
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineStyle": {
              "fill": "solid"
            },
            "lineWidth": 1,
            "pointSize": 1,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "percentage",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 16,
        "w": 24,
        "x": 0,
        "y": 17
      },
      "id": 9,
      "interval": "5",
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true,
          "sortBy": "Last *",
          "sortDesc": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "pluginVersion": "9.5.21",
      "targets": [
        {
          "application": {
            "filter": ""
          },
          "countTriggersBy": "",
          "datasource": {
            "type": "alexanderzobnin-zabbix-datasource",
            "uid": "cAAtMFJIz"
          },
          "evaltype": "0",
          "functions": [],
          "group": {
            "filter": "ddd vCenter Cluster PROD"
          },
          "host": {
            "filter": "/.*/"
          },
          "item": {
            "filter": "CPU usage in percent"
          },
          "itemTag": {
            "filter": ""
          },
          "macro": {
            "filter": ""
          },
          "options": {
            "count": false,
            "disableDataAlignment": false,
            "showDisabledItems": false,
            "skipEmptyValues": false,
            "useTrends": "default",
            "useZabbixValueMapping": false
          },
          "proxy": {
            "filter": ""
          },
          "queryType": "0",
          "refId": "A",
          "resultFormat": "time_series",
          "schema": 12,
          "table": {
            "skipEmptyValues": false
          },
          "tags": {
            "filter": ""
          },
          "textFilter": "",
          "trigger": {
            "filter": ""
          }
        },
        {
          "application": {
            "filter": ""
          },
          "countTriggersBy": "",
          "datasource": {
            "type": "alexanderzobnin-zabbix-datasource",
            "uid": "cAAtMFJIz"
          },
          "evaltype": "0",
          "functions": [],
          "group": {
            "filter": "ddd vCenter Cluster PROD"
          },
          "hide": false,
          "host": {
            "filter": "/.*/"
          },
          "item": {
            "filter": "Number of guest VMs"
          },
          "itemTag": {
            "filter": ""
          },
          "macro": {
            "filter": ""
          },
          "options": {
            "count": false,
            "disableDataAlignment": false,
            "showDisabledItems": false,
            "skipEmptyValues": false,
            "useTrends": "default",
            "useZabbixValueMapping": false
          },
          "proxy": {
            "filter": ""
          },
          "queryType": "0",
          "refId": "B",
          "resultFormat": "time_series",
          "schema": 12,
          "table": {
            "skipEmptyValues": false
          },
          "tags": {
            "filter": ""
          },
          "textFilter": "",
          "trigger": {
            "filter": ""
          }
        }
      ],
      "title": "PROD CPUs and VMs count",
      "transformations": [
        {
          "id": "renameByRegex",
          "options": {
            "regex": "(srv.*\\:).*",
            "renamePattern": "$1ВМ_или_%"
          }
        }
      ],
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "alexanderzobnin-zabbix-datasource",
        "uid": "cAAtMFJIz"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "smooth",
            "lineStyle": {
              "fill": "solid"
            },
            "lineWidth": 1,
            "pointSize": 1,
            "scaleDistribution": {
              "log": 10,
              "type": "log"
            },
            "showPoints": "auto",
            "spanNulls": true,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 0,
        "y": 33
      },
      "id": 1,
      "interval": "5",
      "options": {
        "legend": {
          "calcs": [
            "mean"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true,
          "sortBy": "Mean",
          "sortDesc": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "pluginVersion": "9.5.21",
      "targets": [
        {
          "application": {
            "filter": ""
          },
          "countTriggersBy": "",
          "datasource": {
            "type": "alexanderzobnin-zabbix-datasource",
            "uid": "cAAtMFJIz"
          },
          "evaltype": "0",
          "functions": [],
          "group": {
            "filter": "ddd vCenter Cluster PROD"
          },
          "host": {
            "filter": "/.*/"
          },
          "item": {
            "filter": "Number of guest VMs"
          },
          "itemTag": {
            "filter": ""
          },
          "macro": {
            "filter": ""
          },
          "options": {
            "count": false,
            "disableDataAlignment": false,
            "showDisabledItems": false,
            "skipEmptyValues": false,
            "useTrends": "default",
            "useZabbixValueMapping": false
          },
          "proxy": {
            "filter": ""
          },
          "queryType": "0",
          "refId": "A",
          "resultFormat": "time_series",
          "schema": 12,
          "table": {
            "skipEmptyValues": false
          },
          "tags": {
            "filter": ""
          },
          "textFilter": "",
          "trigger": {
            "filter": ""
          }
        }
      ],
      "title": "PROD VMs",
      "transformations": [
        {
          "id": "calculateField",
          "options": {}
        }
      ],
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "alexanderzobnin-zabbix-datasource",
        "uid": "cAAtMFJIz"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "axisSoftMax": 100,
            "axisSoftMin": 0,
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineStyle": {
              "fill": "solid"
            },
            "lineWidth": 1,
            "pointSize": 1,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "dashed"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "percentage",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 12,
        "y": 33
      },
      "id": 10,
      "interval": "5",
      "options": {
        "legend": {
          "calcs": [
            "mean"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true,
          "sortBy": "Mean",
          "sortDesc": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "pluginVersion": "9.5.21",
      "targets": [
        {
          "application": {
            "filter": ""
          },
          "countTriggersBy": "",
          "datasource": {
            "type": "alexanderzobnin-zabbix-datasource",
            "uid": "cAAtMFJIz"
          },
          "evaltype": "0",
          "functions": [],
          "group": {
            "filter": "ddd vCenter Cluster PROD"
          },
          "host": {
            "filter": "/.*/"
          },
          "item": {
            "filter": "CPU usage in percent"
          },
          "itemTag": {
            "filter": ""
          },
          "macro": {
            "filter": ""
          },
          "options": {
            "count": false,
            "disableDataAlignment": false,
            "showDisabledItems": false,
            "skipEmptyValues": false,
            "useTrends": "default",
            "useZabbixValueMapping": false
          },
          "proxy": {
            "filter": ""
          },
          "queryType": "0",
          "refId": "A",
          "resultFormat": "time_series",
          "schema": 12,
          "table": {
            "skipEmptyValues": false
          },
          "tags": {
            "filter": ""
          },
          "textFilter": "",
          "trigger": {
            "filter": ""
          }
        }
      ],
      "title": "PROD CPUs",
      "transformations": [
        {
          "id": "calculateField",
          "options": {
            "alias": "Средняя загрузка",
            "binary": {
              "left": "Time",
              "reducer": "sum",
              "right": "Time"
            },
            "mode": "reduceRow",
            "reduce": {
              "reducer": "mean"
            },
            "replaceFields": false
          }
        },
        {
          "id": "renameByRegex",
          "options": {
            "regex": "(srv.*\\:).*",
            "renamePattern": "$1 Загр. ЦПУ"
          }
        }
      ],
      "type": "timeseries"
    }
  ],
  "refresh": "5m",
  "schemaVersion": 38,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "Vsphere VM amount  PROD  ddd-win only",
  "uid": "d8078b3e-62fc-430d-9def-d3d1df8f768f",
  "version": 24,
  "weekStart": ""
}

Комментариев нет:

Отправить комментарий