简体   繁体   English

json 格式无效,请检查。 原因:寻找对象键字符串开头的无效字符“a”

[英]Invalid json format, please check. Reason: invalid character 'a' looking for beginning of object key string

could you please assist me here?你能帮我吗? I have validated JSON but the issue appears.. also the strange thing is that when I create the JSON file with the wizard the issue does not appear.我已经验证了 JSON,但问题出现了……而且奇怪的是,当我使用向导创建 JSON 文件时,问题没有出现。 Thank you in advance.先感谢您。

Validate JSON:验证 JSON:

{
    "agent": {
        "metrics_collection_interval": 60,
        "run_as_user": "root"
    },
    "logs": {
        "logs_collected": {
            "files": {
                "collect_list": [
                    {
                        "file_path": "/var/log/messages",
                        "log_group_name": "messages",
                        "log_stream_name": "{instance_id}"
                    }
                ]
            }
        }
    },
    "metrics": {
        "append_dimensions": {
            "AutoScalingGroupName": "${aws:AutoScalingGroupName}",
            "ImageId": "${aws:ImageId}",
            "InstanceId": "${aws:InstanceId}",
            "InstanceType": "${aws:InstanceType}"
        },
        "metrics_collected": {
            "collectd": {
                "metrics_aggregation_interval": 60
            },
            "cpu": {
                "measurement": [
                    "cpu_usage_idle",
                    "cpu_usage_iowait",
                    "cpu_usage_user",
                    "cpu_usage_system"
                ],
                "metrics_collection_interval": 60,
                "totalcpu": false
            },
            "disk": {
                "measurement": [
                    "used_percent",
                    "inodes_free"
                ],
                "metrics_collection_interval": 60,
                "resources": [
                    "*"
                ]
            },
            "diskio": {
                "measurement": [
                    "io_time",
                    "write_bytes",
                    "read_bytes",
                    "writes",
                    "reads"
                ],
                "metrics_collection_interval": 60,
                "resources": [
                    "*"
                ]
            },
            "mem": {
                "measurement": [
                    "mem_used_percent"
                ],
                "metrics_collection_interval": 60
            },
            "netstat": {
                "measurement": [
                    "tcp_established",
                    "tcp_time_wait"
                ],
                "metrics_collection_interval": 60
            },
            "statsd": {
                "metrics_aggregation_interval": 60,
                "metrics_collection_interval": 10,
                "service_address": ":8125"
            },
            "swap": {
                "measurement": [
                    "swap_used_percent"
                ],
                "metrics_collection_interval": 60
            }
        }
    }
}

sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a append-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json -s /opt/aws/amazon-cloudwatch-agent/bin/config-downloader --output-dir /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d --download-source file:/opt/aws/amazon-cloudwatch-agent/bin/config.json --mode ec2 --config /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml --multi-config append Successfully fetched the config and saved in /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_config.json.tmp Start configuration validation... /opt/aws/amazon-cloudwatch-agent/bin/config-translator --input /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json --input-dir /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d --output /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.toml --mode ec2 --config /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml --multi-config append sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a append-config -m ec2 -c 文件:/opt/aws/amazon-cloudwatch-agent/bin/config.json - s /opt/aws/amazon-cloudwatch-agent/bin/config-downloader --output-dir /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d --download-source 文件:/ opt/aws/amazon-cloudwatch-agent/bin/config.json --mode ec2 --config /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml --multi-config append 成功获取配置并保存在 /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_config.json.tmp 开始配置验证... /opt/aws/amazon-cloudwatch-agent/bin/config-翻译器 --input /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json --input-dir /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d - -output /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.toml --mode ec2 --config /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml --multi -配置追加

2019/08/26 07:58:17 Reading json config file path: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json ...
/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json does not exist or cannot read. Skipping it.
2019/08/26 07:58:17 Reading json config file path: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/default ...
2019/08/26 07:58:17 Reading json config file path: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_config.json.tmp ...
2019/08/26 07:58:17 Invalid json format, please check. Reason: invalid character 'a' looking for beginning of object key string 
2019/08/26 07:58:17 I! AmazonCloudWatchAgent Version 1.223987.0.
2019/08/26 07:58:17 Configuration validation first phase failed. Agent version: 1.223987.0. Verify the JSON input is only using features supported by this version.

I managed to fix the java error this by adding \\ in front of the $.我设法通过在 $ 前面添加 \\ 来修复 java 错误。 Then there was a terraform error message when I used terraform apply and added a second dollar sign to skip the interpolation.然后,当我使用 terraform apply 并添加第二个美元符号以跳过插值时,出现了 terraform 错误消息。

"AutoScalingGroupName": "\$${aws:AutoScalingGroupName}",
"ImageId": "\$${aws:ImageId}",
"InstanceId": "\$${aws:InstanceId}",
"InstanceType": "\$${aws:InstanceType}"

Hope this will help somebody in the future.希望这会在将来对某人有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JSON无效字符'}'正在寻找对象键字符串的开头 - JSON invalid character '}' looking for beginning of object key string JSON int密钥发布数据e2e(寻找对象密钥字符串开头的无效字符“ 1”) - JSON int key issue data e2e (invalid character '1' looking for beginning of object key string) JSON无法写入创世纪块:无效字符'\\\\'寻找对象密钥字符串的开头 - JSON failed to write genesis block: invalid character '\\' looking for beginning of object key string Xamarin&Golang-{[]}无效字符'\\ x00'寻找对象密钥字符串的开头 - Xamarin & Golang - { []} invalid character '\x00' looking for beginning of object key string Golang无效字符'b'寻找值的开始 - Golang invalid character 'b' looking for beginning of value golang websocket.JSON.Receive无效字符'q'寻找值的开头 - golang websocket.JSON.Receive invalid character 'q' looking for beginning of value 从精读的HTTP中解组JSON:无效字符寻找值的开头 - Go unmarshalling JSON from compessed HTTP: invalid character looking for beginning of value 解组 JSON 返回错误:无效字符 '\\x1f' 寻找值的开头 - Unmarshalling JSON returns an error: invalid character '\x1f' looking for beginning of value Parse.com说“寻找值的开头的无效字符'\\” - Parse.com says “invalid character '\'' looking for beginning of value” 在 Json Curl 上使用生成的 PHP 字符串获取“无效的关键字符” - Getting "Invalid Key Character" With generated PHP string on Json Curl
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM