Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

Hoofdstuk 12Naam in de cursus: Monitor resources in Azure

Watch resources with Azure Monitor

Azure Monitor collects metrics (numbers over time) and logs (events and records) from every resource, lets you query them with KQL, shows them in dashboards and workbooks, and sends alerts to people and automation.

  • 5 Lessen
  • 2 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

Vaardigheden in dit hoofdstuk

  • Azure Monitor gebruiken: metrics, logs, KQL en alerts

12.1

Know metrics and logs

Metrics are light and fast (CPU %, requests per second). Logs are rich records you query (sign-ins, errors, syslog).

MetricsLogs
ContentNumbers with a time stampRecords with many fields
Kept by default93 daysIn a Log Analytics workspace, as long as you set
Query withMetrics explorerKQL in Log Analytics
Good forCharts, fast alertsInvestigation, correlation, reports
az monitor metrics list --resource VM_ID --metric "Percentage CPU" --interval PT5M -o table

Commando's in deze les

12.2

Collect logs in a workspace

Send logs to a Log Analytics workspace with diagnostic settings (platform resources) and the Azure Monitor Agent with data collection rules (VMs).

az monitor log-analytics workspace create -g rg-mon -n law-prod -l westeurope --retention-time 90
az monitor diagnostic-settings create -n to-law --resource KEYVAULT_ID --workspace law-prod -g rg-mon \
    --logs '[{"categoryGroup":"allLogs","enabled":true}]' --metrics '[{"category":"AllMetrics","enabled":true}]'
az vm extension set -g rg-web --vm-name vm-web1 --name AzureMonitorLinuxAgent --publisher Microsoft.Azure.Monitor

Then create a data collection rule that says which syslog facilities and performance counters to collect from which VMs.

Commando's in deze les

12.3

Query logs with KQL

KQL (Kusto Query Language) starts with a table and passes the rows through | steps — like a Linux pipe.

KQL examples
// VMs that did not send a heartbeat in the last 10 minutes
Heartbeat
| summarize LastSeen = max(TimeGenerated) by Computer
| where LastSeen < ago(10m)
 
// CPU over 80 % in the last hour
Perf
| where ObjectName == "Processor" and CounterName == "% Processor Time" and TimeGenerated > ago(1h)
| summarize AvgCPU = avg(CounterValue) by Computer, bin(TimeGenerated, 5m)
| where AvgCPU > 80
 
// Failed SSH logins from syslog
Syslog
| where Facility == "authpriv" and SyslogMessage has "Failed password"
| summarize Tries = count() by HostName, bin(TimeGenerated, 1h)
| order by Tries desc
OperatorDoes
whereFilter rows
projectChoose columns
summarize … by …Count, sum, average per group
extendAdd a computed column
order by / top N bySort / keep the first N
ago(1h), bin(TimeGenerated, 5m)Time helpers
render timechartDraw a chart

Commando's in deze les

12.4

Create alerts and action groups

An alert rule watches a signal (metric, log query, activity log). When it fires, an action group notifies people (email, SMS, app) or starts automation (webhook, Logic App, function).

az monitor action-group create -g rg-mon -n ag-ops --short-name ops --action email ops it-ops@example.com
az monitor metrics alert create -g rg-mon -n cpu-high --scopes VM_ID \
    --condition "avg Percentage CPU > 85" --window-size 5m --evaluation-frequency 1m --action ag-ops --severity 2
az monitor activity-log alert create -g rg-mon -n rg-deleted --scope /subscriptions/SUB_ID \
    --condition category=Administrative and operationName=Microsoft.Resources/subscriptions/resourceGroups/delete --action-group ag-ops
Alert typeWatches
Metric alertA metric over a threshold (fast)
Log search alertThe result of a KQL query
Activity log alertControl-plane events (create, delete, service health)

Op het werk

Alert processing rules silence alerts during planned maintenance, so nobody is woken up for a planned reboot.

Commando's in deze les

12.5

Use insights and workbooks

Ready-made views for common resources.

  • VM insights: performance and a map of processes and connections.
  • Storage / Key Vault / Network insights: health and use.
  • Workbooks: your own interactive reports from metrics and KQL.
  • Activity log: who did what on the control plane (create, delete, change) — kept 90 days.
  • Service Health: Azure outages and planned maintenance in your regions.

Alle commando's in dit hoofdstuk