current position:Home>A user Logstash consumes Kafka data and writes ES to report an error, 'cannot be changed from type [long] to [text]' processing process
A user Logstash consumes Kafka data and writes ES to report an error, 'cannot be changed from type [long] to [text]' processing process
2022-08-06 20:02:04【South African camels say big data】
一、前言
某用户通过logstash消费Kafka数据写入ES时报错,cause data to be writtenES失败.需要排查原因
- The troubleshooting error message is as follows:
Could not index event to Elasticsearch. {:status=>400, :action=>["index", {:_id=>nil, :_index=>"XXXXXX-2022.08", :routing=>nil, :_type=>"_doc"}, #<LogStash::Event:0x153461e0>], :response=>{"index"=>{"_index"=>"XXXXXX-2022.08
", "_type"=>"_doc", "_id"=>"AKkgXoIBJ6THvkxd4efv", "status"=>400, "error"=>{"type"=>"illegal_argument_exception", "reason"=>"mapper [modules.subModules.items.value] cannot be changed from type [long] to [text]"}}}}
大意是"modules.subModules.items.value"The type of this field is long,但是写入ESbecomes a string typetext.A type conversion error caused the data write to fail.
二、数据测试
测试一:
PUT nginx-hezhenserver/_doc/1
{
"modules": [
{
"name": "IPC",
"subModules": [
{
"name": "cpuUse",
"items": [
{
"name": "all",
"value": "31.63"
},
{
"name": "cpu1",
"value": 29 //注意这里的value的值的不同.
}
]
}
]
}
]
}
报错如下:
测试二:
PUT nginx-hezhenserver/_doc/1
{
"modules": [
{
"name": "IPC",
"subModules": [
{
"name": "cpuUse",
"items": [
{
"name": "all",
"value": "31.63"
},
{
"name": "cpu1",
"value": "29" 加引号//注意这里的value的值的不同,将valueThe format of the value is changed to be consistent.
}
]
}
]
}
]
}
Data created successfully.
from the above comparison,我们可以看到,这种objectWhen the data type in the content of the object subfield of the type does not match,在存入ES的时候,会报类型转换错误,By default, it will be converted to string type storage.
三、解决办法
Because the field contents of this type of user are all numeric types,So here is the unified definitionlong. 可以在templateRiga a dynamic template,Used to write such fieldsES时自动转为long类型.Since here is the object fieldobject 子字段,这里需要用到path.match,The settings in the template are as follows:
{
"message22": {
"mapping": {
"type": "long"
},
"path_match" : "modules.subModules.items.value"
}
}
//将此类index下的valueObject fields map tolong.
After executing the above template,再生成一个new index.
Still the previous test statement.
PUT nginx-hezhenserver/_doc/1
{
"modules": [
{
"name": "IPC",
"subModules": [
{
"name": "cpuUse",
"items": [
{
"name": "all",
"value": "31.63"
},
{
"name": "cpu1",
"value": 29
}
]
}
]
}
]
}
再次执行,发现执行成功.查看mapping,valuesThe subfield becomeslong.Other object fields becometext.
So the problem is basically solved here,但是由于用户logstashThe source data of consumption is not uniform,valueThe contents of the array are irregular,导致写入ES的时候还是报错.
PUT nginx-hezhenserver/_doc/1
{
"modules": [
{
"name": "IPC",
"subModules": [
{
"name": "cpuUse",
"items": [
{
"name": "all",
"value": "31.63"
},
{
"name": "cpu1",
"value": 29
},{
"name": "cpu1",
"value": "689MZH" //字符串类型的value
}
]
}
]
}
]
}
报错如下:
This means this is writtenvalue里的内容ESIt is recognized that the input isString.不能转成long. 解析失败.
Because the user side cannot control the standardization of the written data,那只能ESSide readjust the template,直接改为text类型即可.调整如下:
{
"message22": {
"mapping": {
"type": "text"
},
"path_match" : "modules.subModules.items.value"
}
}
再次执行上述index.The index is created successfully.
Then adjust the above,customers like thislogstash消费kafkaThe problem of abnormal data writing is completely solved.
四、总结
这里主要用到了Elasticseach的动态模板,Object fields are usedpath_match组合,This issue is specifically documented.
copyright notice
author[South African camels say big data],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/218/202208061954002361.html
The sidebar is recommended
- Vue family bucket - Vue-CLI2 and Vue-CLI3 hands-on teaching
- [Tips] Mac uses commands to view the size of sub-files or sub-directories in a directory
- Why build an index?
- Descartes set type and what is the effect of quantization coding?
- [Written in the romantic moment of Qixi Lang] The solution for obtaining data when encountering http codes 206 and 302 in Go
- [Operating System] Process Creation and Destruction
- AQS synchronization component - CountDownLatch analysis and case
- Why is there an index in quantization coding?
- What is the linear combination type in quantization coding?
- Arduino Painless Development _LED8*8 Dot Matrix Experiment (Detailed)
guess what you like
element ui table changes the default style, removes the border and changes the table background color
Data Structure ----- Quick Sort
Node.js test SMTP service
Create Nginx docker container reverse proxy https
Python batch get gitlab project code
Do phrases created by the second-class dictionary method have to have a specific meaning?
How do I select the quantitative method for the quantitative characteristics of the coding?
What is the result after straight-sum quantization?
What are the types of high-dimensional indexes?
Back-end writing Swagger interface management documentation
Random recommended
- Windows use Telnet to test smtp
- Docker - way to modify folder mapping
- 10 easy-to-use software on mac
- SSL/TLS protocol operating mechanism in https protocol
- What is the certificate chain of trust for HTTPS?Can't you publish it yourself?
- Nginx error 413 Request Entity Too Large solution
- js data manipulation problem solving?
- After changing the scale of the screen and the ratio of the layout, the Vue project feels very slow to change the transparency of the image?
- Hand in hand with you to get started weback4.0 (1)
- How to pass the data obtained by nodejs to the front desk for use (keyword - system file)
- Chapter 24 How much do you know about proxy knowledge in Spring AOP
- The prize pool experience is bad, very dark
- C + + string container
- RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn
- The vmware virtual machine is disconnected from the network (nat network) after a period of time
- RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9
- Installing vivado2019.1 is always showing "There is no valid Xilinx installation that this Update can be applied to"
- What are the characteristics of the run-length encoding algorithm?
- Question about pygame
- Self-learning crawler encounters a bottleneck, hoping to get some advice
- Webpack5 packaging process source code analysis (1)
- How to understand the memory analysis of executing another method in a JAVA method.
- HTML5 and CSS web material download
- Chapter 215 Aspect-Oriented Programming Spring AOP Actual Configuration
- ASUS laptop software automatically goes to the recycle bin
- Tag attributes you don't know
- usgs download sentinel2
- andriodstudio packaging process without the steps in the tutorial
- msntfs can not be used!
- Chapter XXVIII Aspect-Oriented Programming of AOP Configuration Based on Spring Annotations
- Question about #vsuninstall#, how to solve it?
- Vue + Element tree form implement drag-and-drop sequence
- Are there any abnormal programs that ZTE R5300G4 server will start at 3:00 am every Saturday?Why does this time cause disk exception
- The error "There is no valid Xilinx installation that this Update can be applied to" has been reported when installing vivado2019.1.
- WeChat Mini Program - Simple Diet Recommendation (3)
- Failed to change color in vscode
- Chapter 217 Play Spring5.X Xml configuration conversion to advanced annotation configuration
- Chapter 216 Play with Spring5.X Xml configuration conversion to annotation configuration
- Linux Network Learning Part VII: Detailed Explanation of IP Protocol + Data Link Layer
- Advanced IO for Linux Learning: Five IO Models