fluentd-es-configmap.yaml 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. kind: ConfigMap
  2. apiVersion: v1
  3. metadata:
  4. name: fluentd-es-config-v0.1.4
  5. namespace: logging
  6. labels:
  7. addonmanager.kubernetes.io/mode: Reconcile
  8. data:
  9. system.conf: |-
  10. <system>
  11. root_dir /tmp/fluentd-buffers/
  12. </system>
  13. containers.input.conf: |-
  14. <source>
  15. @id fluentd-containers.log
  16. @type tail
  17. path /var/log/containers/*.log
  18. pos_file /var/log/es-containers.log.pos
  19. time_format %Y-%m-%dT%H:%M:%S.%NZ
  20. tag raw.kubernetes.*
  21. read_from_head true
  22. <parse>
  23. @type multi_format
  24. <pattern>
  25. format json
  26. time_key time
  27. time_format %Y-%m-%dT%H:%M:%S.%NZ
  28. </pattern>
  29. <pattern>
  30. format /^(?<time>.+) (?<stream>stdout|stderr) [^ ]* (?<log>.*)$/
  31. time_format %Y-%m-%dT%H:%M:%S.%N%:z
  32. </pattern>
  33. </parse>
  34. </source>
  35. # Detect exceptions in the log output and forward them as one log entry.
  36. <match raw.kubernetes.**>
  37. @id raw.kubernetes
  38. @type detect_exceptions
  39. remove_tag_prefix raw
  40. message log
  41. stream stream
  42. multiline_flush_interval 5
  43. max_bytes 500000
  44. max_lines 1000
  45. </match>
  46. system.input.conf: |-
  47. # Examples:
  48. # time="2016-02-04T06:51:03.053580605Z" level=info msg="GET /containers/json"
  49. # time="2016-02-04T07:53:57.505612354Z" level=error msg="HTTP Error" err="No such image: -f" statusCode=404
  50. # TODO(random-liu): Remove this after cri container runtime rolls out.
  51. <source>
  52. @id docker.log
  53. @type tail
  54. format /^time="(?<time>[^)]*)" level=(?<severity>[^ ]*) msg="(?<message>[^"]*)"( err="(?<error>[^"]*)")?( statusCode=($<status_code>\d+))?/
  55. path /var/log/docker.log
  56. pos_file /var/log/es-docker.log.pos
  57. tag docker
  58. </source>
  59. # Multi-line parsing is required for all the kube logs because very large log
  60. # statements, such as those that include entire object bodies, get split into
  61. # multiple lines by glog.
  62. # Example:
  63. # I0204 07:32:30.020537 3368 server.go:1048] POST /stats/container/: (13.972191ms) 200 [[Go-http-client/1.1] 10.244.1.3:40537]
  64. <source>
  65. @id kubelet.log
  66. @type tail
  67. format multiline
  68. multiline_flush_interval 5s
  69. format_firstline /^\w\d{4}/
  70. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  71. time_format %m%d %H:%M:%S.%N
  72. path /var/log/kubelet.log
  73. pos_file /var/log/es-kubelet.log.pos
  74. tag kubelet
  75. </source>
  76. # Example:
  77. # I1118 21:26:53.975789 6 proxier.go:1096] Port "nodePort for kube-system/default-http-backend:http" (:31429/tcp) was open before and is still needed
  78. <source>
  79. @id kube-proxy.log
  80. @type tail
  81. format multiline
  82. multiline_flush_interval 5s
  83. format_firstline /^\w\d{4}/
  84. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  85. time_format %m%d %H:%M:%S.%N
  86. path /var/log/kube-proxy.log
  87. pos_file /var/log/es-kube-proxy.log.pos
  88. tag kube-proxy
  89. </source>
  90. # Example:
  91. # I0204 07:00:19.604280 5 handlers.go:131] GET /api/v1/nodes: (1.624207ms) 200 [[kube-controller-manager/v1.1.3 (linux/amd64) kubernetes/6a81b50] 127.0.0.1:38266]
  92. <source>
  93. @id kube-apiserver.log
  94. @type tail
  95. format multiline
  96. multiline_flush_interval 5s
  97. format_firstline /^\w\d{4}/
  98. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  99. time_format %m%d %H:%M:%S.%N
  100. path /var/log/kube-apiserver.log
  101. pos_file /var/log/es-kube-apiserver.log.pos
  102. tag kube-apiserver
  103. </source>
  104. # Example:
  105. # I0204 06:55:31.872680 5 servicecontroller.go:277] LB already exists and doesn't need update for service kube-system/kube-ui
  106. <source>
  107. @id kube-controller-manager.log
  108. @type tail
  109. format multiline
  110. multiline_flush_interval 5s
  111. format_firstline /^\w\d{4}/
  112. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  113. time_format %m%d %H:%M:%S.%N
  114. path /var/log/kube-controller-manager.log
  115. pos_file /var/log/es-kube-controller-manager.log.pos
  116. tag kube-controller-manager
  117. </source>
  118. # Example:
  119. # W0204 06:49:18.239674 7 reflector.go:245] pkg/scheduler/factory/factory.go:193: watch of *api.Service ended with: 401: The event in requested index is outdated and cleared (the requested history has been cleared [2578313/2577886]) [2579312]
  120. <source>
  121. @id kube-scheduler.log
  122. @type tail
  123. format multiline
  124. multiline_flush_interval 5s
  125. format_firstline /^\w\d{4}/
  126. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  127. time_format %m%d %H:%M:%S.%N
  128. path /var/log/kube-scheduler.log
  129. pos_file /var/log/es-kube-scheduler.log.pos
  130. tag kube-scheduler
  131. </source>
  132. # Example:
  133. # I1104 10:36:20.242766 5 rescheduler.go:73] Running Rescheduler
  134. <source>
  135. @id rescheduler.log
  136. @type tail
  137. format multiline
  138. multiline_flush_interval 5s
  139. format_firstline /^\w\d{4}/
  140. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  141. time_format %m%d %H:%M:%S.%N
  142. path /var/log/rescheduler.log
  143. pos_file /var/log/es-rescheduler.log.pos
  144. tag rescheduler
  145. </source>
  146. # Logs from systemd-journal for interesting services.
  147. # TODO(random-liu): Remove this after cri container runtime rolls out.
  148. <source>
  149. @id journald-docker
  150. @type systemd
  151. filters [{ "_SYSTEMD_UNIT": "docker.service" }]
  152. <storage>
  153. @type local
  154. persistent true
  155. </storage>
  156. read_from_head true
  157. tag docker
  158. </source>
  159. <source>
  160. @id journald-container-runtime
  161. @type systemd
  162. filters [{ "_SYSTEMD_UNIT": "{{ container_runtime }}.service" }]
  163. <storage>
  164. @type local
  165. persistent true
  166. </storage>
  167. read_from_head true
  168. tag container-runtime
  169. </source>
  170. <source>
  171. @id journald-kubelet
  172. @type systemd
  173. filters [{ "_SYSTEMD_UNIT": "kubelet.service" }]
  174. <storage>
  175. @type local
  176. persistent true
  177. </storage>
  178. read_from_head true
  179. tag kubelet
  180. </source>
  181. <source>
  182. @id journald-node-problem-detector
  183. @type systemd
  184. filters [{ "_SYSTEMD_UNIT": "node-problem-detector.service" }]
  185. <storage>
  186. @type local
  187. persistent true
  188. </storage>
  189. read_from_head true
  190. tag node-problem-detector
  191. </source>
  192. <source>
  193. @id kernel
  194. @type systemd
  195. filters [{ "_TRANSPORT": "kernel" }]
  196. <storage>
  197. @type local
  198. persistent true
  199. </storage>
  200. <entry>
  201. fields_strip_underscores true
  202. fields_lowercase true
  203. </entry>
  204. read_from_head true
  205. tag kernel
  206. </source>
  207. forward.input.conf: |-
  208. # Takes the messages sent over TCP
  209. <source>
  210. @type forward
  211. </source>
  212. monitoring.conf: |-
  213. # Prometheus Exporter Plugin
  214. # input plugin that exports metrics
  215. <source>
  216. @type prometheus
  217. </source>
  218. <source>
  219. @type monitor_agent
  220. </source>
  221. # input plugin that collects metrics from MonitorAgent
  222. <source>
  223. @type prometheus_monitor
  224. <labels>
  225. host ${hostname}
  226. </labels>
  227. </source>
  228. # input plugin that collects metrics for output plugin
  229. <source>
  230. @type prometheus_output_monitor
  231. <labels>
  232. host ${hostname}
  233. </labels>
  234. </source>
  235. # input plugin that collects metrics for in_tail plugin
  236. <source>
  237. @type prometheus_tail_monitor
  238. <labels>
  239. host ${hostname}
  240. </labels>
  241. </source>
  242. output.conf: |-
  243. # Enriches records with Kubernetes metadata
  244. <filter kubernetes.**>
  245. @type kubernetes_metadata
  246. </filter>
  247. <match **>
  248. @id elasticsearch
  249. @type elasticsearch
  250. @log_level info
  251. include_tag_key true
  252. host elasticsearch-logging
  253. port 9200
  254. logstash_format true
  255. logstash_prefix fluentd-k8s
  256. logstash_dateformat %Y.%m.%d
  257. <buffer>
  258. @type file
  259. path /var/log/fluentd-buffers/kubernetes.system.buffer
  260. flush_mode interval
  261. retry_type exponential_backoff
  262. flush_thread_count 2
  263. flush_interval 5s
  264. retry_forever
  265. retry_max_interval 30
  266. chunk_limit_size 2M
  267. queue_limit_length 8
  268. overflow_action block
  269. </buffer>
  270. </match>