Amazon Aurora PostgreSQL ULM アプリケーションでのログとメトリクスの収集
Aurora PostgreSQL ULM アプリケーションには、Aurora PostgreSQL データベースのログやメトリクスのモニタリングに使用できる定義済みの検索とダッシュボードが用意されています。ログにより、データベース アクティビティ、ユーザ アクティビティ、被接続数、クエリ実行時間、エラーをモニタリングできます。メトリクスにより、データベース リソースの利用状況とスループットのパフォーマンスをモニタリングできます。
このガイドでは、Aurora PostgreSQL ULM アプリケーションで定義されているクエリやダッシュボードの概要、Aurora PostgreSQL からログとメトリクスを収集する手順、そしてアプリケーションのインストール方法について説明します。
このページでは、Aurora PostgreSQL データベースから収集するログとメトリクスについて説明し、クエリの例を示すと共に、ログとメトリクスの収集をセットアップする方法を説明します。リンクをクリックして、トピックに移動してください。
ログとメトリクスのタイプ
Aurora PostgreSQL ULM 用の Sumo Logic アプリケーションは、以下のログとメトリクスを使用します。
ログの例
AWS CloudTrail ログの例を以下に示します。
{"eventVersion":"1.05","userIdentity":{"type":"IAMUser","principalId":"AI1234567890QEWUABG5Q", "arn":"arn:aws:iam::951234567898:user/bwilliams","accountId":"951234567898","accessKeyId": "ABCDEFGHIHFBOT4FDVK","userName":"jjones","sessionContext":{"attributes":{"mfaAuthenticated": "true","creationDate":"2018-11-05T11:22:45Z"}},"invokedBy":"signin.amazonaws.com"},"eventTime": "2018-11-12T06:56:02Z","eventSource":"rds.amazonaws.com","eventName":"DeleteDBCluster","awsRegion" :"us-east-3","sourceIPAddress":"19.174.45.8","userAgent":"signin.amazonaws.com","requestParameters" :{"dBClusterIdentifier":"nitinpsql968cluster01","skipFinalSnapshot":false,"finalDBSnapshotIdentifier" :"psqldb968nitin02-final-snapshot"},"responseElements":{"allocatedStorage":1,"availabilityZones" :["us-east-1a","us-east-1b","us-east-1c"],"backupRetentionPeriod":2,"databaseName":"nitintestdpsql1", "dBClusterIdentifier":"nitinpsql968cluster01","dBClusterParameterGroup":"default.aurora-postgresql9.6", "dBSubnetGroup":"default-vpc-b81fc4d7","status":"available","earliestRestorableTime":"Nov 5, 2018 2:17:31 PM", "endpoint":"nitinpsql968cluster01.cluster-ci123456789d.us-east-3.rds.amazonaws.com","readerEndpoint" :"nitinpsql968cluster01.cluster-ro-ci123456789d.us-east-1.rds.amazonaws.com","multiAZ":false,"engine" :"aurora-postgresql","engineVersion":"9.6.8","latestRestorableTime":"Nov 5, 2018 3:36:06 PM","port" :5432,"masterUsername":"npandepsql","preferredBackupWindow":"08:59-09:29","preferredMaintenanceWindow" :"sun:08:09-sun:08:39","readReplicaIdentifiers":[],"dBClusterMembers":[{"dBInstanceIdentifier":"psqldb968nitin02" ,"isClusterWriter":true,"dBClusterParameterGroupStatus":"in-sync","promotionTier":1}],"vpcSecurityGroups" :[{"vpcSecurityGroupId":"sg-0e81530fe36e37076","status":"active"}],"hostedZoneId":"Z2R2ITUGPM61AM", "storageEncrypted":true,"kmsKeyId":"arn:aws:kms:us-west-3:951234567898:key/9a3d8016-4cdb-478f-a3a4-9a310fc25307", "dbClusterResourceId":"cluster-LXLBREEIXOAMLSUUDXVKXFVIDA","dBClusterArn":"arn:aws:rds:us-west-2:951234567898:cluster:nitinpsql968cluster01", "associatedRoles":[],"iAMDatabaseAuthenticationEnabled":false,"clusterCreateTime":"Nov 5, 2018 2:16:12 PM","engineMode" :"provisioned","deletionProtection":false,"httpEndpointEnabled":false},"requestID":"0df6f69d-8040-45fa-9171-98043977a14c", "eventID":"ab48927c-7bd8-4c1d-9d86-0b2f6732949c","eventType":"AwsApiCall","recipientAccountId":"951234567898"}
クエリの例
このセクションでは、ダッシュボードのパネルから引用したログ クエリとメトリクス クエリの例を示します。
ログ クエリの例
次のログ クエリは、[CloudTrail Event - Overview (CloudTrail イベント - 概要)] ダッシュボードの [Event Status Trend (イベント ステータスの傾向)] パネルから引用されたものです。
(_sourceCategory=*cloudtrail* or _sourceCategory=*AWS_EAGLE*) "\"eventSource\":\"rds.amazonaws.com\"" ("\"engine\":\"aurora-postgresql\"") | 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 "dBClusterIdentifier", "engine", "engineMode" as req_dBClusterIdentifier, req_engine, req_engineMode nodrop | json field=responseElements "dBClusterIdentifier", "engine", "engineMode" as res_dBClusterIdentifier, res_engine, res_engineMode 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_dBClusterIdentifier), res_dBClusterIdentifier, req_dBClusterIdentifier) as dBClusterIdentifier | if (isEmpty(req_engine), res_engine, req_engine) as engine | if (isEmpty(req_engineMode), res_engineMode, req_engineMode) as engineMode | where eventSource = "rds.amazonaws.com" and (req_engine in ("aurora-postgresql") or res_engine in ("aurora-postgresql")) | timeslice 6h | count by _timeslice, eventStatus, eventName | transpose row _timeslice column eventStatus, eventName
メトリクス クエリの例
次のメトリクス クエリは、[Metric - Overview (メトリクス - 概要)] ダッシュボードの [Volume Write IOPS (ボリューム書き込み IOPS)] パネルから引用されたものです。
_sourceCategory=AWS/RDS/Metric Namespace=AWS/RDS metric=VolumeWriteIOPs DBClusterIdentifier=* Statistic=Average | avg by DBClusterIdentifier
ログとメトリクスの収集の設定
Aurora PostgreSQL ULM アプリケーションは、CloudTrail イベント ログと CloudWatch ログのモニタリングに使用します。メトリクスにより、データベース リソースの利用状況とスループットのパフォーマンスをモニタリングできます。CloudTrail イベントにより、ユーザによる Aurora サービスとオペレーションの使用をモニタリングできます。
このセクションでは、Aurora PostgreSQL ULM 用の Sumo Logic アプリケーションでログとメトリクスを収集する手順を説明します。
- ステップ 1: AWS CloudTrail Source を使用した AWS CloudTrail イベントの収集
- ステップ 2: AWS CloudWatch メトリクス Source を使用した Aurora CloudWatch メトリクスの収集
ステップ 1: AWS CloudTrail Source を使用した AWS CloudTrail イベントの収集
このセクションでは、イベントを収集して Sumo Logic に取り込むための AWS CloudTrail Source のセットアップ方法を説明します。
AWS CloudTrail イベントを収集するには、以下の手順を実行します。
- Hosted Collector を設定します。
-
次の情報を入力して、Hosted Collector に AWS CloudTrail Source を追加します。
- Name (名前) - 新しい Source に表示する名前を入力します。
- Description (説明) - 説明 (省略可能) を入力します。
- S3 Region (S3 リージョン) - CloudTrail Aurora S3 バケットの Amazon リージョンを選択します。
- Bucket Name (バケット名) - CloudTrail Aurora 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 (スキャン間隔): Sumo Logic が S3 バケットをスキャンして新しいデータがないか確認する間隔として、デフォルトの 5 分を使用するか、または別の間隔を入力します。
- Enable Timestamp Parsing (タイムスタンプの parse を有効にする) - 有効にするにはチェックボックスをオンにします。
- Time Zone (タイムゾーン) - [Ignore time zone from log file and instead select UTC (ログ ファイルのタイムゾーンを無視して UTC を使用する)] をオフにします。
- Timestamp Format (タイムスタンプの形式) - [Automatically detect the format (自動的に形式を検出)] を選択します。
- Enable Multiline Processing (複数行の処理の有効化) - チェックボックスをオンにして [Infer Boundaries (境界を推測する)] を選択します。
- [Save (保存)] をクリックします。
ステップ 2: AWS CloudWatch メトリクス Source を使用した Aurora CloudWatch メトリクスの収集
このセクションでは、AWS CloudWatch メトリクス Source を使用して Aurora CloudWatch メトリクスを収集して Sumo Logic に取り込むためのセットアップ方法を説明します。
Aurora CloudWatch メトリクスを収集するには、以下の手順を実行します。
- Hosted Collector を設定します。
-
次の情報を入力して、Amazon CloudWatch メトリクス Source を設定します。
- Name (名前) - 新しい Source に表示する名前を入力します。
- Description (説明) - 説明 (省略可能) を入力します。
- Region (リージョン) - Amazon RDS の Amazon リージョンを選択します。
- Namespaces (名前空間) - [AWS/RDS] を選択します。
- Source Category - Source Category (例: AWS/RDS/Metric) を入力します。
- Access Key ID and Secret Access Key (アクセス キー ID とシークレット アクセス キー) - Amazon のアクセス キー ID とシークレット アクセス キーを入力します。
- Scan Interval (スキャン間隔) - Sumo Logic が CloudWatch Source をスキャンして新しいデータがないか確認する間隔として、デフォルトの 5 分を使用するか、または別の間隔を入力します。
- [Save (保存)] をクリックします。