Grafana dashboard: Azure Network Policy Dashboard based on Azure Monitor
Description: Monitor and understand your Network Configuration. Uses a Prometheus Server data source.

# Azure Network Policy Metrics based on Azure Monitor
Azure Network Policy Manager (NPM) includes informative Prometheus metrics that allow you to monitor and better understand your configurations. We can view these metrics through Grafana dashboard.

## Current Metrics
| Metric Name                       | Description                                    | Prometheus Metric Type | Labels         |
| --                                | --                                             | --       |  -                           |
| `npm_num_policies`                | number of network policies                     | Gauge    |  -                           |
| `npm_num_iptables_rules`          | number of IPTables rules                       | Gauge    |  -                           |
| `npm_num_ipsets`                  | number of IPSets                               | Gauge    |  -                           |
| `npm_num_ipset_entries`           | number of IP address entries in all IPSets     | Gauge    |  -                           |
| `npm_add_policy_exec_time`        | runtime for adding a network policy            | Summary  | quantile (0.5, 0.9, or 0.99) |
| `npm_add_iptables_rule_exec_time` | runtime for adding an IPTables rule            | Summary  | quantile (0.5, 0.9, or 0.99) |
| `npm_add_ipset_exec_time`         | runtime for adding an IPSet                    | Summary  | quantile (0.5, 0.9, or 0.99) |
| `npm_ipset_counts` (advanced)     | number of entries within each individual IPSet | GaugeVec | set name & hash              |


