Search code examples
oracle-cloud-infrastructureoracle-cloud-functionsoracle-cloud-shell

Oracle cloud api health check


I have below command for creating api health check in oracle cloud.

oci health-checks http-monitor create --compartment-id ocid1.compartment.oc1..aaaaaaaabbb5aavs3npxp6ttq525qoollwxtrjmp1vh6skthcsitfzpw4sq2rfa --display-name "keepalive-check" --interval-in-seconds 300 --method HEAD --protocol "HTTPS" --timeout-in-seconds 60 --targets "[api.abcglobal.com]" --path "/dev/user-service/warm"  --vantage-point-names '["aws-sin"]'

While running this command from cloud terminal I am getting below error. Any help would be appreciated.

***Parameter 'targets' must be in JSON format.***


 - Command

**ocidevelop@cloudshell:~ (ap-hyderabad-1)$** *oci health-checks http-monitor create --compartment-id ocid1.compartment.oc1..aaaaaaaabbb5aavs3npxp6ttq525qoollwxtrjmp1vh6skthcsitfzpw4sq2rfa --display-name "keepalive-check" --interval-in-seconds 300 --method HEAD --protocol "HTTPS" --timeout-in-seconds 60 --targets "[api.abcglobal.com]" --path "/dev/user-service/warm"  --vantage-point-names '["aws-sin"]'*

**Parameter 'targets' must be in JSON format.**
For help with formatting JSON input see our documentation here: https://docs.cloud.oracle.com/iaas/Content/API/SDKDocs/cliusing.htm#ManagingCLIInputandOutput

Solution

  • --targets is a complex parameter. You can create its skeleton using https://docs.oracle.com/en-us/iaas/tools/oci-cli/3.6.1/oci_cli_docs/cmdref/health-checks/http-monitor/create.html#cmdoption-targets

    Please follow this:

    oci health-checks http-monitor create --generate-param-json-input targets > target.json

    edit target.json

    oci health-checks http-monitor create --compartment-id $C --protocol "HTTPs" --display-name "test" --interval-in-seconds "300" --targets file://target.json