Grafana dashboard: FastNetMon Flow database full query
Description: FastNetMon Advanced Clickhouse traffic persistence / flow database with ability to query using source IP, port, destination IP, port and protocol.

FastNetMon Advanced Clickhouse traffic persistence / flow database with ability to query using source IP, port, destination IP, port and protocol.

{
  "__inputs": [
    {
      "name": "DS_CLICKHOUSE",
      "label": "Clickhouse",
      "description": "",
      "type": "datasource",
      "pluginId": "vertamedia-clickhouse-datasource",
      "pluginName": "ClickHouse"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "8.1.2"
    },
    {
      "type": "panel",
      "id": "table-old",
      "name": "Table (old)",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "vertamedia-clickhouse-datasource",
      "name": "ClickHouse",
      "version": "2.3.1"
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "target": {
          "limit": 100,
          "matchAny": false,
          "tags": [],
          "type": "dashboard"
        },
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "gnetId": 14925,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1629977224866,
  "links": [],
  "panels": [
    {
      "columns": [],
      "datasource": "${DS_CLICKHOUSE}",
      "fontSize": "100%",
      "gridPos": {
        "h": 16,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "links": [],
      "pageSize": null,
      "scroll": true,
      "showHeader": true,
      "sort": {
        "col": 0,
        "desc": true
      },
      "styles": [
        {
          "alias": "Time",
          "align": "auto",
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "pattern": "Time",
          "type": "date"
        },
        {
          "alias": "",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "sourcePort",
          "thresholds": [],
          "type": "string",
          "unit": "none"
        },
        {
          "alias": "",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "destinationPort",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": "",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "length",
          "thresholds": [],
          "type": "number",
          "unit": "bytes"
        },
        {
          "alias": "",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "srcAsn",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": "",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "dstAsn",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": "",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "inputInterface",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": "",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "outputInterface",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": "",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "sampleRatio",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": "",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "packets",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": "",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "dateFormat": "YYYY-MM-DD HH:mm:ss",
          "decimals": 2,
          "mappingType": 1,
          "pattern": "TcpFlags",
          "thresholds": [],
          "type": "string",
          "unit": "short"
        },
        {
          "alias": "",
          "align": "auto",
          "colorMode": null,
          "colors": [
            "rgba(245, 54, 54, 0.9)",
            "rgba(237, 129, 40, 0.89)",
            "rgba(50, 172, 45, 0.97)"
          ],
          "decimals": 2,
          "pattern": "/.*/",
          "thresholds": [],
          "type": "number",
          "unit": "short"
        }
      ],
      "targets": [
        {
          "database": "fastnetmon",
          "dateColDataType": "packetDate",
          "dateLoading": false,
          "dateTimeColDataType": "packetDateTime",
          "dateTimeType": "DATETIME",
          "datetimeLoading": false,
          "extrapolate": true,
          "format": "table",
          "formattedQuery": "SELECT $timeSeries as t, count() FROM $table WHERE $timeFilter GROUP BY t ORDER BY t",
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "intervalFactor": 1,
          "orderByTime": "ASC",
          "policy": "default",
          "query": "SELECT\n    packetDateTime,\n    IPv4NumToString(srcIp) as srcIP,\n    IPv4NumToString(dstIp) as dstIP,\n    sourcePort,\n    destinationPort,\n    numberOfPackets as packets,\n    length,\n    srcAsn,\n    dstAsn,\n    transform(protocol, [17, 6, 1], ['udp', 'tcp', 'icmp'], 'unknown') as protocolName,\n    IPv4NumToString(agentIpAddress) as agent,\n    inputInterface as input,\n    outputInterface as output,\n    sampleRatio,\n    arrayMap(x -> transform(x, [1, 2, 4, 8, 16, 32, 64, 128, 256, 512], ['fin', 'syn', 'rst', 'psh', 'ack', 'urg', 'ecn', 'cwr', 'nonce', 'reserved'], 'unknown'), bitmaskToArray(flags)) as TcpFlags\nFROM $table\n\nWHERE\n    $timeFilter\n    AND srcIp = IPv4StringToNum('$source_ip')\n    AND dstIp = IPv4StringToNum('$destination_ip')\nand sourcePort = $source_port\n and destinationPort = $destination_port\n and protocolName = '$protocol'",
          "rawQuery": "SELECT\n    packetDateTime,\n    IPv4NumToString(srcIp) as srcIP,\n    IPv4NumToString(dstIp) as dstIP,\n    sourcePort,\n    destinationPort,\n    numberOfPackets as packets,\n    length,\n    srcAsn,\n    dstAsn,\n    transform(protocol, [17, 6, 1], ['udp', 'tcp', 'icmp'], 'unknown') as protocolName,\n    IPv4NumToString(agentIpAddress) as agent,\n    inputInterface as input,\n    outputInterface as output,\n    sampleRatio,\n    arrayMap(x -> transform(x, [1, 2, 4, 8, 16, 32, 64, 128, 256, 512], ['fin', 'syn', 'rst', 'psh', 'ack', 'urg', 'ecn', 'cwr', 'nonce', 'reserved'], 'unknown'), bitmaskToArray(flags)) as TcpFlags\nFROM fastnetmon.traffic\n\nWHERE\n    packetDate >= toDate(1629976160) AND packetDate <= toDate(1629976460) AND packetDateTime >= toDateTime(1629976160) AND packetDateTime <= toDateTime(1629976460)\n    AND srcIp = IPv4StringToNum('10.20.30.14')\n    AND dstIp = IPv4StringToNum('8.8.8.8')\nand sourcePort = 58624\n and destinationPort = 53\n and protocolName = 'udp'",
          "refId": "A",
          "resultFormat": "time_series",
          "round": "0s",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "skip_comments": true,
          "table": "traffic",
          "tableLoading": false,
          "tags": []
        }
      ],
      "title": "Flow storage",
      "transform": "table",
      "type": "table-old"
    }
  ],
  "refresh": "",
  "schemaVersion": 30,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {
          "selected": false,
          "text": "10.20.30.14",
          "value": "10.20.30.14"
        },
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": "Source IP",
        "multi": false,
        "name": "source_ip",
        "options": [
          {
            "selected": true,
            "text": "8.8.8.8",
            "value": "8.8.8.8"
          }
        ],
        "query": "8.8.8.8",
        "queryValue": "10.20.30.14",
        "skipUrlSync": false,
        "type": "custom"
      },
      {
        "allValue": null,
        "current": {
          "selected": false,
          "text": "64669",
          "value": "64669"
        },
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": "Source port",
        "multi": false,
        "name": "source_port",
        "options": [
          {
            "selected": true,
            "text": "80",
            "value": "80"
          }
        ],
        "query": "80",
        "queryValue": "",
        "skipUrlSync": false,
        "type": "custom"
      },
      {
        "allValue": null,
        "current": {
          "selected": true,
          "text": "8.8.8.8",
          "value": "8.8.8.8"
        },
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": "Destination IP",
        "multi": false,
        "name": "destination_ip",
        "options": [
          {
            "selected": true,
            "text": "8.8.8.8",
            "value": "8.8.8.8"
          }
        ],
        "query": "8.8.8.8",
        "queryValue": "",
        "skipUrlSync": false,
        "type": "custom"
      },
      {
        "allValue": null,
        "current": {
          "selected": false,
          "text": "53",
          "value": "53"
        },
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": "Destination port",
        "multi": false,
        "name": "destination_port",
        "options": [
          {
            "selected": true,
            "text": "80",
            "value": "80"
          }
        ],
        "query": "80",
        "queryValue": "53",
        "skipUrlSync": false,
        "type": "custom"
      },
      {
        "allValue": null,
        "current": {
          "selected": true,
          "text": "udp",
          "value": "udp"
        },
        "description": null,
        "error": null,
        "hide": 0,
        "includeAll": false,
        "label": "Protocol",
        "multi": false,
        "name": "protocol",
        "options": [
          {
            "selected": true,
            "text": "udp",
            "value": "udp"
          },
          {
            "selected": false,
            "text": "tcp",
            "value": "tcp"
          },
          {
            "selected": false,
            "text": "icmp",
            "value": "icmp"
          },
          {
            "selected": false,
            "text": "unknown",
            "value": "unknown"
          }
        ],
        "query": "udp,tcp,icmp,unknown",
        "queryValue": "",
        "skipUrlSync": false,
        "type": "custom"
      }
    ]
  },
  "time": {
    "from": "now-3h",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "time_options": [
      "5m",
      "15m",
      "1h",
      "6h",
      "12h",
      "24h",
      "2d",
      "7d",
      "30d"
    ]
  },
  "timezone": "",
  "title": "FastNetMon Flow database full query",
  "uid": "0DQGlW47k",
  "version": 4,
  "description": "FastNetMon Advanced Clickhouse traffic persistence / flow database with ability to query using source IP, port, destination IP, port and protocol."
}