Grafana dashboard: ntopng Network Flow
Description: Dynamic (variable) views of ntopng network flow data stored in MySQL/MariaDB. Great for Application Dependency Mapping or just finding which apps, by port number, are hogging the network 

# Requirements
* Install MariaDB or MySQL
* Install ntopng somewhere
* Place your switch in promiscuous mode
# Install Instructions
* Add this line to your ntopng.conf (replacing [db-hostname] with the hostname of your db server):
````bash
--dump-flows=mysql;[db-hostname];ntopng;flows;ntopng;ntopng
````
* Restart ntopng
````bash
sudo systemctl restart ntopng
````
* Define the ntopng table in your database as a Grafana data source. My definition looks like [this](https://imgur.com/a/S3xs1RG)
* Import this dashboard into Grafana
* Set the data source for the dashboard to your MariaDB/MySQL
* Celebrate 🥳

Demo of he dashboard and the setup can be found [here](https://youtu.be/Em6crXrn614)


{
  "__inputs": [
    {
      "name": "DS_MARIADB-NTOPNG",
      "label": "MariaDB-ntopng",
      "description": "MariaDB/MySQL ntopng table of network flows",
      "type": "datasource",
      "pluginId": "mysql",
      "pluginName": "MySQL"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "7.5.5"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "mysql",
      "name": "MySQL",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "gnetId": 14357,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1620153819654,
  "links": [],
  "panels": [
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_MARIADB-NTOPNG}",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "unit": "binBps"
        },
        "overrides": []
      },
      "fill": 0,
      "fillGradient": 0,
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 0,
        "y": 0
      },
      "hiddenSeries": false,
      "id": 6,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "7.5.5",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "format": "time_series",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": false,
          "rawSql": "SELECT\n  FIRST_SWITCHED AS \"time\",\n  IN_BYTES,\n  INET_NTOA(IP_SRC_ADDR)\nFROM flowsv4\nWHERE\n  $__unixEpochFilter(FIRST_SWITCHED)\nORDER BY FIRST_SWITCHED",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "IN_BYTES"
                ],
                "type": "column"
              }
            ],
            [
              {
                "params": [
                  "INET_NTOA(IP_SRC_ADDR)"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "flowsv4",
          "timeColumn": "FIRST_SWITCHED",
          "timeColumnType": "int",
          "where": [
            {
              "name": "$__unixEpochFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "In - Ip Address",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:1557",
          "decimals": null,
          "format": "binBps",
          "label": null,
          "logBase": 1,
          "max": "400000",
          "min": null,
          "show": true
        },
        {
          "$$hashKey": "object:1558",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": false
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_MARIADB-NTOPNG}",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "unit": "binBps"
        },
        "overrides": []
      },
      "fill": 0,
      "fillGradient": 0,
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 12,
        "y": 0
      },
      "hiddenSeries": false,
      "id": 7,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "7.5.5",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "format": "time_series",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": false,
          "rawSql": "SELECT\n  FIRST_SWITCHED AS \"time\",\n  IN_BYTES,\n  inet_ntoa(ip_dst_addr)\nFROM flowsv4\nWHERE\n  $__unixEpochFilter(FIRST_SWITCHED)\nORDER BY FIRST_SWITCHED",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "IN_BYTES"
                ],
                "type": "column"
              }
            ],
            [
              {
                "params": [
                  "inet_ntoa(ip_dst_addr)"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "flowsv4",
          "timeColumn": "FIRST_SWITCHED",
          "timeColumnType": "int",
          "where": [
            {
              "name": "$__unixEpochFilter",
              "params": [],
              "type": "macro"
            }
          ]
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Out - Ip Address",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:1557",
          "decimals": null,
          "format": "binBps",
          "label": null,
          "logBase": 1,
          "max": "400000",
          "min": null,
          "show": true
        },
        {
          "$$hashKey": "object:1558",
          "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_MARIADB-NTOPNG}",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "unit": "binBps"
        },
        "overrides": []
      },
      "fill": 0,
      "fillGradient": 0,
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 0,
        "y": 9
      },
      "hiddenSeries": false,
      "id": 3,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "7.5.5",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "format": "time_series",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT\n  FIRST_SWITCHED AS \"time\",\n  OUT_BYTES, \n  INET_NTOA(IP_DST_ADDR)\nFROM flowsv4\nWHERE\n  $__unixEpochFilter(FIRST_SWITCHED) AND\n  INET_NTOA(IP_SRC_ADDR) = \"$SRC_IP\"\nORDER BY FIRST_SWITCHED",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "IN_BYTES"
                ],
                "type": "column"
              }
            ],
            [
              {
                "params": [
                  "INET_NTOA(IP_SRC_ADDR)"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "flowsv4",
          "timeColumn": "FIRST_SWITCHED",
          "timeColumnType": "int",
          "where": [
            {
              "name": "$__unixEpochFilter",
              "params": [],
              "type": "macro"
            },
            {
              "name": "",
              "params": [
                "INET_NTOA(IP_DST_ADDR)",
                "=",
                "\"192.168.1.66\""
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "From $SRC_IP - IP & Bytes",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:1557",
          "format": "binBps",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "$$hashKey": "object:1558",
          "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_MARIADB-NTOPNG}",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "unit": "binBps"
        },
        "overrides": []
      },
      "fill": 0,
      "fillGradient": 0,
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 12,
        "y": 9
      },
      "hiddenSeries": false,
      "id": 2,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "7.5.5",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "format": "time_series",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT\n  FIRST_SWITCHED AS \"time\",\n  IN_BYTES, \n  INET_NTOA(IP_SRC_ADDR)\nFROM flowsv4\nWHERE\n  $__unixEpochFilter(FIRST_SWITCHED) AND\n  INET_NTOA(IP_DST_ADDR) = \"$DST_IP\"\nORDER BY FIRST_SWITCHED",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "IN_BYTES"
                ],
                "type": "column"
              }
            ],
            [
              {
                "params": [
                  "INET_NTOA(IP_SRC_ADDR)"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "flowsv4",
          "timeColumn": "FIRST_SWITCHED",
          "timeColumnType": "int",
          "where": [
            {
              "name": "$__unixEpochFilter",
              "params": [],
              "type": "macro"
            },
            {
              "name": "",
              "params": [
                "INET_NTOA(IP_DST_ADDR)",
                "=",
                "\"192.168.1.66\""
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "To $DST_IP - IP & Bytes",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:1557",
          "format": "binBps",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "$$hashKey": "object:1558",
          "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_MARIADB-NTOPNG}",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "unit": "binBps"
        },
        "overrides": []
      },
      "fill": 0,
      "fillGradient": 0,
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 0,
        "y": 18
      },
      "hiddenSeries": false,
      "id": 4,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "alertThreshold": true
      },
      "percentage": false,
      "pluginVersion": "7.5.5",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "format": "time_series",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT\n  FIRST_SWITCHED AS \"time\",\n  OUT_BYTES, \n  IN_BYTES\nFROM flowsv4\nWHERE\n  $__unixEpochFilter(FIRST_SWITCHED) AND\n  INET_NTOA(IP_SRC_ADDR) = \"$SRC_IP\" AND \n  INET_NTOA(IP_DST_ADDR) = \"$DST_IP\"\nORDER BY FIRST_SWITCHED",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "IN_BYTES"
                ],
                "type": "column"
              }
            ],
            [
              {
                "params": [
                  "INET_NTOA(IP_SRC_ADDR)"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "flowsv4",
          "timeColumn": "FIRST_SWITCHED",
          "timeColumnType": "int",
          "where": [
            {
              "name": "$__unixEpochFilter",
              "params": [],
              "type": "macro"
            },
            {
              "name": "",
              "params": [
                "INET_NTOA(IP_DST_ADDR)",
                "=",
                "\"192.168.1.66\""
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "From $SRC_IP  to $DST_IP - Bytes",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:1557",
          "format": "binBps",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "$$hashKey": "object:1558",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "datasource": "${DS_MARIADB-NTOPNG}",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": null,
            "filterable": false
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": []
          },
          "unit": "none"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 12,
        "y": 18
      },
      "id": 8,
      "options": {
        "frameIndex": 1,
        "showHeader": true
      },
      "pluginVersion": "7.5.5",
      "targets": [
        {
          "format": "time_series",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT\n  FIRST_SWITCHED AS \"time\",\n  L4_SRC_PORT,\n  L4_DST_PORT\nFROM flowsv4\nWHERE\n  $__unixEpochFilter(FIRST_SWITCHED) AND\n  INET_NTOA(IP_SRC_ADDR) = \"$SRC_IP\" AND \n  INET_NTOA(IP_DST_ADDR) = \"$DST_IP\"\nORDER BY FIRST_SWITCHED",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "IN_BYTES"
                ],
                "type": "column"
              }
            ],
            [
              {
                "params": [
                  "INET_NTOA(IP_SRC_ADDR)"
                ],
                "type": "column"
              }
            ]
          ],
          "table": "flowsv4",
          "timeColumn": "FIRST_SWITCHED",
          "timeColumnType": "int",
          "where": [
            {
              "name": "$__unixEpochFilter",
              "params": [],
              "type": "macro"
            },
            {
              "name": "",
              "params": [
                "INET_NTOA(IP_DST_ADDR)",
                "=",
                "\"192.168.1.66\""
              ],
              "type": "expression"
            }
          ]
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "From $SRC_IP  to $DST_IP - Port",
      "type": "table"
    }
  ],
  "refresh": "15m",
  "schemaVersion": 27,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_MARIADB-NTOPNG}",
        "definition": "SELECT DISTINCT INET_NTOA(ip_src_addr) from flowsv4 where  INET_NTOA(ip_src_addr) like \"192.168.1.%\"",
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "SRC_IP",
        "options": [],
        "query": "SELECT DISTINCT INET_NTOA(ip_src_addr) from flowsv4 where  INET_NTOA(ip_src_addr) like \"192.168.1.%\"",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 1,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_MARIADB-NTOPNG}",
        "definition": "SELECT DISTINCT INET_NTOA(ip_dst_addr) from flowsv4 where  INET_NTOA(ip_dst_addr) like \"192.168.1.%\"",
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": null,
        "multi": false,
        "name": "DST_IP",
        "options": [],
        "query": "SELECT DISTINCT INET_NTOA(ip_dst_addr) from flowsv4 where  INET_NTOA(ip_dst_addr) like \"192.168.1.%\"",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 1,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "now-1h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "ntopng Network Flow",
  "uid": "pTvKsQ9Mz",
  "version": 30,
  "description": "Dynamic (variable) views of ntopng network flow data stored in MySQL/MariaDB. Great for Application Dependency Mapping or just finding which apps, by port number, are hogging the network "
}