質問編集履歴

9

コメント場所変更

2018/11/04 23:04

投稿

minati
minati

スコア17

test CHANGED
File without changes
test CHANGED
@@ -181,25 +181,3 @@
181
181
 
182
182
 
183
183
  ```
184
-
185
-
186
-
187
- ご回答ありがとうございます。実行したところ、下記のエラーとなりました。
188
-
189
- SDKのバージョンは3.69.16です。
190
-
191
-
192
-
193
- Found 6 errors while validating the input provided for the PutMetricData operation:
194
-
195
- [MetricData][InstanceId] must be an associative array. Found string(19) "i-xxxxxxxxxx"
196
-
197
- [MetricData][MetricName] must be an associative array. Found string(17) "MemoryUtilization"
198
-
199
- [MetricData][Dimensions] must be an associative array. Found array(1)
200
-
201
- [MetricData][Timestamp] must be an associative array. Found int(1541371271)
202
-
203
- [MetricData][Value] must be an associative array. Found int(0)
204
-
205
- [MetricData][Unit] must be an associative array. Found string(7) "Percent"

8

ソースコード追加

2018/11/04 23:04

投稿

minati
minati

スコア17

test CHANGED
File without changes
test CHANGED
@@ -181,3 +181,25 @@
181
181
 
182
182
 
183
183
  ```
184
+
185
+
186
+
187
+ ご回答ありがとうございます。実行したところ、下記のエラーとなりました。
188
+
189
+ SDKのバージョンは3.69.16です。
190
+
191
+
192
+
193
+ Found 6 errors while validating the input provided for the PutMetricData operation:
194
+
195
+ [MetricData][InstanceId] must be an associative array. Found string(19) "i-xxxxxxxxxx"
196
+
197
+ [MetricData][MetricName] must be an associative array. Found string(17) "MemoryUtilization"
198
+
199
+ [MetricData][Dimensions] must be an associative array. Found array(1)
200
+
201
+ [MetricData][Timestamp] must be an associative array. Found int(1541371271)
202
+
203
+ [MetricData][Value] must be an associative array. Found int(0)
204
+
205
+ [MetricData][Unit] must be an associative array. Found string(7) "Percent"

7

ソースコード追加

2018/11/04 22:52

投稿

minati
minati

スコア17

test CHANGED
File without changes
test CHANGED
@@ -154,6 +154,12 @@
154
154
 
155
155
 
156
156
 
