update by query
类似于mysql 中的update set where
核心json
VM,POD类型的 数据,并且host.network.bytes.outgoing字段不为null,并且时间窗口范围在。。。到。。。之间的
数据修改其中host.network.bytes.outgoing字段的值为null
POST delta-monitor-2023.04.24/_update_by_query
{
"script":{
"source":"ctx._source.host.network.bytes.outgoing = null"
},
"query":{
"bool":{
"must":[
{
"terms":{
"labels.resourceType":["VM","POD"]
}
},
{
"exists":{
"field":"host.network.bytes.outgoing"
}
},
{
"range":{
"@timestamp":{
"from":"1682328780000",
"to":"1682342219000"
}
}
}
]
}
}
}
查看目前提交到远程的query by upate的task
GET _tasks?detailed=true&actions=*update*
返回结果
{
"nodes" : {
"fbETc_FzS-epzk60brY_uQ" : {
"name" : "coordinating-0",
"transport_address" : "11.71.40.2:9300",
"host" : "11.71.40.2",
"ip" : "11.71.40.2:9300",
"roles" : [
"ingest"
],
"attributes" : {
"zone_id" : "az1",
"xpack.installed" : "true",
"box_type" : "hot",
"transform.node" : "false"
},
"tasks" : {
"fbETc_FzS-epzk60brY_uQ:8241564204" : {
"node" : "fbETc_FzS-epzk60brY_uQ",
"id" : 8241564204,
"type" : "transport",
"action" : "indices:data/write/update/byquery",
"status" : {
"total" : 824647,
"updated" : 534000,
"created" : 0,
"deleted" : 0,
"batches" : 535,
"version_conflicts" : 0,
"noops" : 0,
"retries" : {
"bulk" : 0,
"search" : 0
},
"throttled_millis" : 0,
"requests_per_second" : -1.0,
"throttled_until_millis" : 0
},
"description" : "update-by-query [delta-monitor-2023.04.24] updated with Script{type=inline, lang='painless', idOrCode='ctx._source.host.network.bytes.outgoing = null', options={}, params={}}",
"start_time_in_millis" : 1682403002556,
"running_time_in_nanos" : 150338472512,
"cancellable" : true,
"headers" : { }
}
}
}
}
}
取消后台正在运行的task
POST _tasks/fbETc_FzS-epzk60brY_uQ:8241564204/_cancel
原创:做时间的朋友