{
    "title": "Network Security Groups",
    "connectivityCriterias": [
        {
            "type": "IsConnectedQuery",
            "value": [
                "AzureDiagnostics | where Category == \"NetworkSecurityGroupEvent\"\n            | summarize LastLogReceived = max(TimeGenerated)\n            | project IsConnected = LastLogReceived > ago(7d)",
                "AzureDiagnostics | where Category == \"NetworkSecurityGroupRuleCounter\"\n            | summarize LastLogReceived = max(TimeGenerated)\n            | project IsConnected = LastLogReceived > ago(7d)"
            ]
        }
    ],
    "id": "AzureNSG",
    "publisher": "Microsoft",
    "logo": "AzureNetworkSecurityGroups.svg",
    "descriptionMarkdown": "Azure network security groups (NSG) allow you to filter network traffic to and from Azure resources in an Azure virtual network. A network security group includes rules that allow or deny traffic to a virtual network subnet, network interface, or both.\n\nWhen you enable logging for an NSG, you can gather the following types of resource log information:\n\n- **Event:** Entries are logged for which NSG rules are applied to VMs, based on MAC address.\n- **Rule counter:** Contains entries for how many times each NSG rule is applied to deny or allow traffic. The status for these rules is collected every 300 seconds.\n\n\nThis connector lets you stream your NSG diagnostics logs into Microsoft Sentinel, allowing you to continuously monitor activity in all your instances. For more information, see the [Microsoft Sentinel documentation](https://go.microsoft.com/fwlink/p/?linkid=2223718&wt.mc_id=sentinel_dataconnectordocs_content_cnl_csasci).",
    "graphQueries": [
        {
            "metricName": "Total data received",
            "legend": "NetworkSecurityGroupEvent",
            "baseQuery": "AzureDiagnostics | where Category == \"NetworkSecurityGroupEvent\""
        },
        {
            "metricName": "Total data received",
            "legend": "NetworkSecurityGroupRuleCounter",
            "baseQuery": "AzureDiagnostics | where Category == \"NetworkSecurityGroupRuleCounter\""
        }
    ],
    "sampleQueries": [
        {
            "description": "All NetworkSecurityGroupEvent category logs",
            "query": "AzureDiagnostics | where Category == \"NetworkSecurityGroupEvent\"\n            | sort by TimeGenerated"
        },
        {
            "description": "All NetworkSecurityGroupRuleCounter category logs",
            "query": "AzureDiagnostics | where Category == \"NetworkSecurityGroupRuleCounter\"\n            | sort by TimeGenerated"
        }
    ],
    "dataTypes": [
        {
            "name": "NetworkSecurityGroupEvent",
            "lastDataReceivedQuery": "AzureDiagnostics | where Category == \"NetworkSecurityGroupEvent\"\n            | summarize Time = max(TimeGenerated)\n            | where isnotempty(Time)"
        },
        {
            "name": "NetworkSecurityGroupRuleCounter",
            "lastDataReceivedQuery": "AzureDiagnostics | where Category == \"NetworkSecurityGroupRuleCounter\"\n            | summarize Time = max(TimeGenerated)\n            | where isnotempty(Time)"
        }
    ],
    "instructionSteps": [
        {
            "title": "Stream diagnostics logs from your Connect your Network Security Groups diagnostics logs into Sentinel. at scale",
            "description": "This connector uses Azure Policy to apply a single Azure Network Security Groups log-streaming configuration to a collection of instances, defined as a scope.   \nFollow the instructions below to create and apply a policy to all current and future instances. **Note**, you may already have an active policy for this resource type.",
            "innerSteps": [
                {
                    "title": "Launch the Azure Policy Assignment wizard and follow the steps.​",
                    "description": ">1. In the **Basics** tab, click the button with the three dots under **Scope** to select your resources assignment scope.\n        >2. In the **Parameters** tab, choose your Microsoft Sentinel workspace from the **Log Analytics workspace** drop-down list, and leave marked as \"True\" all the log and metric types you want to ingest.\n        >3. To apply the policy on your existing resources, select the **Remediation tab** and mark the **Create a remediation task** checkbox.",
                    "instructions": [
                        {
                            "parameters": {
                                "linkType": "OpenPolicyAssignment",
                                "policyDefinitionGuid": "98a2e215-5382-489e-bd29-32e7190a39ba",
                                "assignMode": 1
                            },
                            "type": "InstallAgent"
                        }
                    ]
                }
            ]
        }
    ],
    "permissions": {
        "resourceProvider": [
            {
                "provider": "Microsoft.OperationalInsights/workspaces",
                "permissionsDisplayText": "read and write permissions.",
                "providerDisplayName": "Workspace",
                "scope": "Workspace",
                "requiredPermissions": {
                    "read": true,
                    "write": true,
                    "delete": true
                }
            }
        ],
        "customs": [
            {
                "name": "Policy​",
                "description": "owner role assigned for each policy assignment scope.​"
            }
        ]
    },
    "availability": {
        "status": 2,
        "featureFlag": {
            "feature": "AzureNSGFeature",
            "featureStates": {
                "1": 2,
                "2": 2,
                "3": 2,
                "4": 2,
                "5": 2,
                "6": 1,
                "7": 1
            }
        }
    }
}
