Skip to content

Commit 9045691

Browse files
author
liukai2012
authored
Merge pull request #1157 from PapaPiya/fix_elastic_magic
1.es修复增量采集相关问题;2.修复根据魔法变量切换索引无法继续采集问题
2 parents 54998fb + 10502a5 commit 9045691

File tree

3 files changed

+209
-215
lines changed

3 files changed

+209
-215
lines changed

reader/config/config.go

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ var ModeKeyOptions = map[string][]Option{
945945
Required: true,
946946
DefaultNoUse: false,
947947
Description: "offset保存时间(es_keepalive)",
948-
CheckRegex: "\\d+[dms]",
948+
CheckRegex: "\\d+[dhms]",
949949
Advance: true,
950950
ToolTip: "logkit重启后可以继续读取ES数据的Offset记录在es服务端保存的时长,默认1d",
951951
},
@@ -962,22 +962,63 @@ var ModeKeyOptions = map[string][]Option{
962962
{
963963
KeyName: KeyESCron,
964964
ChooseOnly: false,
965-
Default: "loop 3s",
965+
Default: "",
966966
Placeholder: "00 00 04 * * *",
967967
DefaultNoUse: false,
968968
Description: "定时任务(es_cron)",
969969
Advance: true,
970-
ToolTip: `定时任务触发周期,直接写"loop"循环执行,crontab的写法,类似于* * * * * *,对应的是秒(0~59),分(0~59),时(0~23),日(1~31),月(1-12),星期(0~6),填*号表示所有遍历都执行,loop模式为全量读取,cron模式为增量读取`,
970+
ToolTip: `定时任务触发周期,循环周期不宜太小,会有es中scrollId被快速消耗完的风险,直接写"loop"循环执行,crontab的写法,类似于* * * * * *,对应的是秒(0~59),分(0~59),时(0~23),日(1~31),月(1-12),星期(0~6),填*号表示所有遍历都执行`,
971+
},
972+
{
973+
KeyName: KeyESOffsetKey,
974+
ChooseOnly: false,
975+
Default: "",
976+
Placeholder: "递增字段的字段名",
977+
DefaultNoUse: false,
978+
Description: "递增字段的字段名(es_cron_offset)",
979+
Advance: true,
980+
ToolTip: `定时读取时作为offset字段的字段名,只支持对整型字段进行增量采集`,
981+
},
982+
{
983+
KeyName: KeyESOffsetKeyType,
984+
ChooseOnly: true,
985+
ChooseOptions: []interface{}{"long", "date"},
986+
Default: "long",
987+
Placeholder: "递增字段的类型",
988+
DefaultNoUse: false,
989+
Description: "递增字段的类型(es_offset_key_type)",
990+
Advance: true,
991+
ToolTip: `目前只支持对整型和时间类型的字段进行增量采集`,
971992
},
972993
{
973-
KeyName: KeyESCronOffset,
994+
KeyName: KeyESOffsetStartTime,
974995
ChooseOnly: false,
975996
Default: "",
976-
Placeholder: "定时读取时作为offset字段的字段名",
997+
Placeholder: "递增字段的起始值",
977998
DefaultNoUse: false,
978-
Description: "定时任务offset字段字段名(es_cron_offset)",
999+
Description: "递增字段的起始值(es_offset_start_time)",
9791000
Advance: true,
980-
ToolTip: `定时读取时作为offset字段的字段名,该字段只在es_cron中使用的是定时任务时生效,且此字段应该具有作为offset字段的特性(递增,例如:timestamp字段)`,
1001+
ToolTip: `定时读取时作为offset字段的起始值,默认为空`,
1002+
},
1003+
{
1004+
KeyName: KeyESDelayTime,
1005+
ChooseOnly: false,
1006+
Default: "",
1007+
DefaultNoUse: false,
1008+
Description: "采集延迟时间(" + KeyESDelayTime + ")",
1009+
Advance: true,
1010+
ToolTip: `只采集比当前时间延迟一段时间的数据,以保证数据完全写入,如果递增列为整型,该字段也需要为整型,为整型时需要填写时间戳单位,延迟时间与递增列单位一致;如果是递增的时间字段,请按照'now-1d'的格式填写;为整型时,默认查询到最新位置,为时间类型时,默认查询到now+1y时间`,
1011+
},
1012+
{
1013+
KeyName: KeyESDelayTimeUnit,
1014+
ChooseOnly: true,
1015+
ChooseOptions: []interface{}{"second", "millisecond"},
1016+
Default: "second",
1017+
Placeholder: "",
1018+
DefaultNoUse: false,
1019+
Description: "延迟时间单位(" + KeyESDelayTimeUnit + ")",
1020+
Advance: true,
1021+
ToolTip: `延迟时间单位,默认为秒`,
9811022
},
9821023
{
9831024
KeyName: KeyESDateShift,

reader/config/models.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,21 @@ const (
9494
KeyPGsqlCron = "postgres_cron"
9595
KeyPGsqlExecOnStart = "postgres_exec_onstart"
9696

97-
KeyESReadBatch = "es_limit_batch"
98-
KeyESIndex = "es_index"
99-
KeyESType = "es_type"
100-
KeyESHost = "es_host"
101-
KeyESKeepAlive = "es_keepalive"
102-
KeyESVersion = "es_version"
103-
KeyESCron = "es_cron"
104-
KeyESExecOnstart = "es_exec_onstart"
105-
KeyESCronOffset = "es_cron_offset"
106-
KeyESDateShift = "es_date_shift"
107-
KeyESDateOffset = "es_date_offset"
97+
KeyESReadBatch = "es_limit_batch"
98+
KeyESIndex = "es_index"
99+
KeyESType = "es_type"
100+
KeyESHost = "es_host"
101+
KeyESKeepAlive = "es_keepalive"
102+
KeyESVersion = "es_version"
103+
KeyESCron = "es_cron"
104+
KeyESExecOnstart = "es_exec_onstart"
105+
KeyESOffsetKey = "es_cron_offset"
106+
KeyESOffsetKeyType = "es_offset_key_type"
107+
KeyESOffsetStartTime = "es_offset_start_time"
108+
KeyESDateShift = "es_date_shift"
109+
KeyESDateOffset = "es_date_offset"
110+
KeyESDelayTime = "es_delay_time"
111+
KeyESDelayTimeUnit = "es_delay_time_unit"
108112

109113
KeyMongoHost = "mongo_host"
110114
KeyMongoDatabase = "mongo_database"
@@ -126,7 +130,7 @@ const (
126130

127131
KeyScriptParams = "script_params"
128132
KeyScriptParamsSpliter = "script_params_spliter"
129-
KeyScriptTimeout = "script_timeout"
133+
KeyScriptTimeout = "script_timeout"
130134
KeyScriptContent = "script_content"
131135
KeyExecInterpreter = "script_exec_interprepter"
132136
KeyScriptCron = "script_cron"

0 commit comments

Comments
 (0)