20 #include <aws/monitoring/model/PutMetricDataRequest.h> 21 #include <aws/monitoring/model/StandardUnit.h> 25 namespace CloudWatchMetrics {
28 static std::unordered_map<std::string, Aws::CloudWatch::Model ::StandardUnit>
units_mapper = {
29 {
"sec", Aws::CloudWatch::Model::StandardUnit::Seconds},
30 {
"msec", Aws::CloudWatch::Model::StandardUnit::Milliseconds},
31 {
"usec", Aws::CloudWatch::Model::StandardUnit::Microseconds},
32 {
"percent", Aws::CloudWatch::Model::StandardUnit::Percent},
33 {
"count", Aws::CloudWatch::Model::StandardUnit::Count},
34 {
"count_per_sec", Aws::CloudWatch::Model::StandardUnit::Count_Second},
35 {
"bytes", Aws::CloudWatch::Model::StandardUnit::Bytes},
36 {
"kilobytes", Aws::CloudWatch::Model::StandardUnit::Kilobytes},
37 {
"megabytes", Aws::CloudWatch::Model::StandardUnit::Megabytes},
38 {
"gigabytes", Aws::CloudWatch::Model::StandardUnit::Gigabytes},
39 {
"terabytes", Aws::CloudWatch::Model::StandardUnit::Terabytes},
40 {
"bytes_per_sec", Aws::CloudWatch::Model::StandardUnit::Bytes_Second},
41 {
"kilobytes_per_sec", Aws::CloudWatch::Model::StandardUnit::Kilobytes_Second},
42 {
"megabytes_per_sec", Aws::CloudWatch::Model::StandardUnit::Megabytes_Second},
43 {
"gigabytes_per_sec", Aws::CloudWatch::Model::StandardUnit::Gigabytes_Second},
44 {
"terabytes_per_sec", Aws::CloudWatch::Model::StandardUnit::Terabytes_Second},
45 {
"none", Aws::CloudWatch::Model::StandardUnit::None},
46 {
"", Aws::CloudWatch::Model::StandardUnit::None},
73 const std::string & _name,
75 const std::string & _unit,
76 const int64_t _timestamp,
77 const std::map<std::string, std::string> & _dimensions,
78 const int _storage_resolution)
79 : metric_name(_name), unit(_unit), timestamp(_timestamp), value(_value),
80 dimensions(_dimensions), storage_resolution(_storage_resolution) {}
93 const std::string & _name,
94 const std::map<StatisticValuesType, double> & _statistic_values,
95 const std::string & _unit,
96 const int64_t _timestamp,
97 const std::map<std::string, std::string> & _dimensions,
98 const int _storage_resolution)
99 : metric_name(_name), unit(_unit), timestamp(_timestamp), statistic_values(_statistic_values),
100 dimensions(_dimensions), storage_resolution(_storage_resolution) {}
121 Aws::String aws_metric_name(metrics.
metric_name.c_str());
122 Aws::Utils::DateTime date_time(timestamp);
124 datum.WithMetricName(aws_metric_name).WithTimestamp(date_time);
127 datum.SetValue(metrics.
value);
129 Aws::CloudWatch::Model::StatisticSet stats;
132 stats.SetMinimum(keyval.second);
134 stats.SetMaximum(keyval.second);
136 stats.SetSum(keyval.second);
138 stats.SetSampleCount(keyval.second);
141 datum.SetStatisticValues(stats);
144 auto mapped_unit = units_mapper.find(metrics.
unit);
145 if (units_mapper.end() != mapped_unit) {
146 datum.SetUnit(mapped_unit->second);
148 Aws::String unit_name(metrics.
unit.c_str());
149 datum.SetUnit(Aws::CloudWatch::Model::StandardUnitMapper::GetStandardUnitForName(unit_name));
153 Aws::CloudWatch::Model::Dimension dimension;
154 Aws::String name(it.first.c_str());
155 Aws::String d_value(it.second.c_str());
156 dimension.WithName(name).WithValue(d_value);
157 datum.AddDimensions(dimension);
static std::unordered_map< std::string, Aws::CloudWatch::Model::StandardUnit > units_mapper
std::map< std::string, std::string > dimensions
MetricObject(const std::string &_name, const std::map< StatisticValuesType, double > &_statistic_values, const std::string &_unit, const int64_t _timestamp, const std::map< std::string, std::string > &_dimensions, const int _storage_resolution)
MetricObject(const std::string &_name, const double _value, const std::string &_unit, const int64_t _timestamp, const std::map< std::string, std::string > &_dimensions, const int _storage_resolution)
Aws::CloudWatch::Model::MetricDatum MetricDatum
static MetricDatum metricObjectToDatum(const MetricObject &metrics, const int64_t timestamp)
std::map< StatisticValuesType, double > statistic_values