HI Team,
Actually im work in autopurge script in linux. I dont have enough storage in my disk. i planned to purge the old data from my index and keep last 15 day live records in index.. I can perform this operation by manually like passing this code as shown below,
curl -XDELETE 'http://XXX/logstash-dd.notifychange_log_v1/_query' -d '
{
"query":
{
"range":
{
"eventType_timestamp":
{
"gte": "2016-05-30T07:00:00.000Z",
"lte": "2016-06-15T06:59:59.999Z"
}
}
}
}'
In automation im trying to pass the from and to date automatically by script . I stored the from and to date value in variable and then passing the variable to curl command as shown below,
from_dataset_date=2016-05-30T07:00:00.000Z
to_dataset_date=2016-06-15T06:59:59.999Z
curl -XDELETE 'http://XXXX/logstash-dd.notifychange_log_v1/_query' -d '
{
"query":
{
"range":
{
"eventType_timestamp":
{
"gte": "$from_dataset_date",
"lte": "$to_dataset_date"
}
}
}
}'
In this scenario im getting error.
error :{"error":{"root_cause":[{"type":"parse_exception","reason":"failed to parse date field [$from_dataset_date] with format [strict_date_optional_time||epoch_millis]"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"logstash-dd.notifychange_log_v1","node":"ze7WyKOcRRu0e5iAgA0ueQ","reason":{"type":"parse_exception","reason":"failed to parse date field [$from_dataset_date] with format [strict_date_optional_time||epoch_millis]","caused_by":{"type":"illegal_argument_exception","reason":"Invalid format: "$from_dataset_date""}}}]},"status":400}
Please anyone help me to resolve is it possible to pass variable in curl command as i shown above?