Entity Query Templates - List

Gets all entity query templates.

GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/entityQueryTemplates?api-version=2024-01-01-preview
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/entityQueryTemplates?kind=Activity&api-version=2024-01-01-preview

URI Parameters

Name In Required Type Description
resourceGroupName
path True

string

The name of the resource group. The name is case insensitive.

subscriptionId
path True

string

The ID of the target subscription.

workspaceName
path True

string

The name of the workspace.

Regex pattern: ^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$

api-version
query True

string

The API version to use for this operation.

kind
query

string

The entity template query kind we want to fetch

Responses

Name Type Description
200 OK

EntityQueryTemplateList

OK

Other Status Codes

CloudError

Error response describing why the operation failed.

Security

azure_auth

Azure Active Directory OAuth2 Flow

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

Name Description
user_impersonation impersonate your user account

Examples

Get all entity query templates.

Sample Request

GET https://management.azure.com/subscriptions/d0cfe6b2-9ac0-4464-9919-dccaee2e48c0/resourceGroups/myRg/providers/Microsoft.OperationalInsights/workspaces/myWorkspace/providers/Microsoft.SecurityInsights/entityQueryTemplates?kind=Activity&api-version=2024-01-01-preview

Sample Response

{
  "value": [
    {
      "id": "/subscriptions/d0cfe6b2-9ac0-4464-9919-dccaee2e48c0/resourceGroups/myRg/providers/Microsoft.OperationalInsights/workspaces/myWorkspace/providers/Microsoft.SecurityInsights/entityQueryTemplates/37ca3555-c135-4a73-a65e-9c1d00323f5d",
      "name": "37ca3555-c135-4a73-a65e-9c1d00323f5d",
      "type": "Microsoft.SecurityInsights/entityQueryTemplates",
      "kind": "Activity",
      "properties": {
        "title": "An account was deleted on this host",
        "content": "On '{{Computer}}' the account '{{TargetAccount}}' was deleted by '{{AddedBy}}'",
        "description": "Account deleted on host",
        "queryDefinitions": {
          "query": "let GetAccountActions = (v_Host_Name:string, v_Host_NTDomain:string, v_Host_DnsDomain:string, v_Host_AzureID:string, v_Host_OMSAgentID:string){\nSecurityEvent\n| where EventID in (4725, 4726, 4767, 4720, 4722, 4723, 4724)\n// parsing for Host to handle variety of conventions coming from data\n| extend Host_HostName = case(\nComputer has '@', tostring(split(Computer, '@')[0]),\nComputer has '\\\\', tostring(split(Computer, '\\\\')[1]),\nComputer has '.', tostring(split(Computer, '.')[0]),\nComputer\n)\n| extend Host_NTDomain = case(\nComputer has '\\\\', tostring(split(Computer, '\\\\')[0]), \nComputer has '.', tostring(split(Computer, '.')[-2]), \nComputer\n)\n| extend Host_DnsDomain = case(\nComputer has '\\\\', tostring(split(Computer, '\\\\')[0]), \nComputer has '.', strcat_array(array_slice(split(Computer,'.'),-2,-1),'.'), \nComputer\n)\n| where (Host_HostName =~ v_Host_Name and Host_NTDomain =~ v_Host_NTDomain) \nor (Host_HostName =~ v_Host_Name and Host_DnsDomain =~ v_Host_DnsDomain) \nor v_Host_AzureID =~ _ResourceId \nor v_Host_OMSAgentID == SourceComputerId\n| project TimeGenerated, EventID, Activity, Computer, TargetAccount, TargetUserName, TargetDomainName, TargetSid, SubjectUserName, SubjectUserSid, _ResourceId, SourceComputerId\n| extend AddedBy = SubjectUserName\n// Future support for Activities\n| extend timestamp = TimeGenerated, HostCustomEntity = Computer, AccountCustomEntity = TargetAccount\n};\nGetAccountActions('{{Host_HostName}}', '{{Host_NTDomain}}', '{{Host_DnsDomain}}', '{{Host_AzureID}}', '{{Host_OMSAgentID}}')\n \n| where EventID == 4726 "
        },
        "inputEntityType": "Host",
        "requiredInputFieldsSets": [
          [
            "Host_HostName",
            "Host_NTDomain"
          ],
          [
            "Host_HostName",
            "Host_DnsDomain"
          ],
          [
            "Host_AzureID"
          ],
          [
            "Host_OMSAgentID"
          ]
        ],
        "entitiesFilter": {
          "Host_OsFamily": [
            "Windows"
          ]
        },
        "dataTypes": [
          {
            "dataType": "AuditLogs"
          },
          {
            "dataType": "SecurityEvent"
          }
        ]
      }
    },
    {
      "id": "/subscriptions/d0cfe6b2-9ac0-4464-9919-dccaee2e48c0/resourceGroups/myRg/providers/Microsoft.OperationalInsights/workspaces/myWorkspace/providers/Microsoft.SecurityInsights/entityQueryTemplates/97a1d515-abf2-4231-9a35-985f9de0bb91",
      "name": "97a1d515-abf2-4231-9a35-985f9de0bb91",
      "type": "Microsoft.SecurityInsights/entityQueryTemplates",
      "kind": "Activity",
      "properties": {
        "title": "An account was deleted on this host",
        "content": "On '{{Computer}}' the account '{{TargetAccount}}' was deleted by '{{AddedBy}}'",
        "description": "Account deleted on host",
        "queryDefinitions": {
          "query": "let GetAccountActions = (v_Host_Name:string, v_Host_NTDomain:string, v_Host_DnsDomain:string, v_Host_AzureID:string, v_Host_OMSAgentID:string){\nSecurityEvent\n| where EventID in (4725, 4726, 4767, 4720, 4722, 4723, 4724)\n// parsing for Host to handle variety of conventions coming from data\n| extend Host_HostName = case(\nComputer has '@', tostring(split(Computer, '@')[0]),\nComputer has '\\\\', tostring(split(Computer, '\\\\')[1]),\nComputer has '.', tostring(split(Computer, '.')[0]),\nComputer\n)\n| extend Host_NTDomain = case(\nComputer has '\\\\', tostring(split(Computer, '\\\\')[0]), \nComputer has '.', tostring(split(Computer, '.')[-2]), \nComputer\n)\n| extend Host_DnsDomain = case(\nComputer has '\\\\', tostring(split(Computer, '\\\\')[0]), \nComputer has '.', strcat_array(array_slice(split(Computer,'.'),-2,-1),'.'), \nComputer\n)\n| where (Host_HostName =~ v_Host_Name and Host_NTDomain =~ v_Host_NTDomain) \nor (Host_HostName =~ v_Host_Name and Host_DnsDomain =~ v_Host_DnsDomain) \nor v_Host_AzureID =~ _ResourceId \nor v_Host_OMSAgentID == SourceComputerId\n| project TimeGenerated, EventID, Activity, Computer, TargetAccount, TargetUserName, TargetDomainName, TargetSid, SubjectUserName, SubjectUserSid, _ResourceId, SourceComputerId\n| extend AddedBy = SubjectUserName\n// Future support for Activities\n| extend timestamp = TimeGenerated, HostCustomEntity = Computer, AccountCustomEntity = TargetAccount\n};\nGetAccountActions('{{Host_HostName}}', '{{Host_NTDomain}}', '{{Host_DnsDomain}}', '{{Host_AzureID}}', '{{Host_OMSAgentID}}')\n \n| where EventID == 4726 "
        },
        "inputEntityType": "Host",
        "requiredInputFieldsSets": [
          [
            "Host_HostName",
            "Host_NTDomain"
          ],
          [
            "Host_HostName",
            "Host_DnsDomain"
          ],
          [
            "Host_AzureID"
          ],
          [
            "Host_OMSAgentID"
          ]
        ],
        "entitiesFilter": {
          "Host_OsFamily": [
            "Windows"
          ]
        },
        "dataTypes": [
          {
            "dataType": "AuditLogs"
          },
          {
            "dataType": "SecurityEvent"
          }
        ]
      }
    }
  ]
}