157
+ //インスタンスIDをセット
158
+
159
+ $dimensions = array(array('Name' => 'InstanceId', 'Value' => $InstanceId));
160
+
161
+
162
+
157
163
  $result = $client->getMetricStatistics(array(
158
164
 
159
165
  'Namespace' => $namespace,

6

getMetricStatisticsのコード追記

2018/11/04 12:02

投稿

minati
minati

スコア17

test CHANGED
File without changes
test CHANGED
@@ -146,4 +146,32 @@
146
146
 
147
147
  }
148
148
 
149
+
150
+
151
+
152
+
153
+ getMetricStatisticsのコード
154
+
155
+
156
+
157
+ $result = $client->getMetricStatistics(array(
158
+
159
+ 'Namespace' => $namespace,
160
+
161
+ 'MetricName' => $metricName,
162
+
163
+ 'Dimensions' => $dimensions,
164
+
165
+ 'StartTime' => $StartTime,
166
+
167
+ 'EndTime' => strtotime('now'),
168
+
169
+ 'Period' => '3600',
170
+
171
+ 'Statistics' => array('Maximum')
172
+
173
+ ));
174
+
175
+
176
+
149
177
  ```

5

ソースコード追加

2018/11/04 11:59

投稿

minati
minati

スコア17

test CHANGED
File without changes
test CHANGED
@@ -3,6 +3,8 @@
3
3
  cloudwatch のカスタムメトリクスをAWS SDK for PHP で取得したいです。
4
4
 
5
5
  下記のようにputMetricDataを送信しましたが、うまくできませんでした。
6
+
7
+ 権限はfullでつけています。
6
8
 
7
9
 
8
10
 
@@ -56,7 +58,7 @@
56
58
 
57
59
 
58
60
 
59
- ーーーーーー返ってきた結果ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
61
+ ーーーーーーPUTして返ってきた結果ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
60
62
 
61
63
  Data can be retrieved from the model object using the get() method of the
62
64
 
@@ -102,4 +104,46 @@
102
104
 
103
105
  }
104
106
 
107
+
108
+
109
+ ---GETして返ってきた結果--------------------------------------------
110
+
111
+ {
112
+
113
+ "Label": "MemoryUtilization",
114
+
115
+ "Datapoints": [],
116
+
117
+ "@metadata": {
118
+
119
+ "statusCode": 200,
120
+
121
+ "effectiveUri": "https://monitoring.sa-east-1.amazonaws.com",
122
+
123
+ "headers": {
124
+
125
+ "x-amzn-requestid": "******************************",
126
+
127
+ "content-type": "text/xml",
128
+
129
+ "content-length": "340",
130
+
131
+ "date": "Sat, 03 Nov 2018 04:20:48 GMT"
132
+
133
+ },
134
+
135
+ "transferStats": {
136
+
137
+ "http": [
138
+
139
+ []
140
+
141
+ ]
142
+
143
+ }
144
+
145
+ }
146
+
147
+ }
148
+
105
149
  ```

4

リンク追加

2018/11/03 04:22

投稿

minati
minati

スコア17

test CHANGED
File without changes
test CHANGED
@@ -5,6 +5,8 @@
5
5
  下記のようにputMetricDataを送信しましたが、うまくできませんでした。
6
6
 
7
7
 
8
+
9
+ [参考にしたサイト](https://docs.aws.amazon.com/ja_jp/sdk-for-php/v3/developer-guide/cw-examples-publishing-custom-metrics.html)
8
10
 
9
11
 
10
12
 

3

タイトル修正

2018/11/03 04:11

投稿

minati
minati

スコア17

test CHANGED
@@ -1 +1 @@
1
- eんAWS cloudwatch PHP SDK カスタムメトリクス取得できな
1
+ AWS cloudwatch PHP SDK カスタムメトリクス取得した
test CHANGED
File without changes

2

タイトル変更

2018/11/03 04:04

投稿

minati
minati

スコア17

test CHANGED
@@ -1 +1 @@
1
- AWS cloudwatch PHP SDK カスタムメトリクス取得方法
1
+ eんAWS cloudwatch PHP SDK カスタムメトリクス取得できない
test CHANGED
File without changes

1

ソースコード追加

2018/11/03 04:02

投稿

minati
minati

スコア17

test CHANGED
File without changes
test CHANGED
@@ -1,3 +1,103 @@
1
1
  IAMロールを使用してお客様のアカウントのログを監視するツールに使用するため、
2
2
 
3
3
  cloudwatch のカスタムメトリクスをAWS SDK for PHP で取得したいです。
4
+
5
+ 下記のようにputMetricDataを送信しましたが、うまくできませんでした。
6
+
7
+
8
+
9
+
10
+
11
+ ```php
12
+
13
+ $client = CloudWatchClient::factory(array(
14
+
15
+ 'version'=> 'latest',
16
+
17
+ 'region' => $region_code,
18
+
19
+ 'credentials' => array(
20
+
21
+ 'key' => $AccessKeyId,
22
+
23
+ 'secret' => $SecretAccessKey,
24
+
25
+ 'token' => $SessionToken
26
+
27
+ )
28
+
29
+ ));
30
+
31
+
32
+
33
+ $result = $client->putMetricData(array(
34
+
35
+ 'Namespace' => 'System/Linux',
36
+
37
+ 'MetricData' => array(
38
+
39
+ array(
40
+
41
+ 'MetricName' => 'MemoryUtilization',
42
+
43
+ 'Timestamp' => time(),
44
+
45
+ 'Value' => 0,
46
+
47
+ 'Unit' => 'Percent'
48
+
49
+ )
50
+
51
+ )
52
+
53
+ ));
54
+
55
+
56
+
57
+ ーーーーーー返ってきた結果ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
58
+
59
+ Data can be retrieved from the model object using the get() method of the
60
+
61
+ model (e.g., `$result->get($key)`) or "accessing the result like an
62
+
63
+ associative array (e.g. `$result['key']`). You can also execute JMESPath
64
+
65
+ expressions on the result data using the search() method.
66
+
67
+
68
+
69
+ {
70
+
71
+ "@metadata": {
72
+
73
+ "statusCode": 200,
74
+
75
+ "effectiveUri": "https://monitoring.sa-east-1.amazonaws.com",
76
+
77
+ "headers": {
78
+
79
+ "x-amzn-requestid": "************************************",
80
+
81
+ "content-type": "text/xml",
82
+
83
+ "content-length": "212",
84
+
85
+ "date": "Sat, 03 Nov 2018 03:05:57 GMT"
86
+
87
+ },
88
+
89
+ "transferStats": {
90
+
91
+ "http": [
92
+
93
+ []
94
+
95
+ ]
96
+
97
+ }
98
+
99
+ }
100
+
101
+ }
102
+
103
+ ```