Mais conteúdo relacionado Semelhante a JAWS-UG CLI #25 LT - AWS Tools for Windows PowerShellでログを取得 (20) Mais de Nobuhiro Nakayama (16) JAWS-UG CLI #25 LT - AWS Tools for Windows PowerShellでログを取得1. JAWS-UG CLI #25 LT
AWS Tools for Windows PowerShellで
ログを出力
2015/08/03 Mon
Nobuhiro Nakayama
2. 2
cat << EOF > me.json
{
“name” : “Nobuhiro Nakayama”,
“company” : “UCHIDAYOKO CO., LTD.”,
“favorite aws services” : [
“Directory Service”, “IAM”, “CLI”
],
“twitter” : ”@domokun70cm”,
“facebook” : ” nobuhiro.nakayama.12”,
“certifications” : [
“AWS Certified Solutions Architect-Professional”,
“AWS Certified SysOps Administrator-Associate”,
“Microsoft Certified Solutions Expert Server Infrastructure / SharePoint”,
“IPA Network Specialist”, “IPA Information Security Specialist”
]
}
EOF
4. AWS Tools for Windows PowerShell
• PowerShellでAWSを操作するツール
• コマンドレットの出力結果は.NET Frameworkオブジェクトの配列として出力
• 細かいことは、先々週のBlackBelt Tech Webinarの資料で
• http://www.slideshare.net/AmazonWebServicesJapan/aws-black-belt-tech-2015-
aws-cloudtrail-aws-sdk-for-powershell
2015/8/3 4
今日紹介する機能は、Blackbelt Tech Webinarで
紹介されていないちょっと便利な機能です
5. Metrics Logging/Logging Listener
• 実行結果のログを取得できます(Get-EC2AvailabilityZoneの例)
• 実行結果の他、実行に要した時間なども出力される(Linuxのtimeコマンドのようなもの)
2015/8/3 5
Amazon Verbose: 0 : Received response (truncated to 1024 bytes): [<?xml version="1.0" encoding="UTF-
8"?><DescribeAvailabilityZonesResponse xmlns="http://ec2.amazonaws.com/doc/2015-04-15/"> <requestId>577e1785-a53a-42fa-
8119-2f7d9100376d</requestId> <availabilityZoneInfo> <item> <zoneName>ap-northeast-1a</zoneName>
<zoneState>available</zoneState> <regionName>ap-northeast-1</regionName> <messageSet/> </item>
<item> <zoneName>ap-northeast-1c</zoneName> <zoneState>available</zoneState> <regionName>ap-
northeast-1</regionName> <messageSet/> </item> </availabilityZoneInfo></DescribeAvailabilityZonesResponse>]
Amazon Information: 1 : Request metrics: AsyncCall = False; CanonicalRequest = POST¥n/¥n¥ncontent-type:application/x-www-form-
urlencoded; charset=utf-8¥nhost:ec2.ap-northeast-1.amazonaws.com¥nuser-agent:AWSPowerShell/2.3.46.0 .NET Runtime/4.0 .NET
Framework/4.0 OS/6.1.7601.65536 WindowsPowerShell/4.-1 ClientSync¥nx-amz-content-
sha256:a4541cc6cd06d90dbf380a65d6eaab5b64476077df590c1b7d34985c7100f489¥nx-amz-date:20150802T113641Z¥n¥ncontent-
type;host;user-agent;x-amz-content-sha256;x-amz-date¥na4541cc6cd06d90dbf380a65d6eaab5b64476077df590c1b7d34985c7100f489;
StringToSign = AWS4-HMAC-SHA256¥n20150802T113641Z¥n20150802/ap-northeast-
1/ec2/aws4_request¥n32b22900d41c9cc4d2cef2d35cc6b1ef67966f8d0a50ed6ecc887c43b23ca720; ServiceName = Amazon.EC2;
ServiceEndpoint = https://ec2.ap-northeast-1.amazonaws.com/; MethodName = DescribeAvailabilityZonesRequest; RequestSize = 51;
StatusCode = OK; BytesProcessed = -1; AWSRequestID = 577e1785-a53a-42fa-8119-2f7d9100376d; CredentialsRequestTime =
00:00:00.0000027; RequestSigningTime = 00:00:00.0008425; HttpRequestTime = 00:00:00.0990260; ResponseUnmarshallTime =
00:00:00.0002682; ResponseProcessingTime = 00:00:00.0022254; ClientExecuteTime = 00:00:00.1327580;
8. 1.リスナーを定義
• リスナー名とログファイルの出力先を指定
• ソース(サービス)を指定してログファイルを分けることも可能
• “-Source”なし・ありのリスナーを複数設定した場合、
-Sourceを指定していないリスナーでは
-Sourceを指定したリスナーのログは出力されませんでした。
• 同じ-Sourceを指定した複数のリスナーを設定している場合、両方に出力されました。
2015/8/3 8
> Add-AWSLoggingListener –Name AllLogs -LogFilePath c:¥logs¥all.txt
> Add-AWSLoggingListener –Name S3Logs -LogFilePath c:¥logs¥s3.txt –Source Amazon.S3
11. 【参考】log4net
• log4netが使われているもよう
2015/8/3 11
> Get-AWSPowerShellVersion
AWS Tools for Windows PowerShell
Version 3.1.2.0
Copyright 2012-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Amazon Web Services SDK for .NET
Version 3.1.0.0
Copyright 2009-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Release notes: https://aws.amazon.com/releasenotes/PowerShell
This software includes third party software subject to the following copyrights:
- Logging from log4net, Apache License
[http://logging.apache.org/log4net/license.html]