As I’m using the Opensearch version 2.12.0 , When i tried to create the SM policy to take backup and create snapshot of my indices , I’m facing issue on my curl command , the command and error is given below -
curl -XPUT “http://localhost:9200/_plugins/_ism/policies/opensearch_sm_daily_backup” -H ‘Content-Type: application/json’ -d’
{
“description”: “opensearch_sm_daily_backup”,
“creation”: {
“schedule”: {
“cron”: {
“expression”: “5 * * * *”,
“timezone”: “UTC”
}
}
},
“snapshot_config”: {
“date_format”: “yyyy-MM-dd-HH:mm”,
“timezone”: “UTC”,
“indices”: “test”,
“repository”: “opensearch_sm_repo”,
“ignore_unavailable”: “true”,
“include_global_state”: “false”,
“partial”: “true”,
“metadata”: {
“any_key”: “any_value”
}
}
}’
{“error”:{“root_cause”:[{“type”:“parsing_exception”,“reason”:“Failed to parse object: expecting token of type [START_OBJECT] but found [VALUE_STRING]”,“line”:3,“col”:18}],“type”:“parsing_exception”,“reason”:“Failed to parse object: expecting token of type [START_OBJECT] but found [VALUE_STRING]”,“line”:3,“col”:18},“status”:400}
Same curl i used in the earlier version 1.3.14 opensearch , there is also same issue i faced , but found from the link that SM policy will only work in 2.X version or greater. That’s why i tried with version 2.12.0.
EDIT: I broke down your curl command error, I think this is where the issue is.
parsing_exception: Indicates that there was an error while parsing the data.
Failed to parse object: It couldn’t parse the data as an object.
expecting token of type [START_OBJECT] but found [VALUE_STRING]: It expected the beginning of an object ({) but found a string value instead. This suggests that the data might not be formatted correctly.