azure-kusto-irql-graph
Apply IRQL graph functions to KQL or IRQL query results for Kusto Explorer visualization. Generates Lift_To_Graph mappings and composes Graph_Render_View, Graph_Fold_By_Property, Extract_Node_*, Enrich_Node_*, and Enrich_Graph_* calls. Accepts a supplied query or limited basic na
Install
npx skills add https://github.com/microsoft/skills/tree/main/.github/plugins/azure-kusto-graph-skills/skills/azure-kusto-irql-graph
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install microsoft-skills@llmmart
git clone https://github.com/microsoft/skills.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole microsoft/skills collection as a plugin from our marketplace. Git is the plain clone.
Skill manifest
IRQL Graph Functions -- Query Results to Visualization
Apply the IRQL graph function family to tabular results. Given a KQL or IRQL query and the user's graph description, generate a Lift_To_Graph mapping and compose only the stored graph functions needed to visualize, fold, extract, or enrich the graph in Kusto Explorer. The source query does not need to use IRQL.
Scope and Routing
| Request | Use |
|---|---|
| Turn supplied KQL/IRQL rows into an icon-decorated visual graph | This skill: Lift_To_Graph + Graph_Render_View |
Fold nodes or apply Extract_Node_*, Enrich_Node_*, or Enrich_Graph_* |
This skill |
Use make-graph, graph-match, shortest paths, connected components, graph models, or snapshots |
azure-kusto-graph |
| Author a non-trivial KQL/IRQL investigation from natural language | A Kusto or IRQL query-generation skill, then this skill |
If a request mixes visualization and native graph analysis, use this skill for the lift/render portion and azure-kusto-graph for operator semantics. Do not replace graph-lift functions with a hand-built edges-first graph unless the user asks for native graph operators.
Input Contract
- Preferred input: a working KQL/IRQL query that produces tabular results, plus a natural-language description of the desired nodes, edges, labels, icons, extracts, enrichments, or folds.
- This skill is not a natural-language-to-KQL or NL-to-IRQL converter. It transforms existing query results into graph visualizations. For general NL-to-KQL or NL-to-IRQL conversion, use a dedicated query-generation skill (available separately).
- Preserve the supplied query's retrieval, joins, filters, and aggregations. Add only projections or synthetic IDs required by the graph mapping.
- A basic natural-language source request is supported only when it maps directly to one known table or IRQL
Get_*selector with obvious columns and simple filters. State the assumed source, and do not invent joins, schema, or investigation logic. - For non-trivial query construction, use a separate Kusto/IRQL query-generation skill first, then apply this skill to its output.
- If no query or output schema is available and the source is not trivial, request the KQL query or its result columns before generating a mapping.
Activation Triggers
Use this skill when the user:
- Supplies KQL/IRQL results and asks for an IRQL graph visualization or mapping
- Mentions
Lift_To_Graph,Graph_Render_View, orGraph_Fold_By_Property - Asks for icon-decorated node/edge mappings in Kusto Explorer
- Wants to fold/collapse nodes by a shared property
- Requests graph extraction or enrichment through
Extract_Node_*,Enrich_Node_*, orEnrich_Graph_*
Do not activate this skill solely for graph-match, graph paths/components, persistent graphs, or generic make-graph construction; those belong to azure-kusto-graph.
Not a natural-language-to-KQL/IRQL converter. The input should generally be a working KQL or IRQL query whose results need graph visualization. Basic NL source requests work only for trivial single-table/selector cases. For general NL-to-KQL or NL-to-IRQL, use a dedicated query-generation skill (available separately).
Environment
- Cluster:
https://kc7001.eastus.kusto.windows.net - Databases:
ValdyTimes,JoJosHospital(graph functions pre-deployed) - Rendering: Kusto Explorer desktop app (make-graph visualization window)
- Tool:
kusto_query(via Azure MCP Server)
Function Preflight
Lift_To_Graph and Graph_Render_View are stored functions, not built-in Kusto operators. Before generating or running a lift pipeline against a target database, check what is deployed:
.show functions
| where Name in~ ("Lift_To_Graph", "Graph_Render_View", "Graph_Fold_By_Property")
| project Name
Lift_To_GraphandGraph_Render_Vieware required.Graph_Fold_By_Propertyis required only when folding is requested.- Check any
Extract_Node_*,Enrich_Node_*, orEnrich_Graph_*function before using it; omit optional enrichment when unavailable unless the user wants it deployed. - If a required function is missing and you have permission to alter the database, ask the user for confirmation before deploying. Then use the
.create-or-alter functiondefinitions in references/DEPLOY_IRQL_FUNCTIONS.md. Run the relevant.create-or-alterblock, then rerun the preflight check to confirm. - If you do not have alter permissions, tell the user which functions are missing and point them to
references/DEPLOY_IRQL_FUNCTIONS.mdfor manual deployment.
IRQL Graph Function Family
Lift_To_Graph(T, mappingJson)
Transforms any tabular KQL result into a unified node + edge table.
Input: Any table T + a JSON mapping string.
Output: Rows with EntityType = "node" or "edge", ready for make-graph.
Graph_Render_View(T)
Takes Lift_To_Graph output, splits nodes/edges, and calls make-graph to open Kusto Explorer's graph window.
Graph_Fold_By_Property(T, NodeType, PropertyName)
Collapses nodes of a given type sharing a property value into a single node. Rewires edges automatically.
Graph Extraction and Enrichment Functions
These are additional stored functions that must already be deployed on the target database. They are not bundled in references/DEPLOY_IRQL_FUNCTIONS.md. Use .show functions to verify availability before including in a pipeline.
| Function | Operation | Key Property |
|---|---|---|
Extract_Node_Email_Sender_Domain(T, displayName) |
Adds Domain to node props |
EmailSender |
Extract_Node_Employee_Firstname(T, displayName) |
Adds Firstname to node props |
Name |
Extract_Node_Event_Network_Domain(T, displayName) |
Adds DomainName to node props |
Url |
Enrich_Node_Ip_Employee(T, displayName) |
Adds employee info to IP nodes | ClientIp |
Enrich_Node_Username_Employee(T, displayName) |
Adds employee info to user nodes | Username |
Enrich_Node_Event_Authentication_Username(T, displayName) |
Adds auth context | Username |
Enrich_Node_Ip_Domain(T, displayName) |
Adds DNS domains | ClientIp |
Enrich_Node_Ip_Event_NetworkOutbound(T, displayName) |
Adds outbound events | ClientIp |
Enrich_Graph_Ip_Employee(T, mappingJson) |
Expands graph with employee nodes | ClientIp |
Enrich_Graph_Username_Employee(T, mappingJson) |
Expands graph with employee nodes | Username |
Enrich_Graph_Event_Authentication_Username(T, mappingJson) |
Expands with auth nodes | Username |
Mapping JSON Schema
The JSON mapping has two arrays: node_types and edges.
node_types[]
| Field | Required | Description |
|---|---|---|
type |
Yes | Node type label (e.g. "User", "Host", "IP") |
id |
Yes | Prefix for node ID; usually same as type |
key |
Yes | Column name whose value becomes the node's identity |
props |
Yes | Array of columns to carry as node properties |
defaults |
No | Object of fallback values for null/empty properties |
defIcon |
No | Default icon URL for this node type |
displayName |
No | Column to use for display label (defaults to id) |
color |
No | Column to source color from |
size |
No | Column to source size from |
edges[]
| Field | Required | Description |
|---|---|---|
type |
Yes | Edge type label (e.g. "AuthenticatesTo", "SentEmail") |
source |
Yes | {"id": "<prefix>", "type": "<NodeType>"} |
target |
Yes | {"id": "<prefix>", "type": "<NodeType>"} |
props |
No | Array of columns to carry as edge properties |
displayName |
No | Column for edge label |
color |
No | Column for edge color |
Icon Repository
Use icons from https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/:
- IP:
Public-IP-Addresses-(Classic).svg - Host/VM:
Virtual-Machine.svg - User:
Users.svg - Email:
Mailbox.svg(orazure-cds/command-1070-Mail.svg) - Process:
App-Services.svg - File:
Storage-Accounts.svg - Alert:
Activity-Log.svg - Domain:
DNS-Zones.svg
Mapping Generation Rules
Given the supplied query columns and the user's graph description, generate the mapping JSON by:
- Identify entities -> each distinct noun becomes a
node_type - Identify relationships -> each verb/preposition becomes an
edge - Map to columns -> use actual columns produced by the supplied query; never assume unavailable columns
- Set direction -> source is the actor, target is the acted-upon
- Add properties -> include columns relevant to investigation (timestamps, results, hashes)
- Assign icons -> pick from the icon set above based on entity type
Column Reference (IRQL unified schema)
| Entity | Key Column | Available Props |
|---|---|---|
| User | Username |
Username, Name, Role, Email |
| Host | Hostname |
Hostname |
| IP | ClientIp |
ClientIp |
| Email Message | Subject |
EnvTime, Subject, Verdict, Url |
| Sender | EmailSender |
EmailSender, Domain |
| Recipient | EmailRecipient |
EmailRecipient |
| Process | ProcessName |
EnvTime, ProcessName, ProcessCommandLine, ProcessHash |
| File | Filename |
EnvTime, Filename, Path, Sha256 |
| Domain | DomainName |
DomainName |
| Auth Event | (synthetic ID) | EnvTime, UserAgent, Result, Description |
Function Selection
- Start with the supplied KQL/IRQL tabular pipeline.
- Use
Lift_To_Graph(mapping)to create graph entities. - Add
Extract_Node_*,Enrich_Node_*, orEnrich_Graph_*only when requested and compatible with the mapped keys. - Add
Graph_Fold_By_Property()only when grouping/collapse is requested. - End visual output with
Graph_Render_View(). - Preflight the exact stored functions selected for the pipeline.
Pipeline Pattern
// 1. Preserve the supplied KQL or IRQL query
<input query>
// 2. Lift to graph
| invoke Lift_To_Graph(<mapping_json>)
// 3. Optionally extract or enrich graph entities
| invoke <Extract_Node_* | Enrich_Node_* | Enrich_Graph_*>()
// 4. Optionally fold nodes when requested
| invoke Graph_Fold_By_Property("<NodeType>", "<PropertyName>")
// 5. Render
| invoke Graph_Render_View()
Examples
For additional prompts and worked examples, see references/EXAMPLES.md.
Authentication graph: IP -> AuthEvent -> User -> Host
Input query: Get_Event_Authentication_All | where Result == "Failed Login" | take 200
Graph request: "Show IPs, authentication events, users, and hosts; fold events by result."
let auth_mapping = '{"node_types":[{"type":"SrcIp","id":"SrcIp","key":"ClientIp","props":["ClientIp"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/Public-IP-Addresses-(Classic).svg"},{"type":"Host","id":"Host","key":"Hostname","props":["Hostname"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/Virtual-Machine.svg"},{"type":"User","id":"User","key":"Username","props":["Username"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/Users.svg"},{"type":"AuthEvent","id":"AuthEvent","key":"AuthEventId","props":["AuthEventId","EnvTime","UserAgent","Result","Description"],"defaults":{"Result":"unknown"},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/Activity-Log.svg"}],"edges":[{"type":"RequestsAuth","source":{"id":"SrcIp","type":"SrcIp"},"target":{"id":"AuthEvent","type":"AuthEvent"},"props":["EnvTime"]},{"type":"TargetsUser","source":{"id":"AuthEvent","type":"AuthEvent"},"target":{"id":"User","type":"User"},"props":["EnvTime"]},{"type":"AgainstHost","source":{"id":"AuthEvent","type":"AuthEvent"},"target":{"id":"Host","type":"Host"},"props":["EnvTime"]}]}';
Get_Event_Authentication_All
| extend AuthEventId = strcat(Username, "_", Hostname, "_", EnvTime)
| where Result == "Failed Login"
| take 200
| invoke Lift_To_Graph(auth_mapping)
| invoke Graph_Fold_By_Property("AuthEvent", "Result")
| invoke Graph_Render_View()
Email graph: Sender -> Message -> Recipient
Input query: Get_Email_All | take 400
Graph request: "Visualize sender-to-message-to-recipient flow and fold messages by verdict."
let mail_mapping = '{"node_types":[{"type":"EmailMessage","id":"Message","key":"Subject","props":["EnvTime","Subject","Verdict"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/Media-File.svg"},{"type":"Sender","id":"Email","key":"EmailSender","props":["EmailSender"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-cds/command-1070-Mail.svg"},{"type":"Recipient","id":"Email","key":"EmailRecipient","props":["EmailRecipient"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-cds/command-1070-Mail.svg"}],"edges":[{"type":"SentBy","source":{"id":"Message","type":"EmailMessage"},"target":{"id":"Email","type":"Sender"},"props":["EnvTime","Verdict"]},{"type":"DeliveredTo","source":{"id":"Message","type":"EmailMessage"},"target":{"id":"Email","type":"Recipient"},"props":["EnvTime","Verdict"]}]}';
Get_Email_All
| take 400
| invoke Lift_To_Graph(mail_mapping)
| invoke Graph_Fold_By_Property("EmailMessage", "Verdict")
| invoke Graph_Render_View()
Suspicious domain investigation (end-to-end)
Basic source request: "Use outbound network events for these suspicious domains and graph IP-to-domain connections enriched with employee names."
This is the limited fallback: one known selector, one extractor, and one direct filter.
let suspicious_domain_mapping = '{"node_types":[{"type":"IP","id":"IP","key":"ClientIp","props":["ClientIp"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/Public-IP-Addresses-(Classic).svg"},{"type":"Domain","id":"Domain","key":"DomainName","props":["DomainName"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/DNS-Zones.svg"}],"edges":[{"type":"ConnectsTo","source":{"id":"IP","type":"IP"},"target":{"id":"Domain","type":"Domain"},"props":["EnvTime"]}]}';
Get_Event_NetworkOutbound
| invoke Extract_Event_Network_Domain()
| where DomainName has_any ("raisinkanes.com", "nothing-to-see-here.net", "totally-legit-domain.com")
| invoke Lift_To_Graph(suspicious_domain_mapping)
| invoke Enrich_Node_Ip_Employee("Name")
| invoke Graph_Fold_By_Property("Domain", "DomainName")
| invoke Graph_Render_View()
Process execution graph: User -> Process -> ParentProcess
Input query: Get_Event_Process_All | where ProcessCommandLine has "powershell" | take 300
Graph request: "Visualize process, parent process, host, and user relationships."
let proc_mapping = '{"node_types":[{"type":"Process","id":"Proc","key":"ProcessName","props":["ProcessName","ProcessCommandLine","ProcessHash"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/App-Services.svg"},{"type":"ParentProcess","id":"Proc","key":"ParentProcessName","props":["ParentProcessName","ParentProcessHash"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/App-Services.svg"},{"type":"Host","id":"Host","key":"Hostname","props":["Hostname"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/Virtual-Machine.svg"},{"type":"User","id":"User","key":"Username","props":["Username"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/Users.svg"}],"edges":[{"type":"SpawnedBy","source":{"id":"Proc","type":"Process"},"target":{"id":"Proc","type":"ParentProcess"},"props":["EnvTime"]},{"type":"RanOn","source":{"id":"Proc","type":"Process"},"target":{"id":"Host","type":"Host"},"props":["EnvTime"]},{"type":"ExecutedBy","source":{"id":"Proc","type":"Process"},"target":{"id":"User","type":"User"},"props":["EnvTime"]}]}';
Get_Event_Process_All
| where ProcessCommandLine has "powershell"
| take 300
| invoke Lift_To_Graph(proc_mapping)
| invoke Graph_Render_View()
Query Results -> Mapping Translation
When the user supplies a query and describes the graph:
- Inspect the query's final output columns
- Parse the entity nouns and relationship verbs
- Generate the mapping JSON using only those columns
- Preserve the supplied pipeline and append
Lift_To_Graph() - Include
Graph_Render_View()at the end - If the user mentions grouping/collapsing and the function exists, add
Graph_Fold_By_Property()
Output the complete KQL -- the supplied query plus mapping JSON inline as a string let binding -- after the required-function preflight passes. Clearly mark unverified function dependencies when the target database cannot be checked.
Opening Queries in Kusto Explorer (Windows Only)
Optional convenience feature. The default workflow is to output the KQL in chat and let the user copy it into Kusto Explorer or the VS Code Kusto extension manually. Auto-launch is opt-in only.
Always output the complete KQL query in the chat response with Step 1 (connect) and Step 2 (query) clearly labeled:
// Step 1: Connect to your cluster (skip if already connected)
// Example: uncomment to connect to the KC7 training cluster
// #connect cluster('kc7001.eastus.kusto.windows.net').database('ValdyTimes')
// Or replace with your own cluster:
// #connect cluster('<YOUR_CLUSTER>').database('<YOUR_DATABASE>')
// Step 2: Run the query below
<KQL_QUERY>
If the user asks to save or open in Kusto Explorer, follow the procedure in references/KUSTO_EXPLORER_LAUNCH.md. Key rules:
- Use
ask_userto confirm before writing files or launching executables - Display file contents in chat so the user can review before opening
- Never use shell interpolation or here-strings — write files via
Set-Content/Add-Content - Never encode queries into browser URLs
- On macOS/Linux, save the
.kqlfile and suggest the VS Code Kusto extension or ADX Web Explorer
Files (skills)
-
references
-
DEPLOY_IRQL_FUNCTIONS.md 11.1 KB
# Deploy IRQL Graph Functions The `Lift_To_Graph`, `Graph_Render_View`, and `Graph_Fold_By_Property` functions must be present in the target Kusto database. They are pre-deployed on the kc7001 example cluster but may be missing on other clusters. ## Check for existing functions ```kql .show functions | where Name in~ ("Lift_To_Graph", "Graph_Render_View", "Graph_Fold_By_Property") | project Name ``` If any required function is missing, deploy it using the `.create-or-alter` commands below. ## Lift_To_Graph ```kql .create-or-alter function with (folder="irql_draft", docstring="Transforms a generic table to a Kusto graph table using the given JSON mapping") Lift_To_Graph(T:(), mappingJson:string) { let calcIcon = (T:(type:string, defIcon:string)) { T | extend iconUrl = defIcon | project-away defIcon }; let mapping = (mapping_json:string) { parse_json(mapping_json) }; let Tpacked = (T:()) { T | extend _row = pack_all() }; let KustoResultsToNodes = (T:(), mapping_json:dynamic) { let NodeExpanded = Tpacked(T) | mv-expand nodeDef = mapping(mapping_json).node_types to typeof(dynamic) | extend name=tostring(_row[tostring(nodeDef.key)]), type=tostring(nodeDef.type), _nodeKeys=iif(isnull(nodeDef.props),dynamic([]),nodeDef.props), defaults=nodeDef.defaults | extend nodeColor=iff(isnotnull(nodeDef.color), tostring(_row[tostring(nodeDef.color)]), "") | extend nodeSize=iff(isnotnull(nodeDef.size), toreal(_row[tostring(nodeDef.size)]), 1.0) | extend iconColor=iff(isnotnull(nodeDef.iconColor), tostring(_row[tostring(nodeDef.iconColor)]), "") | extend id = strcat(nodeDef.id,"/",name) | extend nodeDisplayName=iff(isnotnull(nodeDef.displayName), strcat(type,'/',tostring(_row[tostring(nodeDef.displayName)])), id) | extend defIcon = iif(isnotempty(nodeDef.defIcon), nodeDef.defIcon, "") | where isnotempty(split(id, "/")[-1]) | extend type = tostring(nodeDef.type) | extend iconUrl="" | invoke calcIcon(); let NodePropsFilled = (T:(_row:dynamic, _nodeKeys:dynamic, id:string, type:string, nodeDisplayName:string, nodeColor:string, nodeSize:real, iconUrl:string, iconColor:string, defaults:dynamic)) { T | mv-expand k=_nodeKeys to typeof(string) | extend v=_row[k], def=defaults[k] | extend v = iif(isnull(v) or isempty(tostring(v)), iif(isnull(def), v, def), v) | summarize properties=make_bag(bag_pack(k,v)) by id,type,nodeDisplayName,nodeColor,nodeSize,iconUrl,iconColor }; let NodeNoProps = (T:(_nodeKeys:dynamic, id:string, type:string, nodeDisplayName:string, nodeColor:string, nodeSize:real, iconUrl:string, iconColor:string)) { T | where array_length(_nodeKeys)==0 | extend properties=dynamic({}) | project id,type,properties,nodeDisplayName,nodeColor,nodeSize,iconUrl, iconColor }; let Nodes = (T:(_row:dynamic, _nodeKeys:dynamic, id:string, type:string, nodeDisplayName:string, nodeColor:string, nodeSize:real, iconUrl:string, iconColor:string, defaults:dynamic)) { union NodePropsFilled(T), NodeNoProps(T) | project id,type,properties,nodeDisplayName,nodeColor,nodeSize,iconUrl, iconColor }; union (T | extend EntityType = "data"), (Nodes(NodeExpanded) | extend EntityType = "node") }; let KustoResultsToEdges = (T:(EntityType:string, ),mapping_json:dynamic) { let edges = datatable(SourceId:string, TargetId:string) []; let EdgeExpanded = Tpacked((T | where EntityType == "data")) | extend nodeDef = mapping(mapping_json).node_types | mv-expand edgeDef = mapping(mapping_json).edges to typeof(dynamic) | mv-apply nodeDefSrc = nodeDef on ( where tostring(nodeDefSrc["type"]) == tostring(edgeDef.source.type)) | extend SourceId = strcat(nodeDefSrc.id,"/",tostring(_row[tostring(nodeDefSrc.key)])) | mv-apply nodeDefTgt = nodeDef on ( where tostring(nodeDefTgt["type"]) == tostring(edgeDef.target.type)) | extend TargetId = strcat(nodeDefTgt.id,"/",tostring(_row[tostring(nodeDefTgt.key)])) | extend edgeType=tostring(edgeDef.type), _edgeKeys=iif(isnull(edgeDef.props),dynamic([]),edgeDef.props) | extend edgeDisplayName = iff(isnotnull(edgeDef.displayName), strcat(edgeType,'/',tostring(_row[tostring(edgeDef.displayName)])), edgeType) | extend edgeColor= iff(isnotnull(edgeDef.color), tostring(_row[tostring(edgeDef.color)]), edgeType); let EdgePropsFilled = (T:(_row:dynamic, _edgeKeys:dynamic, SourceId:string, TargetId:string, edgeType:string, edgeDisplayName:string, edgeColor:string)) { T | mv-expand k=_edgeKeys to typeof(string) | extend v=_row[k] | summarize edgeProperties=make_bag(bag_pack(k,v)) by SourceId,TargetId,edgeType,edgeDisplayName,edgeColor }; let EdgeNoProps = (T:(_edgeKeys:dynamic, SourceId:string, TargetId:string, edgeType:string, edgeDisplayName:string, edgeColor:string)) { T | where array_length(_edgeKeys)==0 | extend edgeProperties=dynamic({}) | project SourceId,TargetId,edgeType, edgeProperties,edgeDisplayName,edgeColor }; let Edges = (T:(_edgeKeys:dynamic, SourceId:string, TargetId:string, edgeType:string, edgeDisplayName:string, edgeColor:string)) { union EdgePropsFilled(EdgeExpanded), EdgeNoProps(EdgeExpanded) | where isnotempty(split(SourceId, "/")[-1]) and isnotempty(split(TargetId, "/")[-1]) | project-reorder SourceId,TargetId,edgeType,edgeProperties,edgeDisplayName,edgeColor }; union (T | where EntityType=="node"), (Edges(EdgeExpanded) | extend EntityType = "edge") }; T | invoke KustoResultsToNodes(mappingJson) | invoke KustoResultsToEdges(mappingJson) | where EntityType != "data" | project EntityType, id, type, properties, nodeDisplayName, nodeColor, nodeSize, iconUrl, iconColor, SourceId, TargetId, edgeType, edgeProperties, edgeDisplayName, edgeColor } ``` ## Graph_Render_View ```kql .create-or-alter function with (folder="irql_draft", docstring="Renders a graph table using make-graph in Kusto Explorer") Graph_Render_View(T:(id:string, type:string, properties:dynamic, nodeDisplayName:string, nodeColor:string, nodeSize:real, iconUrl:string, iconColor:string, SourceId:string, TargetId:string, edgeType:string, edgeProperties:dynamic, edgeDisplayName:string, edgeColor:string, EntityType:string)) { let NodesTable = T | where EntityType=="node" | project id, type, properties, nodeDisplayName, nodeColor, nodeSize, iconUrl, iconColor; let EdgesTable = T | where EntityType=="edge" | project SourceId, TargetId, type=edgeType, properties=edgeProperties, edgeDisplayName, edgeColor; // #graph-style("Default") let Default = dynamic({ "name":"Default", "graph_style":{ "layout":{"kind":"Grouped"}, "nodes_config":{ "density":80.0, "label_by":"id", "color_by":"iconUrl", "lifetime_start_by":"", "lifetime_end_by":"", "image_url_by":"iconUrl", "image_size":2.0 }, "edges_config":{ "lifetime_start_by":"", "lifetime_end_by":"" } }, "script":"// Use right-click on the nodes to explore interactive operations over the graph.", "matches":[] }); EdgesTable | make-graph SourceId --> TargetId with (NodesTable) on id } ``` ## Graph_Fold_By_Property ```kql .create-or-alter function with (folder="irql_draft", docstring="Folds nodes of a given type by a shared property value into single collapsed nodes") Graph_Fold_By_Property(T:(EntityType:string, id:string, type:string, properties:dynamic, nodeDisplayName:string, nodeColor:string, nodeSize:real, iconUrl:string, iconColor:string, SourceId:string, TargetId:string, edgeType:string, edgeProperties:dynamic, edgeDisplayName:string, edgeColor:string), NodeType:string, PropertyName:string) { let Nodes = T | where EntityType == "node" | project EntityType, id, type, properties, nodeDisplayName, nodeColor, nodeSize, iconUrl, iconColor, SourceId="", TargetId="", edgeType="", edgeProperties=dynamic(null), edgeDisplayName="", edgeColor=""; let Edges = T | where EntityType == "edge" | project EntityType, id="", type="", properties=dynamic({}), nodeDisplayName="", nodeColor="", nodeSize=real(0), iconUrl="", iconColor="", SourceId, TargetId, edgeType, edgeProperties, edgeDisplayName, edgeColor; let FoldedNodes = Nodes | where type == NodeType | where isnotempty(properties[PropertyName]) | extend val = tostring(properties[PropertyName]) | summarize members = make_list(id), memberCount = count() by val | where memberCount > 1 | extend id = strcat(PropertyName, "/", val), type = PropertyName, EntityType = "node", properties = pack("folded", val, "memberCount", memberCount, "members", members), nodeDisplayName = strcat(PropertyName, "/", val), nodeColor = "", nodeSize = real(0), iconUrl = "", iconColor = "" | project EntityType, id, type, properties, nodeDisplayName, nodeColor, nodeSize, iconUrl, iconColor, SourceId="", TargetId="", edgeType="", edgeProperties=dynamic(null), edgeDisplayName="", edgeColor=""; let MemberToFold = Nodes | where type == NodeType | where isnotempty(properties[PropertyName]) | extend val = tostring(properties[PropertyName]) | join kind=inner ( FoldedNodes | extend val = tostring(properties["folded"]) | project val, foldId=id ) on val | project memberId=id, foldId; let RewiredEdges = Edges | lookup kind=leftouter (MemberToFold | project SourceId=memberId, FoldSourceId=foldId) on SourceId | lookup kind=leftouter (MemberToFold | project TargetId=memberId, FoldTargetId=foldId) on TargetId | extend NewSourceId = coalesce(FoldSourceId, SourceId), NewTargetId = coalesce(FoldTargetId, TargetId) | where NewSourceId != NewTargetId | project EntityType="edge", id="", type="", properties=dynamic({}), nodeDisplayName="", nodeColor="", nodeSize=real(0), iconUrl="", iconColor="", SourceId=NewSourceId, TargetId=NewTargetId, edgeType, edgeProperties, edgeDisplayName, edgeColor; let FoldedMemberIds = MemberToFold | distinct memberId; union (Nodes | where id !in (FoldedMemberIds)), FoldedNodes, RewiredEdges } ``` ## Deploying all three functions Run each `.create-or-alter` block above in Kusto Explorer or the ADX web UI against your target database. The functions are placed in the `irql_draft` folder. After deployment, verify: ```kql .show functions | where Name in~ ("Lift_To_Graph", "Graph_Render_View", "Graph_Fold_By_Property") | project Name, Folder, DocString ``` -
EXAMPLES.md 3.6 KB
# Try It Out -- azure-kusto-irql-graph Paste any of these into **Copilot Chat** to see the skill in action. Cluster: `https://kc7001.eastus.kusto.windows.net` Supply the source KQL/IRQL pipeline with the graph description. The skill maps the query's output columns; it does not normally author the underlying investigation query. Use this skill for `Lift_To_Graph`, rendering, folding, and IRQL graph extraction/enrichment functions. Use `azure-kusto-graph` for native `make-graph`, `graph-match`, paths, components, graph models, and snapshots. Before trying the prompts on another database, verify `Lift_To_Graph` and `Graph_Render_View` with `.show functions`; also verify `Graph_Fold_By_Property` or enrichers when a prompt uses them. Deploy missing definitions from `references/DEPLOY_IRQL_FUNCTIONS.md`. --- ## ValdyTimes (IRQL selectors -> Lift_To_Graph) | # | Ask This | What It Does | |---|----------|--------------| | 1 | "Given `Get_Event_Authentication_All | take 200`, create a graph showing users authenticating to hosts" | User + Host mapping -> `Lift_To_Graph` -> `Graph_Render_View` | | 2 | "Given `Get_Event_Authentication_All | where Result == 'Failed Login' | take 100`, show IPs connecting to hosts through authentication events" | SrcIp -> AuthEvent -> Host with 3 node types | | 3 | "Given `Get_Email_All | take 300`, visualize email flow between senders and recipients" | Sender -> Message -> Recipient mapping | | 4 | "Given `Get_Email_All | take 400`, graph emails and collapse messages by verdict" | Email mapping -> `Graph_Fold_By_Property("EmailMessage", "Verdict")` | | 5 | "Given `Get_Event_Process_All | where ProcessCommandLine has 'powershell' | take 200`, show process execution trees with hosts and users" | Process -> ParentProcess + Host + User mapping | | 6 | "Given my query returning `ClientIp`, `DomainName`, and `EnvTime`, graph outbound connections and label IPs with employee names" | Network mapping -> `Enrich_Node_Ip_Employee` -> render | | 7 | "Create a graph mapping for file creation events showing which user created which file on which host" | Open-ended -- Copilot generates a new mapping JSON | | 8 | "Use the known outbound-network selector to graph connections to raisinkanes.com and show who's behind each IP" | Basic source fallback -> filter -> `Lift_To_Graph` -> enrich -> fold -> render | ## AzureCrest (raw KQL -> Lift_To_Graph) | # | Ask This | What It Does | |---|----------|--------------| | 1 | "Given `Email | take 400`, create a graph showing email flow between senders and recipients" | Raw `Email` -> mapping -> `Lift_To_Graph` -> `Graph_Render_View` | | 2 | "Graph emails in AzureCrest and collapse messages by verdict" | Email mapping -> `Graph_Fold_By_Property("EmailMessage", "verdict")` | | 3 | "Given `AuthenticationEvents | take 200`, create a Lift_To_Graph visualization of users authenticating to hosts" | Raw `AuthenticationEvents` -> User + Host mapping | | 4 | "Show IPs connecting to hosts through auth events in AzureCrest, with user nodes" | 4-entity auth mapping: SrcIp -> AuthEvent -> Host + User | | 5 | "Show process execution trees for hosts running powershell in AzureCrest" | Raw `ProcessEvents` -> Process -> Parent + Host + User | | 6 | "Graph outbound network connections from IPs to domains in AzureCrest" | Raw `OutboundNetworkEvents` -> IP -> Domain mapping | | 7 | "Create a graph of file creation events in AzureCrest showing users, files, and hosts" | Raw `FileCreationEvents` -> User + File + Host mapping | | 8 | "Graph DNS lookups in AzureCrest and fold IPs by domain" | `PassiveDns` -> IP -> Domain mapping -> fold by domain | -
KUSTO_EXPLORER_LAUNCH.md 2.6 KB
# Kusto Explorer Launch Procedure ## Prerequisites - Windows only — Kusto Explorer is not available on macOS/Linux - User must explicitly consent before file creation or launch ## Step 1: Confirm with user Use `ask_user`: "Save this query as a .kql file and open in Kusto Explorer? (Yes / Save only / No)" - **No** → output KQL in chat only (default) - **Save only** → proceed to Step 2, skip Step 4 - **Yes** → proceed through all steps ## Step 2: Build the .kql file content The file needs two sections because Kusto Explorer processes `#connect` as a connection-creation command that must run before the query. ``` // Step 1 — Select this line and run it first to connect #connect cluster('<CLUSTER>').database('<DATABASE>') // Step 2 — Select the query below and run it after Step 1 completes <KQL_QUERY> ``` Replace `<CLUSTER>` with the target cluster (e.g. `kc7001.eastus.kusto.windows.net`), `<DATABASE>` with the database name (e.g. `ValdyTimes`), and `<KQL_QUERY>` with the generated query. ## Step 3: Write the file Write to the current workspace directory using the filesystem API. Use a descriptive name with a random suffix to avoid collisions. ```powershell $cluster = "<CLUSTER>" $database = "<DATABASE>" $tmp = Join-Path $PWD "kusto_query_$(New-Guid).kql" $lines = @( "// Step 1 - Select this line and run it first", "#connect cluster('$cluster').database('$database')", "", "// Step 2 - Select the query below and run it after Step 1 completes" ) Set-Content -Path $tmp -Value ($lines -join "`n") -Encoding utf8 -NoNewline Add-Content -Path $tmp -Value "`n<KQL_QUERY>" -Encoding utf8 ``` > **Security:** Use `Set-Content`/`Add-Content` only. Never embed query text in PowerShell here-strings (`@"..."@`) — a crafted query can escape the delimiter and inject commands. Display the saved file path and its full contents in chat so the user can review. ## Step 4: Launch Kusto Explorer (only if user chose "Yes") Locate and launch the Kusto Explorer executable: ```powershell $exe = (Get-ChildItem "$env:LOCALAPPDATA\Apps\2.0" -Recurse -Filter "Kusto.Explorer.exe" -ErrorAction SilentlyContinue | Sort-Object LastWriteTime -Descending | Select-Object -First 1).FullName if ($exe) { Start-Process $exe -ArgumentList "`"$tmp`"" } else { Write-Warning "Kusto Explorer not found. Open the saved file manually: $tmp" } ``` Tell the user: run the `#connect` line (Step 1) first, then select and run the query (Step 2). ## macOS/Linux fallback Save the `.kql` file as in Step 3 and suggest: - Open in the VS Code Kusto extension - Paste into [ADX Web Explorer](https://dataexplorer.azure.com)
-
-
SKILL.md 18.7 KB
--- name: azure-kusto-irql-graph description: "Apply IRQL graph functions to KQL or IRQL query results for Kusto Explorer visualization. Generates Lift_To_Graph mappings and composes Graph_Render_View, Graph_Fold_By_Property, Extract_Node_*, Enrich_Node_*, and Enrich_Graph_* calls. Accepts a supplied query or limited basic natural-language source request; it is not a general natural-language-to-KQL/IRQL skill. WHEN: Lift_To_Graph, Graph_Render_View, Graph_Fold_By_Property, IRQL graph enrichment, graph mapping for existing query results, icon-decorated graph, fold graph nodes. Use azure-kusto-graph for native make-graph analysis, graph-match, shortest paths, components, or persistent graphs." license: MIT metadata: author: Microsoft version: "1.2.1" --- # IRQL Graph Functions -- Query Results to Visualization Apply the IRQL graph function family to tabular results. Given a KQL or IRQL query and the user's graph description, generate a `Lift_To_Graph` mapping and compose only the stored graph functions needed to visualize, fold, extract, or enrich the graph in Kusto Explorer. The source query does not need to use IRQL. ## Scope and Routing | Request | Use | |---|---| | Turn supplied KQL/IRQL rows into an icon-decorated visual graph | This skill: `Lift_To_Graph` + `Graph_Render_View` | | Fold nodes or apply `Extract_Node_*`, `Enrich_Node_*`, or `Enrich_Graph_*` | This skill | | Use `make-graph`, `graph-match`, shortest paths, connected components, graph models, or snapshots | `azure-kusto-graph` | | Author a non-trivial KQL/IRQL investigation from natural language | A Kusto or IRQL query-generation skill, then this skill | If a request mixes visualization and native graph analysis, use this skill for the lift/render portion and `azure-kusto-graph` for operator semantics. Do not replace graph-lift functions with a hand-built edges-first graph unless the user asks for native graph operators. ## Input Contract - **Preferred input**: a working KQL/IRQL query that produces tabular results, plus a natural-language description of the desired nodes, edges, labels, icons, extracts, enrichments, or folds. - This skill is **not a natural-language-to-KQL or NL-to-IRQL converter**. It transforms existing query results into graph visualizations. For general NL-to-KQL or NL-to-IRQL conversion, use a dedicated query-generation skill (available separately). - Preserve the supplied query's retrieval, joins, filters, and aggregations. Add only projections or synthetic IDs required by the graph mapping. - A basic natural-language source request is supported only when it maps directly to one known table or IRQL `Get_*` selector with obvious columns and simple filters. State the assumed source, and do not invent joins, schema, or investigation logic. - For non-trivial query construction, use a separate Kusto/IRQL query-generation skill first, then apply this skill to its output. - If no query or output schema is available and the source is not trivial, request the KQL query or its result columns before generating a mapping. ## Activation Triggers Use this skill when the user: - Supplies KQL/IRQL results and asks for an IRQL graph visualization or mapping - Mentions `Lift_To_Graph`, `Graph_Render_View`, or `Graph_Fold_By_Property` - Asks for icon-decorated node/edge mappings in Kusto Explorer - Wants to fold/collapse nodes by a shared property - Requests graph extraction or enrichment through `Extract_Node_*`, `Enrich_Node_*`, or `Enrich_Graph_*` Do not activate this skill solely for `graph-match`, graph paths/components, persistent graphs, or generic `make-graph` construction; those belong to `azure-kusto-graph`. **Not a natural-language-to-KQL/IRQL converter.** The input should generally be a working KQL or IRQL query whose results need graph visualization. Basic NL source requests work only for trivial single-table/selector cases. For general NL-to-KQL or NL-to-IRQL, use a dedicated query-generation skill (available separately). ## Environment - **Cluster**: `https://kc7001.eastus.kusto.windows.net` - **Databases**: `ValdyTimes`, `JoJosHospital` (graph functions pre-deployed) - **Rendering**: Kusto Explorer desktop app (make-graph visualization window) - **Tool**: `kusto_query` (via Azure MCP Server) ### Function Preflight `Lift_To_Graph` and `Graph_Render_View` are stored functions, not built-in Kusto operators. Before generating or running a lift pipeline against a target database, check what is deployed: ```kql .show functions | where Name in~ ("Lift_To_Graph", "Graph_Render_View", "Graph_Fold_By_Property") | project Name ``` - `Lift_To_Graph` and `Graph_Render_View` are required. - `Graph_Fold_By_Property` is required only when folding is requested. - Check any `Extract_Node_*`, `Enrich_Node_*`, or `Enrich_Graph_*` function before using it; omit optional enrichment when unavailable unless the user wants it deployed. - If a required function is missing and you have permission to alter the database, **ask the user for confirmation before deploying**. Then use the `.create-or-alter function` definitions in [references/DEPLOY_IRQL_FUNCTIONS.md](references/DEPLOY_IRQL_FUNCTIONS.md). Run the relevant `.create-or-alter` block, then rerun the preflight check to confirm. - If you do not have alter permissions, tell the user which functions are missing and point them to `references/DEPLOY_IRQL_FUNCTIONS.md` for manual deployment. ## IRQL Graph Function Family ### `Lift_To_Graph(T, mappingJson)` Transforms any tabular KQL result into a unified node + edge table. **Input**: Any table `T` + a JSON mapping string. **Output**: Rows with `EntityType` = `"node"` or `"edge"`, ready for `make-graph`. ### `Graph_Render_View(T)` Takes `Lift_To_Graph` output, splits nodes/edges, and calls `make-graph` to open Kusto Explorer's graph window. ### `Graph_Fold_By_Property(T, NodeType, PropertyName)` Collapses nodes of a given type sharing a property value into a single node. Rewires edges automatically. ### Graph Extraction and Enrichment Functions These are additional stored functions that must already be deployed on the target database. They are **not** bundled in `references/DEPLOY_IRQL_FUNCTIONS.md`. Use `.show functions` to verify availability before including in a pipeline. | Function | Operation | Key Property | |---|---|---| | `Extract_Node_Email_Sender_Domain(T, displayName)` | Adds `Domain` to node props | `EmailSender` | | `Extract_Node_Employee_Firstname(T, displayName)` | Adds `Firstname` to node props | `Name` | | `Extract_Node_Event_Network_Domain(T, displayName)` | Adds `DomainName` to node props | `Url` | | `Enrich_Node_Ip_Employee(T, displayName)` | Adds employee info to IP nodes | `ClientIp` | | `Enrich_Node_Username_Employee(T, displayName)` | Adds employee info to user nodes | `Username` | | `Enrich_Node_Event_Authentication_Username(T, displayName)` | Adds auth context | `Username` | | `Enrich_Node_Ip_Domain(T, displayName)` | Adds DNS domains | `ClientIp` | | `Enrich_Node_Ip_Event_NetworkOutbound(T, displayName)` | Adds outbound events | `ClientIp` | | `Enrich_Graph_Ip_Employee(T, mappingJson)` | Expands graph with employee nodes | `ClientIp` | | `Enrich_Graph_Username_Employee(T, mappingJson)` | Expands graph with employee nodes | `Username` | | `Enrich_Graph_Event_Authentication_Username(T, mappingJson)` | Expands with auth nodes | `Username` | ## Mapping JSON Schema The JSON mapping has two arrays: `node_types` and `edges`. ### `node_types[]` | Field | Required | Description | |---|---|---| | `type` | Yes | Node type label (e.g. `"User"`, `"Host"`, `"IP"`) | | `id` | Yes | Prefix for node ID; usually same as type | | `key` | Yes | Column name whose value becomes the node's identity | | `props` | Yes | Array of columns to carry as node properties | | `defaults` | No | Object of fallback values for null/empty properties | | `defIcon` | No | Default icon URL for this node type | | `displayName` | No | Column to use for display label (defaults to `id`) | | `color` | No | Column to source color from | | `size` | No | Column to source size from | ### `edges[]` | Field | Required | Description | |---|---|---| | `type` | Yes | Edge type label (e.g. `"AuthenticatesTo"`, `"SentEmail"`) | | `source` | Yes | `{"id": "<prefix>", "type": "<NodeType>"}` | | `target` | Yes | `{"id": "<prefix>", "type": "<NodeType>"}` | | `props` | No | Array of columns to carry as edge properties | | `displayName` | No | Column for edge label | | `color` | No | Column for edge color | ### Icon Repository Use icons from `https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/`: - IP: `Public-IP-Addresses-(Classic).svg` - Host/VM: `Virtual-Machine.svg` - User: `Users.svg` - Email: `Mailbox.svg` (or `azure-cds/command-1070-Mail.svg`) - Process: `App-Services.svg` - File: `Storage-Accounts.svg` - Alert: `Activity-Log.svg` - Domain: `DNS-Zones.svg` ## Mapping Generation Rules Given the supplied query columns and the user's graph description, generate the mapping JSON by: 1. **Identify entities** -> each distinct noun becomes a `node_type` 2. **Identify relationships** -> each verb/preposition becomes an `edge` 3. **Map to columns** -> use actual columns produced by the supplied query; never assume unavailable columns 4. **Set direction** -> source is the actor, target is the acted-upon 5. **Add properties** -> include columns relevant to investigation (timestamps, results, hashes) 6. **Assign icons** -> pick from the icon set above based on entity type ### Column Reference (IRQL unified schema) | Entity | Key Column | Available Props | |---|---|---| | User | `Username` | `Username`, `Name`, `Role`, `Email` | | Host | `Hostname` | `Hostname` | | IP | `ClientIp` | `ClientIp` | | Email Message | `Subject` | `EnvTime`, `Subject`, `Verdict`, `Url` | | Sender | `EmailSender` | `EmailSender`, `Domain` | | Recipient | `EmailRecipient` | `EmailRecipient` | | Process | `ProcessName` | `EnvTime`, `ProcessName`, `ProcessCommandLine`, `ProcessHash` | | File | `Filename` | `EnvTime`, `Filename`, `Path`, `Sha256` | | Domain | `DomainName` | `DomainName` | | Auth Event | (synthetic ID) | `EnvTime`, `UserAgent`, `Result`, `Description` | ## Function Selection 1. Start with the supplied KQL/IRQL tabular pipeline. 2. Use `Lift_To_Graph(mapping)` to create graph entities. 3. Add `Extract_Node_*`, `Enrich_Node_*`, or `Enrich_Graph_*` only when requested and compatible with the mapped keys. 4. Add `Graph_Fold_By_Property()` only when grouping/collapse is requested. 5. End visual output with `Graph_Render_View()`. 6. Preflight the exact stored functions selected for the pipeline. ## Pipeline Pattern ```kql // 1. Preserve the supplied KQL or IRQL query <input query> // 2. Lift to graph | invoke Lift_To_Graph(<mapping_json>) // 3. Optionally extract or enrich graph entities | invoke <Extract_Node_* | Enrich_Node_* | Enrich_Graph_*>() // 4. Optionally fold nodes when requested | invoke Graph_Fold_By_Property("<NodeType>", "<PropertyName>") // 5. Render | invoke Graph_Render_View() ``` ## Examples For additional prompts and worked examples, see [references/EXAMPLES.md](references/EXAMPLES.md). ### Authentication graph: IP -> AuthEvent -> User -> Host **Input query**: `Get_Event_Authentication_All | where Result == "Failed Login" | take 200` **Graph request**: "Show IPs, authentication events, users, and hosts; fold events by result." ```kql let auth_mapping = '{"node_types":[{"type":"SrcIp","id":"SrcIp","key":"ClientIp","props":["ClientIp"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/Public-IP-Addresses-(Classic).svg"},{"type":"Host","id":"Host","key":"Hostname","props":["Hostname"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/Virtual-Machine.svg"},{"type":"User","id":"User","key":"Username","props":["Username"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/Users.svg"},{"type":"AuthEvent","id":"AuthEvent","key":"AuthEventId","props":["AuthEventId","EnvTime","UserAgent","Result","Description"],"defaults":{"Result":"unknown"},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/Activity-Log.svg"}],"edges":[{"type":"RequestsAuth","source":{"id":"SrcIp","type":"SrcIp"},"target":{"id":"AuthEvent","type":"AuthEvent"},"props":["EnvTime"]},{"type":"TargetsUser","source":{"id":"AuthEvent","type":"AuthEvent"},"target":{"id":"User","type":"User"},"props":["EnvTime"]},{"type":"AgainstHost","source":{"id":"AuthEvent","type":"AuthEvent"},"target":{"id":"Host","type":"Host"},"props":["EnvTime"]}]}'; Get_Event_Authentication_All | extend AuthEventId = strcat(Username, "_", Hostname, "_", EnvTime) | where Result == "Failed Login" | take 200 | invoke Lift_To_Graph(auth_mapping) | invoke Graph_Fold_By_Property("AuthEvent", "Result") | invoke Graph_Render_View() ``` ### Email graph: Sender -> Message -> Recipient **Input query**: `Get_Email_All | take 400` **Graph request**: "Visualize sender-to-message-to-recipient flow and fold messages by verdict." ```kql let mail_mapping = '{"node_types":[{"type":"EmailMessage","id":"Message","key":"Subject","props":["EnvTime","Subject","Verdict"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/Media-File.svg"},{"type":"Sender","id":"Email","key":"EmailSender","props":["EmailSender"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-cds/command-1070-Mail.svg"},{"type":"Recipient","id":"Email","key":"EmailRecipient","props":["EmailRecipient"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-cds/command-1070-Mail.svg"}],"edges":[{"type":"SentBy","source":{"id":"Message","type":"EmailMessage"},"target":{"id":"Email","type":"Sender"},"props":["EnvTime","Verdict"]},{"type":"DeliveredTo","source":{"id":"Message","type":"EmailMessage"},"target":{"id":"Email","type":"Recipient"},"props":["EnvTime","Verdict"]}]}'; Get_Email_All | take 400 | invoke Lift_To_Graph(mail_mapping) | invoke Graph_Fold_By_Property("EmailMessage", "Verdict") | invoke Graph_Render_View() ``` ### Suspicious domain investigation (end-to-end) **Basic source request**: "Use outbound network events for these suspicious domains and graph IP-to-domain connections enriched with employee names." This is the limited fallback: one known selector, one extractor, and one direct filter. ```kql let suspicious_domain_mapping = '{"node_types":[{"type":"IP","id":"IP","key":"ClientIp","props":["ClientIp"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/Public-IP-Addresses-(Classic).svg"},{"type":"Domain","id":"Domain","key":"DomainName","props":["DomainName"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/DNS-Zones.svg"}],"edges":[{"type":"ConnectsTo","source":{"id":"IP","type":"IP"},"target":{"id":"Domain","type":"Domain"},"props":["EnvTime"]}]}'; Get_Event_NetworkOutbound | invoke Extract_Event_Network_Domain() | where DomainName has_any ("raisinkanes.com", "nothing-to-see-here.net", "totally-legit-domain.com") | invoke Lift_To_Graph(suspicious_domain_mapping) | invoke Enrich_Node_Ip_Employee("Name") | invoke Graph_Fold_By_Property("Domain", "DomainName") | invoke Graph_Render_View() ``` ### Process execution graph: User -> Process -> ParentProcess **Input query**: `Get_Event_Process_All | where ProcessCommandLine has "powershell" | take 300` **Graph request**: "Visualize process, parent process, host, and user relationships." ```kql let proc_mapping = '{"node_types":[{"type":"Process","id":"Proc","key":"ProcessName","props":["ProcessName","ProcessCommandLine","ProcessHash"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/App-Services.svg"},{"type":"ParentProcess","id":"Proc","key":"ParentProcessName","props":["ParentProcessName","ParentProcessHash"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/App-Services.svg"},{"type":"Host","id":"Host","key":"Hostname","props":["Hostname"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/Virtual-Machine.svg"},{"type":"User","id":"User","key":"Username","props":["Username"],"defaults":{},"defIcon":"https://raw.githubusercontent.com/benc-uk/icon-collection/master/azure-icons/Users.svg"}],"edges":[{"type":"SpawnedBy","source":{"id":"Proc","type":"Process"},"target":{"id":"Proc","type":"ParentProcess"},"props":["EnvTime"]},{"type":"RanOn","source":{"id":"Proc","type":"Process"},"target":{"id":"Host","type":"Host"},"props":["EnvTime"]},{"type":"ExecutedBy","source":{"id":"Proc","type":"Process"},"target":{"id":"User","type":"User"},"props":["EnvTime"]}]}'; Get_Event_Process_All | where ProcessCommandLine has "powershell" | take 300 | invoke Lift_To_Graph(proc_mapping) | invoke Graph_Render_View() ``` ## Query Results -> Mapping Translation When the user supplies a query and describes the graph: 1. Inspect the query's final output columns 2. Parse the entity nouns and relationship verbs 3. Generate the mapping JSON using only those columns 4. Preserve the supplied pipeline and append `Lift_To_Graph()` 5. Include `Graph_Render_View()` at the end 6. If the user mentions grouping/collapsing and the function exists, add `Graph_Fold_By_Property()` Output the complete KQL -- the supplied query plus mapping JSON inline as a string `let` binding -- after the required-function preflight passes. Clearly mark unverified function dependencies when the target database cannot be checked. ## Opening Queries in Kusto Explorer (Windows Only) > **Optional convenience feature.** The default workflow is to output the KQL in chat and let the user copy it into Kusto Explorer or the VS Code Kusto extension manually. Auto-launch is opt-in only. Always output the complete KQL query in the chat response with Step 1 (connect) and Step 2 (query) clearly labeled: ``` // Step 1: Connect to your cluster (skip if already connected) // Example: uncomment to connect to the KC7 training cluster // #connect cluster('kc7001.eastus.kusto.windows.net').database('ValdyTimes') // Or replace with your own cluster: // #connect cluster('<YOUR_CLUSTER>').database('<YOUR_DATABASE>') // Step 2: Run the query below <KQL_QUERY> ``` If the user asks to save or open in Kusto Explorer, follow the procedure in [references/KUSTO_EXPLORER_LAUNCH.md](references/KUSTO_EXPLORER_LAUNCH.md). Key rules: - Use `ask_user` to confirm before writing files or launching executables - Display file contents in chat so the user can review before opening - Never use shell interpolation or here-strings — write files via `Set-Content`/`Add-Content` - Never encode queries into browser URLs - On macOS/Linux, save the `.kql` file and suggest the VS Code Kusto extension or ADX Web Explorer
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.