无法将 json 文件上传到 aws cloudwatch

萨加尔·贾达夫

我试图通过替换其中的内容在 aws cloudwatch 上上传 json 文件,作为回报,我将该文件上传到 cloudwatch。

第 1 步:- 我正在 Windows 机器上使用 AWS cli (AWS cloudwatch get-dashboard *) 保存一个 cloudwatch 仪表板(以 JSON 格式)。

Step2 :- 替换文件的内容并按原样保存。

步骤 3:- 我正在将新修改的文​​件(以 json 格式)上传到 cloudwatch,但上传失败。

当我查看未以 JSON 格式显示的文件时,Windows 将其视为字符串。

我使用的 cli 是:

aws cloudwatch get-dashboard --dashboard-name SIT  --region eu-west-1 > SIT.json

输出显示如下:

{
    "DashboardName": "SIT",
    "DashboardArn": "arn:aws:cloudwatch::123456789:dashboard/SIT",
    "DashboardBody": "{\"widgets\":[{\"type\":\"metric\",\"x\":0,\"y\":0,\"width\":12,\"height\":6,\"properties\":{\"metrics\":[[\"sit/Default\",\"Memory Available\",\"Instance\",\"i-04996767d0822cccf\"]]
,\"view\":\"timeSeries\",\"stacked\":false,\"region\":\"eu-west-1\",\"title\":\"RT1 Available Memory\",\"period\":300}},{\"type\":\"metric\",\"x\":0,\"y\":6,\"width\":12,\"height\":6,\"properties\":{\"met
rics\":[[\"AWS/EC2\",\"CPUUtilization\",\"InstanceId\",\"i-04996767d0822cccf\"]],\"view\":\"timeSeries\",\"stacked\":false,\"region\":\"eu-west-1\",\"title\":\"RT1 CPU Utilization\",\"period\":300}},{\"ty
pe\":\"metric\",\"x\":0,\"y\":18,\"width\":12,\"height\":6,\"properties\":{\"metrics\":[[\"AWS/EC2\",\"CPUUtilization\",\"InstanceId\",\"i-092fcbe0dd0eeceb5\"]],\"view\":\"timeSeries\",\"stacked\":false,\
"title\":\"SQL Primary CPU Utilization\",\"region\":\"eu-west-1\",\"period\":300}},{\"type\":\"metric\",\"x\":12,\"y\":12,\"width\":12,\"height\":6,\"properties\":{\"metrics\":[[\"AWS/EC2\",\"CPUUtilizati
on\",\"InstanceId\",\"i-045c7346c36f1cc3d\"]],\"view\":\"timeSeries\",\"stacked\":false,\"region\":\"eu-west-1\",\"title\":\"Batch CPU Utilization\",\"period\":300}},{\"type\":\"metric\",\"x\":0,\"y\":12,
\"width\":12,\"height\":6,\"properties\":{\"metrics\":[[\"sit/Default\",\"Memory Available\",\"Instance\",\"i-045c7346c36f1cc3d\"]],\"view\":\"timeSeries\",\"stacked\":false,\"title\":\"Batch Available Me
mory\",\"region\":\"eu-west-1\",\"period\":300}},{\"type\":\"metric\",\"x\":12,\"y\":18,\"width\":12,\"height\":6,\"properties\":{\"view\":\"timeSeries\",\"stacked\":false,\"metrics\":[[\"AWS/EC2\",\"CPUU
tilization\",\"InstanceId\",\"i-092fcbe0dd0eeceb5\"]],\"region\":\"eu-west-1\",\"title\":\"SQL Secondary CPU Utilization\"}},{\"type\":\"metric\",\"x\":0,\"y\":24,\"width\":12,\"height\":6,\"properties\":
{\"metrics\":[[\"sit/Default\",\"Memory Available\",\"Instance\",\"i-03b623e8400e4b801\"]],\"view\":\"timeSeries\",\"stacked\":false,\"title\":\"SAM Available Memory\",\"region\":\"eu-west-1\",\"period\":
300}},{\"type\":\"metric\",\"x\":12,\"y\":24,\"width\":12,\"height\":6,\"properties\":{\"metrics\":[[\"AWS/EC2\",\"CPUUtilization\",\"InstanceId\",\"i-03b623e8400e4b801\"]],\"view\":\"timeSeries\",\"stack
ed\":false,\"title\":\"SAM CPU Utilization\",\"region\":\"eu-west-1\",\"period\":300}},{\"type\":\"metric\",\"x\":12,\"y\":0,\"width\":12,\"height\":6,\"properties\":{\"metrics\":[[\"sit/Default\",\"Memor
y Available\",\"Instance\",\"i-0e82d201d3fac0d2d\"]],\"view\":\"timeSeries\",\"stacked\":false,\"title\":\"RT2 Available Memory\",\"region\":\"eu-west-1\",\"period\":300}},{\"type\":\"metric\",\"x\":12,\"
y\":6,\"width\":12,\"height\":6,\"properties\":{\"metrics\":[[\"AWS/EC2\",\"CPUUtilization\",\"InstanceId\",\"i-0e82d201d3fac0d2d\"]],\"view\":\"timeSeries\",\"stacked\":false,\"title\":\"RT2 CPU Utilizat
ion\",\"region\":\"eu-west-1\",\"period\":300}}]}"
}

