Özel Ölçümler ve CloudWatch Alarmları
Lambda'dan kendi iş ve performans ölçümlerinizi göndermeyi, eşikler aşıldığında alarmları ve bildirimleri tetiklemeyi öğrenin.
Özel Ölçümler ve CloudWatch Alarmları, CoddyKit'te ücretsiz bir Serverless AWS Lambda Development dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Serverless AWS Lambda Development öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Serverless AWS Lambda Development kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
Beyond Default Metrics
Lambda publishes built-in metrics like invocations and errors, but your app has its own signals, such as orders processed or items failed. These are custom metrics.
Embedded Metric Format
The easiest way to emit metrics is the Embedded Metric Format (EMF): print structured JSON to logs and CloudWatch extracts metrics automatically.
{
"_aws": {
"CloudWatchMetrics": [{
"Namespace": "OrdersApp",
"Metrics": [{"Name": "OrdersProcessed", "Unit": "Count"}]
}]
},
"OrdersProcessed": 12
}Emitting EMF in Python
Build the EMF object and print it as JSON. No extra API call or latency is needed.
import json, time
def emit(count):
print(json.dumps({
'_aws': {
'Timestamp': int(time.time() * 1000),
'CloudWatchMetrics': [{
'Namespace': 'OrdersApp',
'Dimensions': [[]],
'Metrics': [{'Name': 'OrdersProcessed', 'Unit': 'Count'}]
}]
},
'OrdersProcessed': count
}))PutMetricData API
Alternatively call put_metric_data directly. This is synchronous and adds latency, so EMF is usually preferred for hot paths.
import boto3
cw = boto3.client('cloudwatch')
cw.put_metric_data(Namespace='OrdersApp',
MetricData=[{'MetricName': 'OrdersProcessed', 'Value': 1}])Dimensions Add Context
Dimensions are key-value tags that slice a metric, such as by region or customer tier. Keep dimension cardinality low to control cost.
What an Alarm Does
A CloudWatch alarm watches a metric and changes state when it breaches a threshold for a set number of periods, then triggers an action.
Creating an Alarm
This alarm fires when the error count exceeds 5 in a single one-minute period.
aws cloudwatch put-metric-alarm \
--alarm-name orders-errors \
--metric-name Errors \
--namespace AWS/Lambda \
--threshold 5 \
--comparison-operator GreaterThanThreshold \
--evaluation-periods 1 \
--period 60Notifying with SNS
Point the alarm action at an SNS topic so it emails, texts, or pages your on-call when triggered.
Alarm States
Alarms have three states: OK, ALARM, and INSUFFICIENT_DATA. The last means the metric had no data points in the window.
Avoid Alarm Fatigue
Too many noisy alarms train people to ignore them. Alarm on symptoms users feel, like error rate and latency, not every minor metric.
Dashboards Tie It Together
Build a CloudWatch dashboard combining built-in and custom metrics so you see the whole system health at a glance during an incident.
Quick Check
Test your metrics knowledge.
Recap
You learned to emit custom metrics via EMF or PutMetricData, add dimensions, create threshold alarms wired to SNS, and avoid alarm fatigue with dashboards.
Sıkça Sorulan Sorular
“Özel Ölçümler ve CloudWatch Alarmları” dersi ücretsiz mi?
Evet — “Özel Ölçümler ve CloudWatch Alarmları” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Serverless AWS Lambda Development kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Serverless AWS Lambda Development kursu toplamda 4 dersten oluşur.
“Özel Ölçümler ve CloudWatch Alarmları” dersinde ne öğreneceğim?
Lambda'dan kendi iş ve performans ölçümlerinizi göndermeyi, eşikler aşıldığında alarmları ve bildirimleri tetiklemeyi öğrenin. Serverless AWS Lambda Development ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Serverless AWS Lambda Development öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Serverless AWS Lambda Development, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.
“Özel Ölçümler ve CloudWatch Alarmları” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Serverless AWS Lambda Development dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Serverless AWS Lambda Development dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- CloudWatch Günlükleri ve Ölçümleri
- Hataları Yönetme ve Yeniden Denemeler
- Sunucusuz Uygulamalarda Hata Ayıklama
- Özel Ölçümler ve CloudWatch Alarmları