在官方有说明:

logstash_format

  1. logstash_format true # defaults to false

This is meant to make writing data into Elasticsearch indices compatible to what Logstash calls them. By doing this, one could take advantage of Kibana. See logstash_prefix and logstash_dateformat to customize this index name pattern. The index name will be #{logstash_prefix}-#{formated_date}

:warning: Setting this option to true will ignore the index_name setting. The default index name prefix is logstash-.

fluentd的配置如下:

  1. # In v1 configuration, type and id are @ prefix parameters.
  2. # @type and @id are recommended. type and id are still available for backward compatibility
  3. ## built-in TCP input
  4. ## $ echo <json> | fluent-cat <tag>
  5. <source>
  6. @type forward
  7. @id forward_input
  8. </source>
  9. ## built-in UNIX socket input
  10. #<source>
  11. # @type unix
  12. #</source>
  13. # HTTP input
  14. # http://localhost:8888/<tag>?json=<json>
  15. <source>
  16. @type http
  17. @id http_input
  18. port 8888
  19. </source>
  20. ## File input
  21. ## read apache logs with tag=apache.access
  22. #<source>
  23. # @type tail
  24. # format apache
  25. # path /var/log/httpd-access.log
  26. # tag apache.access
  27. #</source>
  28. ## Mutating event filter
  29. ## Add hostname and tag fields to apache.access tag events
  30. #<filter apache.access>
  31. # @type record_transformer
  32. # <record>
  33. # hostname ${hostname}
  34. # tag ${tag}
  35. # </record>
  36. #</filter>
  37. ## Selecting event filter
  38. ## Remove unnecessary events from apache prefixed tag events
  39. #<filter apache.**>
  40. # @type grep
  41. # include1 method GET # pass only GET in 'method' field
  42. # exclude1 message debug # remove debug event
  43. #</filter>
  44. # Listen HTTP for monitoring
  45. # http://localhost:24220/api/plugins
  46. # http://localhost:24220/api/plugins?type=TYPE
  47. # http://localhost:24220/api/plugins?tag=MYTAG
  48. <source>
  49. @type monitor_agent
  50. @id monitor_agent_input
  51. port 24220
  52. </source>
  53. # Listen DRb for debug
  54. <source>
  55. @type debug_agent
  56. @id debug_agent_input
  57. bind 127.0.0.1
  58. port 24230
  59. </source>
  60. ## match tag=apache.access and write to file
  61. #<match apache.access>
  62. # @type file
  63. # path /var/log/fluent/access
  64. #</match>
  65. ## match tag=debug.** and dump to console
  66. <match debug.**>
  67. @type stdout
  68. @id stdout_output
  69. </match>
  70. # match tag=system.** and forward to another fluent server
  71. <match system.**>
  72. @type forward
  73. @id forward_output
  74. <server>
  75. host 192.168.0.11
  76. </server>
  77. <secondary>
  78. <server>
  79. host 192.168.0.12
  80. </server>
  81. </secondary>
  82. </match>
  83. ## match tag=myapp.** and forward and write to file
  84. #<match myapp.**>
  85. # @type copy
  86. # <store>
  87. # @type forward
  88. # buffer_type file
  89. # buffer_path /var/log/fluent/myapp-forward
  90. # retry_limit 50
  91. # flush_interval 10s
  92. # <server>
  93. # host 192.168.0.13
  94. # </server>
  95. # </store>
  96. # <store>
  97. # @type file
  98. # path /var/log/fluent/myapp
  99. # </store>
  100. #</match>
  101. ## match fluent's internal events
  102. #<match fluent.**>
  103. # @type null
  104. #</match>
  105. ## match not matched logs and write to file
  106. #<match **>
  107. # @type file
  108. # path /var/log/fluent/else
  109. # compress gz
  110. #</match>
  111. ## Label: For handling complex event routing
  112. #<label @STAGING>
  113. # <match system.**>
  114. # @type forward
  115. # @id staging_forward_output
  116. # <server>
  117. # host 192.168.0.101
  118. # </server>
  119. # </match>
  120. #</label>
  121. ######以下可以能过匹配的tag (elk)写入到elasticsearch
  122. <match elk.**>
  123. @type elasticsearch
  124. host localhost
  125. port 9200
  126. logstash_format true
  127. </match>
  128. ######tail 收集日志开始
  129. <match golang.**>
  130. @type elasticsearch
  131. host localhost
  132. port 9200
  133. index_name fluentd.${tag}
  134. logstash_format false ##更改为false就不会成生logstash-2019.02.19这样子的
  135. flush_interval 1s
  136. </match>
  137. <source>
  138. @type tail
  139. format json
  140. path /var/log/test.log
  141. tag golang.access
  142. </source>
  143. #######tail 收集日志结束

分类: web

标签:   fluentd