Lesson 56 — Automating Suspicious IP Investigations
Turn a suspicious IP address in a Sentinel incident into a repeatable, evidence-first investigation. Collect identity activity, compare approved context and produce an analyst-ready summary — without automatically blocking a legitimate service.

What you will learn
Build a controlled IP investigation playbook.
The case — one IP, several possible explanations
A Microsoft Sentinel incident flags repeated sign-in failures from an unfamiliar IP address. Is it hostile infrastructure, a shared VPN gateway, a corporate proxy or simply an outdated reference entry? Agent Foskett's playbook gathers the available evidence, records its limits and asks an analyst to decide.
Learning objectives
- Extract IP entities safely from an incident-triggered playbook.
- Separate internal, private and public address handling.
- Correlate the address with available Entra sign-in telemetry.
- Compare the address against an approved Sentinel watchlist.
- Produce a sourced investigation summary and preserve analyst approval for response.
Investigation flow
Prerequisites and safe lab setup
- Complete Lessons 53–55 or have equivalent Sentinel automation and Logic Apps experience.
- Use a dedicated lab incident and approved test IP address.
- Confirm Microsoft Sentinel connector, Logic Apps identity, Log Analytics query permissions and watchlist access.
- Keep the workflow read-only except for an incident comment or approved tag.
- Never automatically block an IP, disable an account or close an incident in this lab.
Step 1 — Define the investigation question
For each address, answer: Where did we observe it, when, for which identities, and what does our trusted context say? A reputation score by itself is not proof of compromise. Decide the lookback window, maximum number of entities and acceptable query latency before building.
Step 2 — Make a separate lab playbook
- Copy the tested enrichment playbook from Lesson 55 into a new lab Logic App.
- Name it
AF-LAB-IP-Investigation. - Retain a narrowly scoped Sentinel incident trigger and automation rule.
- Record its owner, managed identity, resource group and rollback procedure.
- Verify that a test incident can invoke the workflow once.
Step 3 — Extract incident IP entities
Use the Microsoft Sentinel connector's supported incident entity action or the trigger's documented entity payload. Inspect a test run before referencing fields. An incident can contain several IPs, duplicate values or none at all. Handle each case explicitly.
Step 4 — Validate and classify addresses
- Trim whitespace, validate IPv4/IPv6 format and deduplicate exact values.
- Identify loopback, link-local, private, reserved and public address ranges using a tested IP classification method.
- Do not send internal addresses to an external reputation service by default.
- Apply a per-incident processing cap and report skipped addresses.
- Preserve the original address string for the audit record.
Step 5 — Define evidence boundaries
| Question | Evidence source | Important limitation |
|---|---|---|
| Which accounts used this address? | Entra SigninLogs, where ingested | Coverage and retention vary |
| Was access successful? | ResultType and sign-in details | A successful sign-in is not automatically malicious |
| Is it a known organization address? | Approved Sentinel watchlist | Reference data can be stale |
| What incident triggered the lookup? | Sentinel incident and entities | Entity association does not prove attribution |
Step 6 — Choose a time window
For the lab, inspect the previous 24 hours. In production, prefer an explicit incident-relative window when the relevant alert activity occurred earlier. Label the window in every output, and distinguish event time from playbook execution time.
Step 7 — KQL: inspect sign-in activity for one IP
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
let TargetIP = "203.0.113.10";
let Lookback = 24h;
SigninLogs
| where TimeGenerated >= ago(Lookback)
| where IPAddress == TargetIP
| summarize Attempts = count(),
Successful = countif(ResultType == "0"),
Failed = countif(ResultType != "0"),
FirstSeen = min(TimeGenerated),
LastSeen = max(TimeGenerated)
by UserPrincipalName, AppDisplayName
| order by Attempts descReplace the documentation-only address with your approved lab IP. This query runs in the workspace Logs experience; do not assume a Logic Apps action can execute it until its connector, permissions and parameter handling are configured.
Step 8 — Read the query results correctly
Attempts is the number of matching sign-in records, not the number of attackers. Successful and Failed describe sign-in outcomes, not whether activity was authorized. Review account type, application, conditional access details and corroborating evidence before drawing conclusions.
Step 9 — KQL: inspect the timeline
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
let TargetIP = "203.0.113.10";
SigninLogs
| where TimeGenerated >= ago(24h)
| where IPAddress == TargetIP
| project TimeGenerated, UserPrincipalName,
AppDisplayName, ResultType,
ResultDescription, ConditionalAccessStatus,
CorrelationId
| order by TimeGenerated asc
| take 200The row cap keeps the lab view manageable. State when results are truncated; a timeline of 200 rows is not necessarily the complete history.
Step 10 — KQL: check approved watchlist context
- 1
- 2
- 3
- 4
- 5
- 6
let TargetIP = "203.0.113.10";
_GetWatchlist("SOC-IP-Context")
| where SearchKey == TargetIP
| project SearchKey, TimeGenerated
| take 20Replace the watchlist alias with the one configured in your workspace. Inspect additional columns before using them; watchlist fields are organization-defined. A match is context, not a benign verdict.
Step 11 — Query from Logic Apps safely
- Choose a supported Azure Monitor Logs / Log Analytics query action available in your environment.
- Configure the intended workspace and least-privilege identity.
- Pass the validated IP through the supported query input or safe parameterization mechanism.
- Use a bounded time window and reasonable result cap.
- Inspect the action's actual output schema before parsing rows.
Do not concatenate unvalidated incident text into KQL. Confirm connector authentication and query permissions with a controlled test.
Step 12 — Handle no-data results
If SigninLogs returns zero rows, write “No matching sign-in records found in the queried workspace and time window”, not “IP is safe.” If the table is unavailable, report a coverage gap rather than a negative finding.
Step 13 — Preserve lookup provenance
Record the workspace, table, query time, event window, watchlist alias, result count and any connector errors. If you use approved external threat intelligence, include the provider and observation timestamp, and avoid forwarding sensitive incident data without authorization.
Step 14 — Build a structured investigation summary
Use dynamic content from successful, validated actions. Never print access tokens, secret values or unredacted sensitive details in broadly visible comments.
Step 15 — Add a comment, not a verdict
Use the supported Sentinel incident comment action to attach the summary. Clearly mark it as automated context. Do not change severity, owner, status or classification based solely on an IP lookup.
Step 16 — Avoid duplicate comments
Automation can run again when an incident changes. Define a repeat-run strategy: record a workflow version and execution marker, compare an existing marker when feasible, or use a controlled trigger condition. Avoid creating an endless update → automation → comment cycle.
Step 17 — Design failure paths
| Failure | Safe behaviour |
|---|---|
| No IP entity | Skip lookup; record why |
| Malformed or reserved address | Use local-only context or skip |
| Query permission denied | Report unavailable evidence |
| Rate limit or timeout | Bound retries; flag incomplete result |
| Watchlist missing | Do not infer trust |
| Multiple IPs | Deduplicate, cap and disclose limit |
Step 18 — Test with controlled scenarios
- Incident with one valid public test IP.
- Incident with two duplicate IP entities.
- Incident with a private address.
- Incident with no IP entity.
- Incident with an IP that has no matching sign-in records.
- Simulated query failure or missing watchlist.
- Repeated invocation against the same incident.
For each test, inspect Logic Apps run history and the final Sentinel incident comment.
Step 19 — Review permissions and privacy
Keep read access scoped to the required workspace and write access limited to the intended incident action. Verify the playbook's identity and connector permissions separately. Limit retention of execution inputs/outputs that contain identifiers and follow your organization's privacy policy.
Step 20 — Performance and cost controls
Use narrow query windows, bounded row counts, capped entity loops and controlled retry policies. Query execution, Logic Apps actions and external lookups can have cost and throttling implications. Monitor failed runs and processing time before broad deployment.
Agent Foskett case file — The trusted address
The watchlist labels the address “Trusted VPN”. The automated summary also finds failed sign-ins against several accounts and one successful sign-in. A rushed workflow might close the incident as harmless. Agent Foskett checks the reference entry's owner and age, then reviews the actual identity evidence.
Finding: a trusted infrastructure label does not establish that every activity originating from it is authorized.
Hands-on challenge
- Copy your Lesson 55 enrichment playbook.
- Extract and validate an IP entity.
- Query a 24-hour sign-in window in the lab.
- Compare against your approved watchlist.
- Build an evidence summary with source and time details.
- Post a comment to the test incident.
- Test the missing-data and repeated-run cases.
- Write the analyst's next two investigation pivots.
Publishing and operational checklist
- Inputs validated; internal and reserved addresses handled appropriately.
- KQL outputs verified against source records.
- Lookback window, row caps and missing data disclosed.
- Least-privilege connector identities confirmed.
- Comment text identifies automated context, not a verdict.
- Repeat runs and failure paths tested.
- No automatic blocking, account changes or incident closure.
- Rollback and ownership documented.
Agent Foskett takeaway
Automate the collection of evidence, not the assumption of guilt. A suspicious IP is a starting point. Good automation tells an analyst what was observed, what remains unknown and where to investigate next.
The logs already knew. Agent Foskett checked the context.
