pulumi-datadog icon indicating copy to clipboard operation
pulumi-datadog copied to clipboard

Example fails due to invalid JSON

Open cpiemontese opened this issue 2 years ago • 0 comments

File: themes/default/content/registry/packages/datadog/api-docs/monitorjson/_index.md

Hello!

I tried running the Python example to create a MonitorJson and I encountered the following error

Diagnostics:
  datadog:index:MonitorJson (monitorJson):
    error: datadog:index/monitorJson:MonitorJson resource 'monitorJson' has a problem: "monitor" contains an invalid JSON: invalid character 'n' after object key:value pair. Examine values at 'MonitorJson.Monitor'.

This seems to be due to some missing escapes and can be fixed as follows

datadog.MonitorJson(
        "monitorJson",
        monitor="""{
    "name": "Example monitor - service check",
    "type": "service check",
    "query": "\\\"ntp.in_sync\\\".by(\\\"*\\\").last(2).count_by_status()",
    "message": "Change the message triggers if any host's clock goes out of sync with the time given by NTP. The offset threshold is configured in the Agent's 'ntp.yaml' file.\\n\\nSee [Troubleshooting NTP Offset issues](https://docs.datadoghq.com/agent/troubleshooting/ntp for more details on cause and resolution.",
    "tags": [],
    "multi": true,
	"restricted_roles": null,
    "options": {
        "include_tags": true,
        "locked": false,
        "new_host_delay": 150,
        "notify_audit": false,
        "notify_no_data": false,
        "thresholds": {
            "warning": 1,
            "ok": 1,
            "critical": 1
        }
    },
    "priority": null,
    "classification": "custom"
}
""",
    )

cpiemontese avatar Jul 08 '22 14:07 cpiemontese