Reputation: 1
CA UIM probe monitors EC2 instances, using API provided by AWS.
Can I get access to this AWS API for monitoring EC2 instances?
Upvotes: 1
Views: 405
Reputation: 33511
Sure, you can use AWS REST API (available via SDKs or CLI). To get instance metrics you'll need to use EC2 and CloudWatch APIs. Here are the examples with AWS CLI for the metrics from "AWS related QOS Metrics" of the doc you've provided:
Instance State:
aws ec2 describe-instances --instance-ids i-999f9f99f999f99f9 --query "Reservations[*].Instances[*].[State]"
[
[
[
{
"Code": 16,
"Name": "running"
}
]
]
]
CPU Utilization (%):
aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name CPUUtilization --period 60 --statistics Average --dimensions Name=InstanceId,Value=i-999f9f99f999f99f9 --start-time 2018-12-07T00:00:00 --end-time 2018-12-08T00:00:00
{
"Label": "CPUUtilization",
"Datapoints": [
{
"Timestamp": "2018-12-07T02:40:00Z",
"Average": 0.0,
"Unit": "Percent"
},
{
"Timestamp": "2018-12-07T13:35:00Z",
"Average": 1.0,
"Unit": "Percent"
},
…
]
}
Disk Read Ops:
aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name EBSReadOps --period 60 --statistics Average --dimensions Name=InstanceId,Value=i-999f9f99f999f99f9 --start-time 2018-12-07T00:00:00 --end-time 2018-12-08T00:00:00
aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name DiskReadOps --period 60 --statistics Average --dimensions Name=InstanceId,Value=i-999f9f99f999f99f9 --start-time 2018-12-07T00:00:00 --end-time 2018-12-08T00:00:00
{
"Label": "EBSReadOps",
"Datapoints": [
{
"Timestamp": "2018-12-07T00:25:00Z",
"Average": 10.0,
"Unit": "Count"
},
{
"Timestamp": "2018-12-07T20:10:00Z",
"Average": 11.5,
"Unit": "Count"
},
…
]
}
Disk Write Ops
aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name EBSWriteOps --period 60 --statistics Average --dimensions Name=InstanceId,Value=i-999f9f99f999f99f9 --start-time 2018-12-07T00:00:00 --end-time 2018-12-08T00:00:00
aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name DiskWriteOps --period 60 --statistics Average --dimensions Name=InstanceId,Value=i-999f9f99f999f99f9 --start-time 2018-12-07T00:00:00 --end-time 2018-12-08T00:00:00
{
"Label": "EBSWriteOps",
"Datapoints": [
{
"Timestamp": "2018-12-07T00:25:00Z",
"Average": 1229.3,
"Unit": "Count"
},
{
"Timestamp": "2018-12-07T20:10:00Z",
"Average": 496.6,
"Unit": "Count"
},
…
]
}
Disk Read Bytes
aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name EBSReadBytes --period 60 --statistics Average --dimensions Name=InstanceId,Value=i-999f9f99f999f99f9 --start-time 2018-12-07T00:00:00 --end-time 2018-12-08T00:00:00
aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name DiskReadBytes --period 60 --statistics Average --dimensions Name=InstanceId,Value=i-999f9f99f999f99f9 --start-time 2018-12-07T00:00:00 --end-time 2018-12-08T00:00:00
{
"Label": "EBSReadBytes",
"Datapoints": [
{
"Timestamp": "2018-12-07T00:25:00Z",
"Average": 665.6,
"Unit": "Count"
},
{
"Timestamp": "2018-12-07T20:10:00Z",
"Average": 200.3,
"Unit": "Count"
},
…
]
}
Disk Write Bytes
aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name EBSWriteBytes --period 60 --statistics Average --dimensions Name=InstanceId,Value=i-999f9f99f999f99f9 --start-time 2018-12-07T00:00:00 --end-time 2018-12-08T00:00:00
aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name DiskWriteBytes --period 60 --statistics Average --dimensions Name=InstanceId,Value=i-999f9f99f999f99f9 --start-time 2018-12-07T00:00:00 --end-time 2018-12-08T00:00:00
{
"Label": "EBSWriteBytes",
"Datapoints": [
{
"Timestamp": "2018-12-07T00:25:00Z",
"Average": 7026688.0,
"Unit": "Count"
},
{
"Timestamp": "2018-12-07T20:10:00Z",
"Average": 7586713.6,
"Unit": "Count"
},
…
]
}
Network In Bytes
aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name NetworkIn --period 60 --statistics Average --dimensions Name=InstanceId,Value=i-999f9f99f999f99f9 --start-time 2018-12-07T00:00:00 --end-time 2018-12-08T00:00:00
{
"Label": "NetworkIn",
"Datapoints": [
{
"Timestamp": "2018-12-07T16:10:00Z",
"Average": 24489418.6,
"Unit": "Bytes"
},
{
"Timestamp": "2018-12-07T13:50:00Z",
"Average": 21305249.0,
"Unit": "Bytes"
},
…
]
}
Network Out Bytes
aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name NetworkOut --period 60 --statistics Average --dimensions Name=InstanceId,Value=i-999f9f99f999f99f9 --start-time 2018-12-07T00:00:00 --end-time 2018-12-08T00:00:00
{
"Label": "NetworkOut",
"Datapoints": [
{
"Timestamp": "2018-12-07T16:10:00Z",
"Average": 25363795.4,
"Unit": "Bytes"
},
{
"Timestamp": "2018-12-07T13:50:00Z",
"Average": 22128487.0,
"Unit": "Bytes"
},
…
]
}
The full list of available metrics can be found here. Subpages contain available metrics for particular services. Here is the page for EC2.
You'll get virtually the same data when using your language's SDK. As you see, CloudWatch just returns a list of timestamped metrics that you've queried.
Upvotes: 3