Cloudwatch should easily be able to keep up with your metric volume so I would just use 1 PutMetricDataRequest
for each batch coming in from the source applications and let Cloudwatch do the aggregation.
If you look at PutMetricDataRequest
it takes a Collection<MetricDatum>
which is well suited to receive any number of keys you're receiving from the source applications in a single request.
====
Converting a HashMap to a List is pretty straightforward with the Java8 streams API:
Assuming your map is a key => value map:
Map<String, Object> metricMap = new HashMap<>();
metricMap.put("metricKey", 99);
You can use the Java8 streams API with map and collect:
List<MetricDatum> metrics = metricMap.entrySet().parallelStream()
.map(map -> new MetricDatum()
.withMetricName(map.getKey())
.withUnit(StandardUnit.Count)
.withValue(Double.valueOf(map.getValue().toString()))
).collect(Collectors.toList());