## How it works?
* An AKS or AKS engine cluster with Azure Network Policy plugin.
* Container Insights enabled for cluster.
* Please refer this [doc](https://grafana.com/docs/grafana/latest/features/datasources/azuremonitor/) to enable Grafana dashboard from Azure Monitor log analytics data source

## Contact
acn@microsoft.com


{
  "__inputs": [
    {
      "name": "DS_AZURE_MONITOR-NONPCLUSTER02",
      "label": "Azure Monitor-noNPcluster02",
      "description": "",
      "type": "datasource",
      "pluginId": "grafana-azure-monitor-datasource",
      "pluginName": "Azure Monitor"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "7.0.3"
    },
    {
      "type": "datasource",
      "id": "grafana-azure-monitor-datasource",
      "name": "Azure Monitor",
      "version": "0.3.0"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "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": 13102,
  "graphTooltip": 0,
  "id": null,
  "links": [],
  "panels": [
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_AZURE_MONITOR-NONPCLUSTER02}",
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 0
      },
      "hiddenSeries": false,
      "id": 4,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "appInsights": {
            "dimension": "none",
            "metricName": "select",
            "rawQuery": false,
            "rawQueryString": "",
            "timeColumn": "timestamp",
            "timeGrain": "auto",
            "valueColumn": ""
          },
          "azureLogAnalytics": {
            "query": "InsightsMetrics\r\n| where Namespace == \"prometheus\"\r\n| where Name == \"npm_num_policies\"\r",
            "resultFormat": "time_series",
            "workspace": "1e97df55-3c1b-48c3-968c-fb03906f14e8"
          },
          "azureMonitor": {
            "aggOptions": [],
            "dimensionFilter": "*",
            "metricDefinition": "select",
            "metricName": "select",
            "metricNamespace": "select",
            "resourceGroup": "select",
            "resourceName": "select",
            "timeGrain": "auto",
            "timeGrains": [],
            "top": "10"
          },
          "queryType": "Azure Log Analytics",
          "refId": "A",
          "subscription": "9b8218f9-902a-4d20-a65c-e98acec5362f"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Network Policy Counts",
      "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_AZURE_MONITOR-NONPCLUSTER02}",
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 0
      },
      "hiddenSeries": false,
      "id": 6,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "appInsights": {
            "dimension": "none",
            "metricName": "select",
            "rawQuery": false,
            "rawQueryString": "",
            "timeColumn": "timestamp",
            "timeGrain": "auto",
            "valueColumn": ""
          },
          "azureLogAnalytics": {
            "query": "InsightsMetrics\r\n| where Namespace == \"prometheus\"\r\n| where Name == \"npm_num_iptables_rules\"\r",
            "resultFormat": "time_series",
            "workspace": "1e97df55-3c1b-48c3-968c-fb03906f14e8"
          },
          "azureMonitor": {
            "aggOptions": [],
            "dimensionFilter": "*",
            "metricDefinition": "select",
            "metricName": "select",
            "metricNamespace": "select",
            "resourceGroup": "select",
            "resourceName": "select",
            "timeGrain": "auto",
            "timeGrains": [],
            "top": "10"
          },
          "queryType": "Azure Log Analytics",
          "refId": "A",
          "subscription": "9b8218f9-902a-4d20-a65c-e98acec5362f"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Iptables Rules Counts",
      "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_AZURE_MONITOR-NONPCLUSTER02}",
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 8
      },
      "hiddenSeries": false,
      "id": 8,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "appInsights": {
            "dimension": "none",
            "metricName": "select",
            "rawQuery": false,
            "rawQueryString": "",
            "timeColumn": "timestamp",
            "timeGrain": "auto",
            "valueColumn": ""
          },
          "azureLogAnalytics": {
            "query": "InsightsMetrics\r\n| where Namespace == \"prometheus\"\r\n| where Name == \"npm_num_ipsets\"\r",
            "resultFormat": "time_series",
            "workspace": "1e97df55-3c1b-48c3-968c-fb03906f14e8"
          },
          "azureMonitor": {
            "aggOptions": [],
            "dimensionFilter": "*",
            "metricDefinition": "select",
            "metricName": "select",
            "metricNamespace": "select",
            "resourceGroup": "select",
            "resourceName": "select",
            "timeGrain": "auto",
            "timeGrains": [],
            "top": "10"
          },
          "queryType": "Azure Log Analytics",
          "refId": "A",
          "subscription": "9b8218f9-902a-4d20-a65c-e98acec5362f"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Ipset Counts",
      "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_AZURE_MONITOR-NONPCLUSTER02}",
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 8
      },
      "hiddenSeries": false,
      "id": 14,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "appInsights": {
            "dimension": "none",
            "metricName": "select",
            "rawQuery": false,
            "rawQueryString": "",
            "timeColumn": "timestamp",
            "timeGrain": "auto",
            "valueColumn": ""
          },
          "azureLogAnalytics": {
            "query": "InsightsMetrics\r\n| where Namespace == \"prometheus\"\r\n| where Name == \"npm_add_policy_exec_time\"\r",
            "resultFormat": "time_series",
            "workspace": "1e97df55-3c1b-48c3-968c-fb03906f14e8"
          },
          "azureMonitor": {
            "aggOptions": [],
            "dimensionFilter": "*",
            "metricDefinition": "select",
            "metricName": "select",
            "metricNamespace": "select",
            "resourceGroup": "select",
            "resourceName": "select",
            "timeGrain": "auto",
            "timeGrains": [],
            "top": "10"
          },
          "queryType": "Azure Log Analytics",
          "refId": "A",
          "subscription": "9b8218f9-902a-4d20-a65c-e98acec5362f"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Add Network Policy Execution Time",
      "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_AZURE_MONITOR-NONPCLUSTER02}",
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 16
      },
      "hiddenSeries": false,
      "id": 12,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "appInsights": {
            "dimension": "none",
            "metricName": "select",
            "rawQuery": false,
            "rawQueryString": "",
            "timeColumn": "timestamp",
            "timeGrain": "auto",
            "valueColumn": ""
          },
          "azureLogAnalytics": {
            "query": "InsightsMetrics\r\n| where Namespace == \"prometheus\"\r\n| where Name == \"npm_add_ipset_exec_time\"\r",
            "resultFormat": "time_series",
            "workspace": "1e97df55-3c1b-48c3-968c-fb03906f14e8"
          },
          "azureMonitor": {
            "aggOptions": [],
            "dimensionFilter": "*",
            "metricDefinition": "select",
            "metricName": "select",
            "metricNamespace": "select",
            "resourceGroup": "select",
            "resourceName": "select",
            "timeGrain": "auto",
            "timeGrains": [],
            "top": "10"
          },
          "queryType": "Azure Log Analytics",
          "refId": "A",
          "subscription": "9b8218f9-902a-4d20-a65c-e98acec5362f"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Add Ipset Execution Time",
      "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_AZURE_MONITOR-NONPCLUSTER02}",
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 0,
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 16
      },
      "hiddenSeries": false,
      "id": 16,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "nullPointMode": "null",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "appInsights": {
            "dimension": "none",
            "metricName": "select",
            "rawQuery": false,
            "rawQueryString": "",
            "timeColumn": "timestamp",
            "timeGrain": "auto",
            "valueColumn": ""
          },
          "azureLogAnalytics": {
            "query": "InsightsMetrics\r\n| where Namespace == \"prometheus\"\r\n| where Name == \"npm_add_iptables_rule_exec_time\"\r",
            "resultFormat": "time_series",
            "workspace": "1e97df55-3c1b-48c3-968c-fb03906f14e8"
          },
          "azureMonitor": {
            "aggOptions": [],
            "dimensionFilter": "*",
            "metricDefinition": "select",
            "metricName": "select",
            "metricNamespace": "select",
            "resourceGroup": "select",
            "resourceName": "select",
            "timeGrain": "auto",
            "timeGrains": [],
            "top": "10"
          },
          "queryType": "Azure Log Analytics",
          "refId": "A",
          "subscription": "9b8218f9-902a-4d20-a65c-e98acec5362f"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Add Iptables Rule Execution Time",
      "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": false,
  "schemaVersion": 25,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now-1h",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ]
  },
  "timezone": "",
  "title": "Azure Network Policy Dashboard based on Azure Monitor",
  "uid": "-PuZwPKMz",
  "version": 9,
  "description": "Monitor and understand your Network Configuration. Uses a Prometheus Server data source."
}