Grafana dashboard: DHCP messages
Description: Observe amount of discover/offer/request/ack/nak/release/inform/decline messages pass your DHCP interface.

Use this dashboard in combination with dhcpmessages_exporter

https://github.com/mrizvic/dhcpmessage_exporter

It listens (pcap) on specific network interfaces for dhcp traffic (bpf filter: udp and port 67) and counts following DHCP messages:

    discover
    offer
    request
    ack
    nak
    inform
    release
    decline

Stats are available over HTTP in format suitable for prometheus:

```
dhcp-lab$ curl -s localhost:8067/metrics |grep dhcp
# HELP dhcp_messages_processed_total The total number of processed DHCP messagess
# TYPE dhcp_messages_processed_total counter
dhcp_messages_processed_total{interface="ens192",type="ack"} 0
dhcp_messages_processed_total{interface="ens192",type="decline"} 0
dhcp_messages_processed_total{interface="ens192",type="discover"} 0
dhcp_messages_processed_total{interface="ens192",type="inform"} 0
dhcp_messages_processed_total{interface="ens192",type="nak"} 0
dhcp_messages_processed_total{interface="ens192",type="offer"} 0
dhcp_messages_processed_total{interface="ens192",type="release"} 0
dhcp_messages_processed_total{interface="ens192",type="request"} 0
dhcp_messages_processed_total{interface="ens193",type="ack"} 2
dhcp_messages_processed_total{interface="ens193",type="decline"} 0
dhcp_messages_processed_total{interface="ens193",type="discover"} 12
dhcp_messages_processed_total{interface="ens193",type="inform"} 0
dhcp_messages_processed_total{interface="ens193",type="nak"} 0
dhcp_messages_processed_total{interface="ens193",type="offer"} 0
dhcp_messages_processed_total{interface="ens193",type="release"} 12
dhcp_messages_processed_total{interface="ens193",type="request"} 14
dhcp_messages_processed_total{interface="ens224",type="ack"} 1
dhcp_messages_processed_total{interface="ens224",type="decline"} 0
dhcp_messages_processed_total{interface="ens224",type="discover"} 0
dhcp_messages_processed_total{interface="ens224",type="inform"} 0
dhcp_messages_processed_total{interface="ens224",type="nak"} 0
dhcp_messages_processed_total{interface="ens224",type="offer"} 0
dhcp_messages_processed_total{interface="ens224",type="release"} 0
dhcp_messages_processed_total{interface="ens224",type="request"} 1
dhcp_messages_processed_total{interface="ens256",type="ack"} 14
dhcp_messages_processed_total{interface="ens256",type="decline"} 0
dhcp_messages_processed_total{interface="ens256",type="discover"} 3
dhcp_messages_processed_total{interface="ens256",type="inform"} 0
dhcp_messages_processed_total{interface="ens256",type="nak"} 0
dhcp_messages_processed_total{interface="ens256",type="offer"} 9
dhcp_messages_processed_total{interface="ens256",type="release"} 0
dhcp_messages_processed_total{interface="ens256",type="request"} 4
# HELP packets_captured_total The total number of packets that passed bpf filter
# TYPE packets_captured_total counter
packets_captured_total{interface="ens192",type="all"} 0
packets_captured_total{interface="ens193",type="all"} 40
packets_captured_total{interface="ens224",type="all"} 2
packets_captured_total{interface="ens256",type="all"} 30
```

{
  "__inputs": [
    {
      "name": "DS_PROMETHEUS",
      "label": "Prometheus",
      "description": "",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "7.3.4"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "1.0.0"
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "gnetId": 13513,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1607117764213,
  "links": [],
  "panels": [
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_PROMETHEUS}",
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 9,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "hiddenSeries": false,
      "id": 4,
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": true,
        "max": true,
        "min": true,
        "rightSide": true,
        "show": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "7.3.4",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "sum by (type) (increase(dhcp_messages_processed_total{instance=\"$instance\"}[60s])/60)",
          "instant": false,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "{{ type }}",
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "DHCP messages - all interfaces",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "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
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_PROMETHEUS}",
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 9,
        "w": 24,
        "x": 0,
        "y": 9
      },
      "hiddenSeries": false,
      "id": 5,
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": true,
        "max": true,
        "min": true,
        "rightSide": true,
        "show": true,
        "total": false,
        "values": true
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "7.3.4",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "sum by (type) (increase(dhcp_messages_processed_total{instance=\"$instance\",interface=~\"$interface\"}[60s])/60)",
          "instant": false,
          "interval": "",
          "intervalFactor": 1,
          "legendFormat": "{{ type }}",
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "DHCP messages - specific interface",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "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
      }
    }
  ],
  "refresh": "15m",
  "schemaVersion": 26,
  "style": "dark",
  "tags": [
    "dhcp"
  ],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_PROMETHEUS}",
        "definition": "label_values(dhcp_messages_processed_total, instance)",
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": "Instance",
        "multi": false,
        "name": "instance",
        "options": [],
        "query": "label_values(dhcp_messages_processed_total, instance)",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 1,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_PROMETHEUS}",
        "definition": "label_values(dhcp_messages_processed_total{instance=\"$instance\"}, interface)",
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": "Interface",
        "multi": false,
        "name": "interface",
        "options": [],
        "query": "label_values(dhcp_messages_processed_total{instance=\"$instance\"}, interface)",
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "now-1h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "DHCP messages",
  "uid": "HRDTO1oGk",
  "version": 4,
  "description": "Observe amount of discover/offer/request/ack/nak/release/inform/decline messages pass your DHCP interface."
}