我正在创建一个应用程序,该应用程序返回与亚马逊服务相关的使用情况和费用。 首先,我尝试从AWS Cost Explorer中获取任何信息,但元数据始终返回为空... 指标有误吗?
var client = new AmazonCostExplorerClient(profile.Options.AccessKey, profile.Options.SecretKey);
GetCostAndUsageRequest request = new GetCostAndUsageRequest();
request.Granularity = "DAILY";
//Context c = new Context("COST_AND_USAGE");
request.Metrics.Add("USAGE_QUANTITY");
//request.Metrics.Add("NORMALIZED_USAGE_AMOUNT");
//request.Metrics.Add("UNBLENDED_COST");
DateInterval dateInt = new DateInterval();
dateInt.Start = DateTime.Now.AddDays(-4).ToString("yyyy-MM-dd");
dateInt.End = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd");
request.TimePeriod = dateInt;
//var gpDef = new GroupDefinition();
//gpDef.Key = "USAGE_TYPE";
//request.GroupBy.Add(gpDef);
try
{
var response = client.GetCostAndUsage(request);
Console.WriteLine(response.ResponseMetadata.Metadata.Count);
Console.WriteLine(response.ResultsByTime.ToString());
foreach (KeyValuePair<String, String> s in response.ResponseMetadata.Metadata)
{
Console.WriteLine("chave - " + s.Key);
Console.WriteLine("valor -" + s.Value);
}
Console.ReadKey();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadKey();
}
理想的计划是获取Json格式的值,但是现在获取任何东西将是很棒的。