I'm trying to set some custom AWS CloudWatch metrics using the Java SDK.
I can't seem to find anything in the documentation describing how to get certain pieces of data, nor what data I need to include.
MetricDatum datum = new MetricDatum()
.withDimensions(
new Dimension()
.withName("InstanceType").withValue(/* 1 */),
new Dimension()
.withName("InstanceId").withValue(/* 2 */)
/* 3 */
.withMetricName("My metric").withTimestamp(new Date())
.withUnit("Percent").withValue(new Double(55.0));
So, questions (for each of the commented numbers in the code above):
- Where do I get the data to put here, using the Java AWS SDK?
- Where do I get the data to put here, using the Java AWS SDK?
- What other data do I need to include in order to ensure I can aggregate by auto-scaling group? (aggregating by security group would also be fine)
For #1, I've seen that I can make a regular HTTP call to http://169.254.169.254/latest/meta-data/instance-id to get the instance-id, but I'm hoping to do this all via the AWS SDK, if there are methods available to do so.