Amazon ElastiCache Redis ULM アプリケーションのログとメトリクスの収集
Amazon ElastiCache Redis ULM アプリケーションは、CloudTrail イベント ログと CloudWatch ログのモニタリングに使用します。メトリクスにより、メモリ内のデータベース リソースの利用状況とスループットのパフォーマンスをモニタリングできます。CloudTrail イベントにより、ユーザによる Amazon ElastiCache Redis サービスとオペレーションの使用をモニタリングできます。
このページでは、Amazon ElastiCache Redis ULM アプリケーションでログとメトリクスを収集する手順を説明します。リンクをクリックして、トピックに移動してください。
- ステップ 1: Source Category の計画
- ステップ 2: AWS CloudTrail Source を使用した AWS CloudTrail イベントの収集
- ステップ 3: AWS CloudWatch メトリクス Source を使用した Amazon ElastiCache メトリクスの収集
- ステップ 4: AWS SNS を使用した Amazon ElastiCache イベントの収集
- ログ メッセージのサンプル
- クエリのサンプル
ステップ 1.Source Category の計画
Amazon ElastiCache Redis ULM 用の Sumo Logic アプリケーションのログ Source とメトリクス Source を設定する前に、それぞれに割り当てる Source Category を決める必要があります。次に示すように、階層的なアプローチを採用すると、検索の実行時にワイルドカードを使用できるのでお勧めです。
- CloudTrail イベント用の AWS CloudTrail Source には、Source Category として
AWS/CloudTrail
を使用します。 - CloudWatch メトリクスを収集するための AWS CloudWatch メトリクス Source には、Source Category として
AWS/ElastiCache/Metric
を使用します。 - SNS 経由の AWS ElastiCache には、Source Category として
AWS/ElastiCache/Events/Notifications
を使用します。
ステップ 2.AWS CloudTrail Source を使用した AWS CloudTrail イベントの収集
このセクションでは、Hosted Collector を設定して CloudTrail イベントを収集するための AWS CloudTrail Source を追加する方法を説明します。
Hosted Collector を設定して AWS CloudTrail Source を追加するには、次の手順を実行します。
-
Hosted Collector を設定します。
-
次の情報を入力して、Hosted Collector に AWS CloudTrail Source を追加します。
-
Name (名前)—新しい Source に表示する名前を入力します。
-
Description (説明)—説明 (省略可能) を入力します。
-
S3 Region (S3 リージョン)—SCloudTrail Amazon ElastiCache S3 バケットの Amazon リージョンを選択します。
-
Bucket Name (バケット名)—CloudTrail Amazon ElastiCache S3 バケットの名前を正確に入力します。
-
Path Expression (パス式)—収集する S3 オブジェクトに一致する文字列を入力します。この文字列では、ワイルドカードを 1 つ使用できます。(先頭にスラッシュを付けないでください。「Amazon パス式」参照。) S3 バケット名はパスに含まれません。パス式を設定するときはバケット名を含めないでください。
-
Source Category—Source Category を入力します。例: AWS/Cloudtrail
-
Access Key ID and Secret Access Key (アクセス キー ID とシークレット アクセス キー)—Amazon のアクセス キー ID とシークレット アクセス キーを入力します。
-
Scan Interval (スキャン間隔)—デフォルトの 5 分を使用します。または、Sumo Logic が S3 バケットをスキャンして新しいデータがないか確認する間隔を入力します。
-
Enable Timestamp Parsing (タイムスタンプの parse を有効にする)—チェックボックスをオンにします。
-
Time Zone (タイム ゾーン)—[Ignore time zone from log file and instead use (ログ ファイルのタイム ゾーンを無視して、次を使用します)] を選択して、[UTC] を選択します。
-
Timestamp Format (タイムスタンプの形式)—[Automatically detect the format (自動的に形式を検出)] を選択します。
-
Enable Multiline Processing (複数行の処理の有効化)—チェックボックスをオンにして [Infer Boundaries (境界を推測する)] を選択します。
-
- [Save (保存)] をクリックします。
ステップ 3.AWS CloudWatch メトリクス Source を使用した Amazon ElastiCache メトリクスの収集
このセクションでは、Hosted Collector を設定して、CloudWatch メトリクスを収集するための Amazon CloudWatch メトリクス Source を追加する方法を説明します。
Hosted Collector を設定して Amazon CloudWatch メトリクス Source を追加するには、次の手順を実行します。
-
Hosted Collector を設定します。
-
次の情報を入力して、Amazon CloudWatch メトリクス Source を設定します。
-
Name (名前)—新しい Source に表示する名前を入力します。
-
Description (説明)—説明 (省略可能) を入力します。
-
Region (リージョン)—Amazon RDS の Amazon リージョンを選択します。
-
Namespaces (名前空間)—[AWS/ElastiCache] を選択します。
-
Source Category—Source Category を入力します。例: AWS/ElastiCache/メトリクス
-
Access Key ID and Secret Access Key (アクセス キー ID とシークレット アクセス キー)—Amazon のアクセス キー ID とシークレット アクセス キーを入力します。
-
Scan Interval (スキャン間隔)—Sumo Logic が CloudWatch Source をスキャンして新しいデータがないか確認する間隔として、デフォルトの 5 分を使用するか、または別の間隔を入力します。
-
- [Save (保存)] をクリックします。
ステップ 4: AWS SNS を使用した Amazon ElastiCache イベントの収集
このセクションでは、Amazon Simple Notification Service (Amazon SNS) を使用して重要なクラスタ イベントに関する通知を Sumo に送信するように ElastiCache を設定する方法を説明します。
AWS SNS を使用して Amazon ElastiCache イベントを収集するには、次の手順を実行します。
-
Hosted Collector を設定します。
-
HTTP Source を設定します。
-
Name (名前)—新しい Source に表示する名前を入力します。
-
Description (説明)—説明 (省略可能) を入力します。
-
Source Category—Source Category (例:
AWS/ElastiCache/Events/Notifications
) を入力します。 -
Timestamp Parsing Settings (タイムスタンプ parse 設定):
-
Enable Timestamp Parsing (タイムスタンプ parse の有効化)— True
-
Timezone (タイムゾーン)—ログはデフォルトで UTC で送信され、自動検出できます
-
Timestamp Format (タイムスタンプ形式)—Auto Detect (自動検出)
-
-
チェックボックスをオフ—Enable Multiline Processing (複数行処理の有効化)
-
Enable One Message Per Request (リクエストごとに 1 つのメッセージを有効にする)
-
- [Save (保存)] をクリックします。
SNS 通知を受け取る Source EndPoint URL を書き留めます。 -
イベントを Sumo に転送する AWS アカウントで、まだ SNS Service を使用して SNS トピックを作成していない場合は作成します。SNS トピック ARN を書き留めます。
-
今作成した SNS トピックへのサブスクリプションを作成して、以下を指定します。
-
サブスクリプションの確認をリクエストして、Sumo Source EndPoint URL にメッセージが送信されたら以下を実行します。
-
Sumo の検索ボックスで以下を実行します。
_sourcecategory=AWS/ElastiCache/Events/Notifications SubscribeURL
-
Sumo で Source Category を確認して、サブスクリプションの確認に必要な [SubscribeURL] フィールド値を取得して、[Subscription confirmation URL (サブスクリプション確認 URL)] フィールドに入力します。
-
[AWS Account (AWS アカウント)] > [SNS service (SNS サービス)] で、作成したサブスクリプションを選択し、[Confirm Subscription (サブスクリプションを確認)] を選択して SubscribeURL を貼り付けてから [Confirm Subscription (サブスクリプションを確認)] をクリックします。
-
-
サブスクリプションを選択し、[Other Subscription actions (その他のサブスクリプション アクション)] または [Actions (アクション)] の下で [Edit Subscription Attributes (サブスクリプション属性を編集)] を選択し、[Raw Message Delivery (未処理メッセージの配信)] のチェックボックスをオンにして、[Set Subscription attributes (サブスクリプション属性を設定)] をクリックします。これにより、1 つのフィールドのみを未処理としてメッセージが Sumo に配信されます。
-
サブスクリプションが完成したら、AWS ElastiCache サービスに移動し、SNS を使用してイベント通知を転送する ElastiCache クラスタを選択して、ステップ 4 で書き留めたトピック名で SNS 通知のトピック* を設定します。
ログ メッセージのサンプル
Elasticache Redis 用の Amazon CloudTrail イベント のサンプル ログ ファイルを次に示します。
{"eventVersion":"1.05","userIdentity":{"type":"IAMUser","principalId":"A12345678904QEWUABG5Q","arn": "arn:aws:iam::123456789038:user/Nitin","accountId":"123456789038","accessKeyId":"A1234567890FHCUQYQRM","userName":"Nitin", "sessionContext":{"attributes":{"mfaAuthenticated":"true","creationDate":"2018-10-29T07:08:50Z"}},"invokedBy": "signin.amazonaws.com"},"eventTime":"2018-10-29T08:38:13Z","eventSource":"elasticache.amazonaws.com","eventName": "CreateCacheSubnetGroup","awsRegion":"us-west-1","sourceIPAddress":"49.48.90.17","userAgent":"signin.amazonaws.com", "requestParameters":{"cacheSubnetGroupName":"nitin-redis-subnet-grp1","subnetIds":["subnet-b33fc55e"]},"responseElements": {"cacheSubnetGroupDescription":" ","vpcId":"vpc-b12fc345","subnets":[{"subnetAvailabilityZone":{"name":"us-west-1a"}, "subnetIdentifier":"subnet-b33fc55e"}],"cacheSubnetGroupName":"nitin-redis-subnet-grp1"},"requestID": "c6a79737-1234-5678-bb74-9f27f56e6306","eventID":"70c2c865-1234-4567-893c-9800b91e2502","eventType":"AwsApiCall", "recipientAccountId":"123456789038"}
SNS 通知としての Amazon ElastiCache イベント のサンプル ログ ファイルを次に示します。
{"ElastiCache:ReplicationGroupScalingInStarted":"nitin-redis-cluster1"}
クエリのサンプル
次のログ クエリは、[Amazon ElastiCache Redis ULM - CloudTrail Event - Overview (Amazon ElastiCache Redis ULM - CloudTrail イベント - 概要)] ダッシュボードの [Event Status Trend (イベント ステータスの傾向)] パネルから引用されたものです。
(_sourceCategory=*cloudtrail* or _sourceCategory=*AWS_EAGLE*) "\"eventSource\":\"elasticache.amazonaws.com\"" | json "userIdentity", "eventSource", "eventName", "awsRegion", "sourceIPAddress", "userAgent", "eventType", "recipientAccountId", "requestParameters", "responseElements", "requestID", "errorCode", "errorMessage" nodrop | json field=userIdentity "type", "principalId", "arn", "userName", "accountId" nodrop | json field=userIdentity "sessionContext.attributes.mfaAuthenticated" as mfaAuthenticated nodrop | json field=requestParameters "replicationGroupId", "engine", "engineVersion" as req_replicationGroupId, req_engine, req_engineVersion nodrop | json field=responseElements "replicationGroupId", "engine", "engineVersion", "status" as res_replicationGroupId, res_engine, res_engineVersion, res_status nodrop | parse field=arn ":assumed-role/*" as user nodrop | parse field=arn "arn:aws:iam::*:*" as accountId, user nodrop | if (isEmpty(errorCode), "Success", "Failure") as eventStatus | if (isEmpty(userName), user, userName) as user | if (isEmpty(req_replicationGroupId), res_replicationGroupId, req_replicationGroupId) as replicationGroupId | if (isEmpty(req_engine), res_engine, req_engine) as engine | if (isEmpty(req_engineVersion), res_engineVersion, req_engineVersion) as engineVersion | where eventSource = "elasticache.amazonaws.com" | timeslice 6h | count by _timeslice, eventStatus, eventName | transpose row _timeslice column eventStatus, eventName
次のクエリ例は、[Amazon ElastiCache Redis ULM - Metric - Overview (Amazon ElastiCache Redis ULM - メトリクス - 概要)] ダッシュボードの [Cache Hit Rate (キャッシュヒット率)] パネルから引用されたものサンプルです。
_sourceCategory=AWS/ElastiCache/Metric Namespace=AWS/ElastiCache metric=CacheHits Statistic=Average !CacheClusterId=* !CacheNodeId=* | avg _sourceCategory=AWS/ElastiCache/Metric Namespace=AWS/ElastiCache metric=CacheMisses Statistic=Average !CacheClusterId=* !CacheNodeId=* | avg (#A / (#A + #B) * 100)
次のログ クエリは、[Amazon ElastiCache Redis ULM - Notifications Dashboard (Amazon ElastiCache Redis ULM - 通知ダッシュボード)] の [Recent Events (最近のイベント)] パネルから引用されたものです。
_sourceCategory=AWS/ElastiCache/SNSNotifications* Elasticache | json "Message" as msg nodrop | if (!isEmpty(msg), msg, _raw) as msg | parse field=msg "\"ElastiCache:*\":\"*\"" as event, clusterId nodrop | parse field=msg "\"Elasticache:*\":\"*\"" as event, clusterId nodrop | json field=msg "Total Slots Moved" as TotalSlotsMoved nodrop | json field=msg "Amount Of Node Groups That Will Be Removed" as AmountOfNodeGroupsThatWillBeRemoved nodrop | if (event matches "*Failed", "Failure", "Success") as status | timeslice 1s | count by _timeslice, event, clusterId, status | sort by _timeslice