bi-watch.conf 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. input{
  2. beats {
  3. host => "0.0.0.0"
  4. port => 13838
  5. }
  6. }
  7. filter{
  8. # mutate{
  9. # add_field => {"pq1" =>"value1"}
  10. # }
  11. mutate{
  12. gsub => ["message", "[\\\\]", ""]
  13. remove_field => ["container","@timestamp","log","@version","version","agent","offset","input","beat","tags","host","ecs","_flush_time"]
  14. # remove_field => "container"
  15. }
  16. json {
  17. source => "message" # 解析成json
  18. }
  19. mutate{
  20. remove_field => "message"
  21. remove_field => "lib"
  22. remove_field => "[properties][$latest_search_keyword]"
  23. remove_field => "[properties][$url_path]"
  24. remove_field => "[properties][$lib_version]"
  25. }
  26. mutate{
  27. rename => {
  28. "[properties][$lib]"=>"lib"
  29. "[properties][$screen_width]"=>"screen_width"
  30. "[properties][$screen_height]"=>"screen_height"
  31. "[properties][$url]"=>"url"
  32. "[properties][$title]"=>"title"
  33. "[properties][$element_target_url]"=>"element_target_url"
  34. "[properties][$is_first_day]"=>"is_first_day"
  35. "[properties][$element_path]"=>"element_path"
  36. "[properties][$element_class_name]"=>"element_class_name"
  37. "[properties][$element_content]"=>"element_content"
  38. "[properties][$element_type]"=>"element_type"
  39. "[properties][$latest_referrer]"=>"latest_referrer"
  40. "[properties][aid]"=>"aid"
  41. "[properties][taskid]"=>"taskid"
  42. "[properties][attr1]"=>"attr1"
  43. "[properties][attr2]"=>"attr2"
  44. "[properties][attr3]"=>"attr3"
  45. "[properties][attr4]"=>"attr4"
  46. "[properties][attr5]"=>"attr5"
  47. "[properties][attr6]"=>"attr6"
  48. "[properties][attr7]"=>"attr7"
  49. "[properties][attr8]"=>"attr8"
  50. "[properties][attr9]"=>"attr9"
  51. "[properties][attr10]"=>"attr10"
  52. "[properties][attr11]"=>"attr11"
  53. "[properties][attr12]"=>"attr12"
  54. "[properties][attr13]"=>"attr13"
  55. "[properties][attr14]"=>"attr14"
  56. "[properties][attr15]"=>"attr15"
  57. "[properties][attr16]"=>"attr16"
  58. "[properties][attr17]"=>"attr17"
  59. "[properties][attr18]"=>"attr18"
  60. "[properties][attr19]"=>"attr19"
  61. "[properties][attr20]"=>"attr20"
  62. "[properties][platform_type]"=>"platform_type"
  63. "[properties][source]"=>"source"
  64. "[properties][plan]"=>"plan"
  65. "[properties][unit]"=>"unit"
  66. "[properties][keyword]"=>"keyword"
  67. "[properties][e_creative]"=>"e_creative"
  68. "[properties][e_keywordid]"=>"e_keywordid"
  69. "[properties][account]"=>"account"
  70. "[properties][referer]"=>"referer"
  71. }
  72. convert => {
  73. "attr1" => "string"
  74. "attr2" => "string"
  75. "attr3" => "string"
  76. "attr4" => "string"
  77. "attr5" => "string"
  78. "attr6" => "string"
  79. "attr7" => "string"
  80. "attr8" => "string"
  81. "attr9" => "string"
  82. "attr10" => "string"
  83. "attr11" => "string"
  84. "attr12" => "string"
  85. "attr13" => "string"
  86. "attr14" => "string"
  87. "attr15" => "string"
  88. "attr16" => "string"
  89. "attr17" => "string"
  90. "attr18" => "string"
  91. "attr19" => "string"
  92. "attr20" => "string"
  93. "source" => "string"
  94. "plan" => "string"
  95. "unit" => "string"
  96. "keyword" => "string"
  97. "e_creative" => "string"
  98. "e_keywordid" => "string"
  99. "account" => "string"
  100. "referer" => "string"
  101. }
  102. }
  103. date {
  104. match => ["time", "UNIX_MS"]
  105. target =>"logdatetime"
  106. locale =>"cn"
  107. tag_on_failure =>"1970-01-01 00:00:00"
  108. }
  109. # time时区必须加个00:00 不然插入时会+8小时
  110. #event.set('timezone', Time.at(tstamp).zone)
  111. ruby {
  112. code => "tstamp = event.get('logdatetime').to_i
  113. event.set('d_timestamp', Time.at(tstamp).localtime('+00:00').strftime('%Y-%m-%d %H:%M:%S'))
  114. event.set('d_date', Time.at(tstamp).strftime('%Y-%m-%d'))"
  115. }
  116. }
  117. output{
  118. stdout {
  119. codec => rubydebug
  120. }
  121. # base64.encode(userName:passWord) => ZGVmYXVsdDpMaWFudG9uZ2JpWWlkb25naGFvNjY=
  122. clickhouse {
  123. headers => ["Authorization", "Basic ZGVmYXVsdDpQbGF0b21peEBjazEyMw=="]
  124. http_hosts => "http://clickhouse:8123"
  125. table => "ads.user_event"
  126. request_tolerance => 1 #失败(响应码不是200)的重试次数
  127. #flush_size => 1000 #每次批量发送的数据大小,默认值为50
  128. #pool_max => 1000
  129. mutations => {
  130. proj => proj
  131. ptype => ptype
  132. ip => ip
  133. distinct_id => distinct_id
  134. anonymous_id => anonymous_id
  135. login_id => login_id
  136. d_time => time
  137. d_timestamp=> d_timestamp
  138. d_date => d_date
  139. d_type => type
  140. event => event
  141. screen_width => screen_width
  142. screen_height => screen_height
  143. lib => lib
  144. _track_id => _track_id
  145. url => url
  146. title => title
  147. element_target_url => element_target_url
  148. is_first_day => is_first_day
  149. element_path => element_path
  150. element_class_name => element_class_name
  151. element_content => element_content
  152. element_type => element_type
  153. latest_referrer => latest_referrer
  154. aid=> aid
  155. taskid=> taskid
  156. attr1=> attr1
  157. attr2=> attr2
  158. attr3=> attr3
  159. attr4=> attr4
  160. attr5=> attr5
  161. attr6=> attr6
  162. attr7=> attr7
  163. attr8=> attr8
  164. attr9=> attr9
  165. attr10=> attr10
  166. attr11=> attr11
  167. attr12=> attr12
  168. attr13=> attr13
  169. attr14=> attr14
  170. attr15=> attr15
  171. attr16=> attr16
  172. attr17=> attr17
  173. attr18=> attr18
  174. attr19=> attr19
  175. attr20=> attr20
  176. platform_type=> platform_type
  177. source=> source
  178. plan=> plan
  179. unit=> unit
  180. keyword=> keyword
  181. e_creative=> e_creative
  182. e_keywordid=> e_keywordid
  183. account=> account
  184. referer=> referer
  185. }
  186. }
  187. }