我尝试使用“ConvertTo-Json”,但仍然无法上传。

我得到的错误如下;

An error occurred (InvalidParameterInput) when calling the PutDashboard operation: The dashboard body is invalid, there are 1 validation errors: [ { "dataPath": "", "message": "Should have required property 'widgets'" } ]

有人可以建议吗?

萨加尔·贾达夫

我设法使用“格式列表”powershell 找到了解决方案;

Get-CWDashboard -DashboardName <SIT> | select DashboardBody | fl

上面的命令将只选择 DashboardBody 并在 json 视图中格式化输出(仪表板正文的原始格式)。

有了这个,我现在可以将 DashboardBody 上传回 cloudwatch 仪表板。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

无法通过PHP文件上传将文件上传到AWS

无法将json文件上传到vb.net

将 JSON 文件上传到 elasticsearch/kibana

将JSON文件上传到WebAPI

使用Ubuntu中的CloudWatch Log Agent将服务器日志上传到AWS CloudWatch Log中

将 JSON 文件从 node.js 中的 aws-sdk 上传到 aws s3 存储桶

使用Java将zip文件上传到AWS Lambda

使用Java将AWS文件上传到S3

将文件从URL上传到Laravel中的AWS

使用Terraform将文件上传到AWS Secrets Manager

Django:将CSV文件上传到AWS S3

从本地计算机将文件上传到AWS

将大文件上传到 AWS aurora postgres serverless

将文件上传到 AWS 以进入 Postgres 数据库

无法将pdf文件上传到AWS s3存储桶-PHP

无法通过carrierwavefog-aws将文件上传到minio(docker-compose)

无法使用 Python 脚本和通配符将多个文件上传到 AWS S3

由于文件太大,无法将JSON文件上传到Azure Cosmos DB

无法将JSON文件上传到parse.com-文件格式错误

如何使用_id将json文件导入/上传到arangoDB?

如何将JSON文件上传到Firebase

从JSON文件将多个“文档”上传到IrisCouch

以未排序的顺序将JSON文件上传到R

将JSON文件上传到Amazon SQS时出错

无法将大型JSON文件上传到Firebase实时数据库

无法通过Chrome将JSON文件上传到Firebase数据库

Python-无法将文件上传到AWS S3存储桶中的已定义文件夹

AWS 将多行日志文件从 CloudWatch 流式传输到 ELK

我无法从Cloudwatch将日志上传到我的s3存储桶