1.
[root@master log]# cat test.log
111111111111
222222222222
333333333333
[root@master log]# stat test.log
File: ‘test.log’
Size: 39 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 134304003 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2023-06-07 09:54:09.044113434 +0800
Modify: 2023-06-07 09:54:07.592919367 +0800
Change: 2023-06-07 09:54:07.592919367 +0800
Birth: -
{
"@timestamp": "2023-06-07T01:55:46.649Z",
"@metadata": {
"beat": "filebeat",
"type": "_doc",
"version": "8.8.0"
},
"ecs": {
"version": "8.0.0"
},
"host": {
"name": "master"
},
"message": "111111111111",
"log": {
"file": {
"path": "/var/log/test.log"
},
"offset": 0
},
"input": {
"type": "log"
},
"agent": {
"name": "master",
"type": "filebeat",
"version": "8.8.0",
"ephemeral_id": "9711df42-1b93-42ad-b6ae-e4c7a3ab4c24",
"id": "b07fb812-bcdb-48ae-a96b-2384bfed5cbe"
}
}
{
"@timestamp": "2023-06-07T01:55:46.649Z",
"@metadata": {
"beat": "filebeat",
"type": "_doc",
"version": "8.8.0"
},
"message": "222222222222",
"input": {
"type": "log"
},
"ecs": {
"version": "8.0.0"
},
"host": {
"name": "master"
},
"agent": {
"type": "filebeat",
"version": "8.8.0",
"ephemeral_id": "9711df42-1b93-42ad-b6ae-e4c7a3ab4c24",
"id": "b07fb812-bcdb-48ae-a96b-2384bfed5cbe",
"name": "master"
},
"log": {
"offset": 13,
"file": {
"path": "/var/log/test.log"
}
}
}
{
"@timestamp": "2023-06-07T01:55:46.649Z",
"@metadata": {
"beat": "filebeat",
"type": "_doc",
"version": "8.8.0"
},
"agent": {
"id": "b07fb812-bcdb-48ae-a96b-2384bfed5cbe",
"name": "master",
"type": "filebeat",
"version": "8.8.0",
"ephemeral_id": "9711df42-1b93-42ad-b6ae-e4c7a3ab4c24"
},
"message": "333333333333",
"log": {
"offset": 26,
"file": {
"path": "/var/log/test.log"
}
},
"input": {
"type": "log"
},
"ecs": {
"version": "8.0.0"
},
"host": {
"name": "master"
}
}
{"k":"filebeat::logs::native::134304003-64768","v":{"identifier_name":"native","source":"/var/log/test.log","timestamp":[2062235293660,1686102947],"offset":39,"ttl":-1,"type":"log","FileStateOS":{"inode":134304003,"device":64768},"id":"native::134304003-64768","prev_id":""}}
{
"@timestamp": "2023-06-07T01:58:41.676Z",
"@metadata": {
"beat": "filebeat",
"type": "_doc",
"version": "8.8.0"
},
"ecs": {
"version": "8.0.0"
},
"host": {
"name": "master"
},
"agent": {
"ephemeral_id": "9711df42-1b93-42ad-b6ae-e4c7a3ab4c24",
"id": "b07fb812-bcdb-48ae-a96b-2384bfed5cbe",
"name": "master",
"type": "filebeat",
"version": "8.8.0"
},
"log": {
"offset": 39,
"file": {
"path": "/var/log/test.log"
}
},
"message": "44444444444",
"input": {
"type": "log"
}
}
2、开始mv文件
[root@master log]# stat test.log
File: ‘test.log’
Size: 51 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 134304003 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2023-06-07 09:58:41.675572073 +0800
Modify: 2023-06-07 09:58:39.920337347 +0800
Change: 2023-06-07 09:58:39.920337347 +0800
Birth: -
[root@master log]# mv test.log test.log.001
[root@master log]# stat test.log.001
File: ‘test.log.001’
Size: 51 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 134304003 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2023-06-07 10:00:36.710955601 +0800
Modify: 2023-06-07 09:58:39.920337347 +0800
Change: 2023-06-07 10:00:35.327770629 +0800
Birth: -
[root@master log]# echo '555555555555' >>test.log.001
{
"@timestamp": "2023-06-07T02:01:26.714Z",
"@metadata": {
"beat": "filebeat",
"type": "_doc",
"version": "8.8.0"
},
"log": {
"offset": 51,
"file": {
"path": "/var/log/test.log"
}
},
"message": "555555555555",
"input": {
"type": "log"
},
3.重新生成test.log
[root@master log]# stat test.log
File: ‘test.log’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd00h/64768d Inode: 142091472 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2023-06-07 10:01:58.078837438 +0800
Modify: 2023-06-07 10:01:58.078837438 +0800
Change: 2023-06-07 10:01:58.078837438 +0800
Birth: -
[root@master log]# stat test.log.001
File: ‘test.log.001’
Size: 64 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 134304003 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2023-06-07 10:01:26.713642765 +0800
Modify: 2023-06-07 10:01:24.854394116 +0800
Change: 2023-06-07 10:01:24.854394116 +0800
Birth: -
{
"@timestamp": "2023-06-07T02:02:41.692Z",
"@metadata": {
"beat": "filebeat",
"type": "_doc",
"version": "8.8.0"
},
"message": "11111111111111",
"input": {
"type": "log"
},
"ecs": {
"version": "8.0.0"
},
"host": {
"name": "master"
},
"agent": {
"type": "filebeat",
"version": "8.8.0",
"ephemeral_id": "9711df42-1b93-42ad-b6ae-e4c7a3ab4c24",
"id": "b07fb812-bcdb-48ae-a96b-2384bfed5cbe",
"name": "master"
},
"log": {
"offset": 0,
"file": {
"path": "/var/log/test.log"
}
}
}文章来源:https://www.toymoban.com/news/detail-480188.html
偏移量又重新开始计算
文章来源地址https://www.toymoban.com/news/detail-480188.html
到了这里,关于filebeat 日志切割后偏移量重置的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!