Definitions

Name Description
ActivityEntityQueryTemplate

Represents Activity entity query.

CloudError

Error response structure.

CloudErrorBody

Error details.

createdByType

The type of identity that created the resource.

DataTypeDefinitions

The data type definition

EntityQueryTemplateKind

The kind of the entity query template.

EntityQueryTemplateList

List of all the entity query templates.

EntityType

The type of the query's source entity

QueryDefinitions

The Activity query definitions

systemData

Metadata pertaining to creation and last modification of the resource.

ActivityEntityQueryTemplate

Represents Activity entity query.

Name Type Description
id

string

Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}

kind string:

Activity

the entity query template kind

name

string

The name of the resource

properties.content

string

The entity query content to display in timeline

properties.dataTypes

DataTypeDefinitions[]

List of required data types for the given entity query template

properties.description

string

The entity query description

properties.entitiesFilter

object

The query applied only to entities matching to all filters

properties.inputEntityType

EntityType

The type of the query's source entity

properties.queryDefinitions

QueryDefinitions

The Activity query definitions

properties.requiredInputFieldsSets

string[]

List of the fields of the source entity that are required to run the query

properties.title

string

The entity query title

systemData

systemData

Azure Resource Manager metadata containing createdBy and modifiedBy information.

type

string

The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"

