The monitoring pieces
| Piece | Does | Example |
|---|---|---|
| Metrics | Numbers over time, near real-time | PipelineFailedRuns, storage transactions |
| Logs (Log Analytics) | Detailed records you query with KQL | ADFPipelineRun, ADFActivityRun tables |
| Diagnostic settings | Route a resource's logs/metrics somewhere | ADF β log-shopkart-dev |
| Alert rules | Evaluate metrics or log queries | Failed runs > 0 in 15 minutes |
| Action groups | Who/what to notify | Email the data team, call a webhook |
| Budgets (Cost Management) | Spend thresholds | βΉ5,000/month: alert at 80% actual, 100% forecast |
All of it as code
// Watch the platform: Log Analytics, ADF diagnostics, a failed-pipeline alert, and a monthly budget.
param location string = resourceGroup().location
param factoryName string
param alertEmail string
param monthlyBudgetInr int = 5000
param budgetStartDate string = '2026-12-01'
resource factory 'Microsoft.DataFactory/factories@2018-06-01' existing = {
name: factoryName
}
resource logs 'Microsoft.OperationalInsights/workspaces@2023-09-01' = {
name: 'log-shopkart-dev'
location: location
properties: { sku: { name: 'PerGB2018' }, retentionInDays: 30 }
}
resource adfDiagnostics 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
scope: factory
name: 'to-log-analytics'
properties: {
workspaceId: logs.id
logAnalyticsDestinationType: 'Dedicated' // ADFPipelineRun, ADFActivityRun tables
logs: [
{ category: 'PipelineRuns', enabled: true }
{ category: 'ActivityRuns', enabled: true }
{ category: 'TriggerRuns', enabled: true }
]
metrics: [ { category: 'AllMetrics', enabled: true } ]
}
}
resource team 'Microsoft.Insights/actionGroups@2023-01-01' = {
name: 'ag-shopkart-data-team'
location: 'global'
properties: {
groupShortName: 'shopkart'
enabled: true
emailReceivers: [ { name: 'data-team', emailAddress: alertEmail, useCommonAlertSchema: true } ]
}
}
resource failedRuns 'Microsoft.Insights/metricAlerts@2018-03-01' = {
name: 'alert-adf-failed-runs'
location: 'global'
properties: {
severity: 2
enabled: true
scopes: [ factory.id ]
evaluationFrequency: 'PT5M'
windowSize: 'PT15M'
criteria: {
'odata.type': 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria'
allOf: [
{
name: 'failed'
criterionType: 'StaticThresholdCriterion'
metricName: 'PipelineFailedRuns'
timeAggregation: 'Total'
operator: 'GreaterThan'
threshold: 0
}
]
}
actions: [ { actionGroupId: team.id } ]
}
}
resource budget 'Microsoft.Consumption/budgets@2023-11-01' = {
name: 'budget-shopkart-dev'
properties: {
category: 'Cost'
amount: monthlyBudgetInr
timeGrain: 'Monthly'
timePeriod: { startDate: budgetStartDate }
notifications: {
actual80: { enabled: true, operator: 'GreaterThan', threshold: 80, contactEmails: [ alertEmail ] }
forecast100: { enabled: true, operator: 'GreaterThan', threshold: 100, thresholdType: 'Forecasted', contactEmails: [ alertEmail ] }
}
}
}bicep lint monitoring.bicep β no warnings
bicep build monitoring.bicep β 5 resources: workspaces (Log Analytics), diagnosticSettings, actionGroups, metricAlerts, budgetsexisting references the factory deployed in lesson 4. logAnalyticsDestinationType: 'Dedicated' writes to resource-specific tables (ADFPipelineRun, ADFActivityRun) instead of one big AzureDiagnostics table: easier queries and lower cost.
KQL queries you'll use
// Not run here (needs a Log Analytics workspace). Failed pipeline runs in the last 24 hours:
ADFPipelineRun
| where TimeGenerated > ago(24h) and Status == "Failed"
| project TimeGenerated, PipelineName, RunId, FailureType
| order by TimeGenerated desc
// Which activity failed, and why
ADFActivityRun
| where TimeGenerated > ago(24h) and Status == "Failed"
| project TimeGenerated, PipelineName, ActivityName, ErrorMessage
// Slowest activities this week
ADFActivityRun
| where TimeGenerated > ago(7d) and Status == "Succeeded"
| extend minutes = datetime_diff('minute', End, Start)
| summarize avg_minutes = avg(minutes), runs = count() by PipelineName, ActivityName
| top 10 by avg_minutes| KQL | Like in SQL |
|---|---|
| where | WHERE |
| project | SELECT columns |
| extend | Add a computed column |
| summarize ... by | GROUP BY with aggregates |
| order by / top | ORDER BY / LIMIT |
| ago(24h) | NOW() - INTERVAL 24 HOURS |
Cost management habits
| Habit | Saves |
|---|---|
| Budgets with actual + forecast alerts per subscription/resource group | Surprises |
| Tags (project, env, owner) + cost analysis grouped by tag | Finding who spends what |
| Auto-pause (serverless SQL), auto-termination (Databricks), schedules | Idle compute |
| Lifecycle rules to cool/cold/archive tiers | Storage |
| Right-size: smaller SKUs in dev, reservations/savings plans for steady prod | Compute |
| Log Analytics retention and table plans (Basic/Auxiliary for verbose logs) | Monitoring costs |
| Keep data and compute in one region | Egress |
π― Interview questions on this topic
Try to answer out loud first, then tap to check.
Q1How do you get alerted when a Data Factory pipeline fails?Fresher+
Q2How do you keep long-term pipeline history and analyse it?1β3 yrs+
Q3Your Azure bill jumped 40% this month. How do you find out why?3+ yrs+
Key takeaways
- βCentralise logs in Log Analytics and learn a little KQL.
- βAlert through action groups; test that alerts actually arrive.
- βBudgets warn; auto-pause and lifecycle rules actually save.
- βMonitoring and budgets belong in Bicep too.
Frequently asked questions
Where do Data Factory run logs go?
The ADF Monitor hub keeps 45 days. For longer history, queries across factories and alerts on details, add a diagnostic setting that sends PipelineRuns, ActivityRuns and TriggerRuns to a Log Analytics workspace, then query them with KQL.
Metric alert or log alert?
Metric alerts (like PipelineFailedRuns > 0) are near real-time, cheap and simple. Log (scheduled query) alerts run a KQL query and can include details such as pipeline name and error text. Many teams use a metric alert for 'something failed' and dashboards/log queries for investigation.
Do budgets stop spending?
No. Azure budgets send alerts (and can trigger action groups or automation) when actual or forecasted spend crosses thresholds; they don't cap or shut down resources by themselves. Use them early, with auto-pause and auto-termination on compute.
What is KQL?
Kusto Query Language, used by Log Analytics, Azure Data Explorer and Fabric Real-Time Intelligence. Queries read like a pipeline: table | where ... | summarize ... | order by ...
π§ Quick check: monitoring and cost
1. Keep ADF run history for a year and query it. Use...
2. Who gets the alert email?
3. An Azure budget reaching 100%...
4. Which table holds ADF pipeline runs in resource-specific mode?
Checking your accessβ¦