mardi 20 janvier 2015

CloudWatch EC2 - Finding EC2 Server's Instance ID and Instance Name

I have a custom CloudWatch metric that I am reporting. My call looks like:



$dimensions = array(
array(
"Name" => "InstanceId",
"Value" => "need instance id here"
),
array(
"Name" => "InstanceName",
"Value" => "need instance name here"
)
);

// API call to save cpu usage
$client->putMetricData(array(
"Namespace" => "mynamespace",
"MetricData" => array(
array(
"MetricName" => "CPU_Usage",
"Value" => $cpu_usage,
"Unit" => "Percent",
"Timestamp" => time(),
"Dimensions" => $dimensions
)
)
));


I want to populate InstanceId and InstanceName with values corresponding to the server running the script.


Is there a way to do this through CloudWatch API?





Aucun commentaire:

Enregistrer un commentaire