CloudError

Error response structure.

Name Type Description
error

CloudErrorBody

Error data

CloudErrorBody

Error details.

Name Type Description
code

string

An identifier for the error. Codes are invariant and are intended to be consumed programmatically.

message

string

A message describing the error, intended to be suitable for display in a user interface.

createdByType

The type of identity that created the resource.

Name Type Description
Application

string

Key

string

ManagedIdentity

string

User

string

DataTypeDefinitions

The data type definition

Name Type Description
dataType

string

The data type name

EntityQueryTemplateKind

The kind of the entity query template.

Name Type Description
Activity

string

EntityQueryTemplateList

List of all the entity query templates.

Name Type Description
nextLink

string

URL to fetch the next set of entity query templates.

value EntityQueryTemplate[]:

ActivityEntityQueryTemplate[]

Array of entity query templates.

EntityType

The type of the query's source entity

Name Type Description
Account

string

Entity represents account in the system.

AzureResource

string

Entity represents azure resource in the system.

CloudApplication

string

Entity represents cloud application in the system.

DNS

string

Entity represents dns in the system.

File

string

Entity represents file in the system.

FileHash

string

Entity represents file hash in the system.

Host

string

Entity represents host in the system.

HuntingBookmark

string

Entity represents HuntingBookmark in the system.

IP

string

Entity represents ip in the system.

IoTDevice

string

Entity represents IoT device in the system.

MailCluster

string

Entity represents mail cluster in the system.

MailMessage

string

Entity represents mail message in the system.

Mailbox

string

Entity represents mailbox in the system.

Malware

string

Entity represents malware in the system.

Nic

string

Entity represents network interface in the system.

Process

string

Entity represents process in the system.

RegistryKey

string

Entity represents registry key in the system.

RegistryValue

string

Entity represents registry value in the system.

SecurityAlert

string

Entity represents security alert in the system.

SecurityGroup

string

Entity represents security group in the system.

SubmissionMail

string

Entity represents submission mail in the system.

URL

string

Entity represents url in the system.

QueryDefinitions

The Activity query definitions

Name Type Description
query

string

The Activity query to run on a given entity

summarizeBy

string

The dimensions we want to summarize the timeline results on, this is comma separated list

systemData

Metadata pertaining to creation and last modification of the resource.

Name Type Description
createdAt

string

The timestamp of resource creation (UTC).

createdBy

string

The identity that created the resource.

createdByType

createdByType

The type of identity that created the resource.

lastModifiedAt

string

The timestamp of resource last modification (UTC)

lastModifiedBy

string

The identity that last modified the resource.

lastModifiedByType

createdByType

The type of identity that last modified the resource.