fluentd-configmap.yaml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. kind: ConfigMap
  2. apiVersion: v1
  3. metadata:
  4. name: fluentd-es-config-v0.2.0
  5. namespace: public-service
  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. # This configuration file for Fluentd / td-agent is used
  15. # to watch changes to Docker log files. The kubelet creates symlinks that
  16. # capture the pod name, namespace, container name & Docker container ID
  17. # to the docker logs for pods in the /var/log/containers directory on the host.
  18. # If running this fluentd configuration in a Docker container, the /var/log
  19. # directory should be mounted in the container.
  20. #
  21. # These logs are then submitted to Elasticsearch which assumes the
  22. # installation of the fluent-plugin-elasticsearch & the
  23. # fluent-plugin-kubernetes_metadata_filter plugins.
  24. # See https://github.com/uken/fluent-plugin-elasticsearch &
  25. # https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter for
  26. # more information about the plugins.
  27. #
  28. # Example
  29. # =======
  30. # A line in the Docker log file might look like this JSON:
  31. #
  32. # {"log":"2014/09/25 21:15:03 Got request with path wombat\n",
  33. # "stream":"stderr",
  34. # "time":"2014-09-25T21:15:03.499185026Z"}
  35. #
  36. # The time_format specification below makes sure we properly
  37. # parse the time format produced by Docker. This will be
  38. # submitted to Elasticsearch and should appear like:
  39. # $ curl 'http://elasticsearch-logging:9200/_search?pretty'
  40. # ...
  41. # {
  42. # "_index" : "logstash-2014.09.25",
  43. # "_type" : "fluentd",
  44. # "_id" : "VBrbor2QTuGpsQyTCdfzqA",
  45. # "_score" : 1.0,
  46. # "_source":{"log":"2014/09/25 22:45:50 Got request with path wombat\n",
  47. # "stream":"stderr","tag":"docker.container.all",
  48. # "@timestamp":"2014-09-25T22:45:50+00:00"}
  49. # },
  50. # ...
  51. #
  52. # The Kubernetes fluentd plugin is used to write the Kubernetes metadata to the log
  53. # record & add labels to the log record if properly configured. This enables users
  54. # to filter & search logs on any metadata.
  55. # For example a Docker container's logs might be in the directory:
  56. #
  57. # /var/lib/docker/containers/997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b
  58. #
  59. # and in the file:
  60. #
  61. # 997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b-json.log
  62. #
  63. # where 997599971ee6... is the Docker ID of the running container.
  64. # The Kubernetes kubelet makes a symbolic link to this file on the host machine
  65. # in the /var/log/containers directory which includes the pod name and the Kubernetes
  66. # container name:
  67. #
  68. # synthetic-logger-0.25lps-pod_default_synth-lgr-997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b.log
  69. # ->
  70. # /var/lib/docker/containers/997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b/997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b-json.log
  71. #
  72. # The /var/log directory on the host is mapped to the /var/log directory in the container
  73. # running this instance of Fluentd and we end up collecting the file:
  74. #
  75. # /var/log/containers/synthetic-logger-0.25lps-pod_default_synth-lgr-997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b.log
  76. #
  77. # This results in the tag:
  78. #
  79. # var.log.containers.synthetic-logger-0.25lps-pod_default_synth-lgr-997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b.log
  80. #
  81. # The Kubernetes fluentd plugin is used to extract the namespace, pod name & container name
  82. # which are added to the log message as a kubernetes field object & the Docker container ID
  83. # is also added under the docker field object.
  84. # The final tag is:
  85. #
  86. # kubernetes.var.log.containers.synthetic-logger-0.25lps-pod_default_synth-lgr-997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b.log
  87. #
  88. # And the final log record look like:
  89. #
  90. # {
  91. # "log":"2014/09/25 21:15:03 Got request with path wombat\n",
  92. # "stream":"stderr",
  93. # "time":"2014-09-25T21:15:03.499185026Z",
  94. # "kubernetes": {
  95. # "namespace": "default",
  96. # "pod_name": "synthetic-logger-0.25lps-pod",
  97. # "container_name": "synth-lgr"
  98. # },
  99. # "docker": {
  100. # "container_id": "997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b"
  101. # }
  102. # }
  103. #
  104. # This makes it easier for users to search for logs by pod me or by
  105. # the name of the Kubernetes container regardless of how many times the
  106. # Kubernetes pod has been restarted (resulting in a several Docker container IDs).
  107. # Json Log Example:
  108. # {"log":"[info:2016-02-16T16:04:05.930-08:00] Some log text here\n","stream":"stdout","time":"2016-02-17T00:04:05.931087621Z"}
  109. # CRI Log Example:
  110. # 2016-02-17T00:04:05.931087621Z stdout F [info:2016-02-16T16:04:05.930-08:00] Some log text here
  111. <source>
  112. @id fluentd-containers.log
  113. @type tail
  114. path /var/log/containers/*.log
  115. pos_file /var/log/es-containers.log.pos
  116. tag raw.kubernetes.*
  117. read_from_head true
  118. <parse>
  119. @type multi_format
  120. <pattern>
  121. format json
  122. time_key time
  123. time_format %Y-%m-%dT%H:%M:%S.%NZ
  124. </pattern>
  125. <pattern>
  126. format /^(?<time>.+) (?<stream>stdout|stderr) [^ ]* (?<log>.*)$/
  127. time_format %Y-%m-%dT%H:%M:%S.%N%:z
  128. </pattern>
  129. </parse>
  130. </source>
  131. # Detect exceptions in the log output and forward them as one log entry.
  132. <match raw.kubernetes.**>
  133. @id raw.kubernetes
  134. @type detect_exceptions
  135. remove_tag_prefix raw
  136. message log
  137. stream stream
  138. multiline_flush_interval 5
  139. max_bytes 500000
  140. max_lines 1000
  141. </match>
  142. # Concatenate multi-line logs
  143. <filter **>
  144. @id filter_concat
  145. @type concat
  146. key message
  147. multiline_end_regexp /\n$/
  148. separator ""
  149. </filter>
  150. # Enriches records with Kubernetes metadata
  151. <filter kubernetes.**>
  152. @id filter_kubernetes_metadata
  153. @type kubernetes_metadata
  154. </filter>
  155. # Fixes json fields in Elasticsearch
  156. <filter kubernetes.**>
  157. @id filter_parser
  158. @type parser
  159. key_name log
  160. reserve_data true
  161. remove_key_name_field true
  162. <parse>
  163. @type multi_format
  164. <pattern>
  165. format json
  166. </pattern>
  167. <pattern>
  168. format none
  169. </pattern>
  170. </parse>
  171. </filter>
  172. system.input.conf: |-
  173. # Example:
  174. # 2015-12-21 23:17:22,066 [salt.state ][INFO ] Completed state [net.ipv4.ip_forward] at time 23:17:22.066081
  175. <source>
  176. @id minion
  177. @type tail
  178. format /^(?<time>[^ ]* [^ ,]*)[^\[]*\[[^\]]*\]\[(?<severity>[^ \]]*) *\] (?<message>.*)$/
  179. time_format %Y-%m-%d %H:%M:%S
  180. path /var/log/salt/minion
  181. pos_file /var/log/salt.pos
  182. tag salt
  183. </source>
  184. # Example:
  185. # Dec 21 23:17:22 gke-foo-1-1-4b5cbd14-node-4eoj startupscript: Finished running startup script /var/run/google.startup.script
  186. <source>
  187. @id startupscript.log
  188. @type tail
  189. format syslog
  190. path /var/log/startupscript.log
  191. pos_file /var/log/es-startupscript.log.pos
  192. tag startupscript
  193. </source>
  194. # Examples:
  195. # time="2016-02-04T06:51:03.053580605Z" level=info msg="GET /containers/json"
  196. # time="2016-02-04T07:53:57.505612354Z" level=error msg="HTTP Error" err="No such image: -f" statusCode=404
  197. # TODO(random-liu): Remove this after cri container runtime rolls out.
  198. <source>
  199. @id docker.log
  200. @type tail
  201. format /^time="(?<time>[^"]*)" level=(?<severity>[^ ]*) msg="(?<message>[^"]*)"( err="(?<error>[^"]*)")?( statusCode=($<status_code>\d+))?/
  202. path /var/log/docker.log
  203. pos_file /var/log/es-docker.log.pos
  204. tag docker
  205. </source>
  206. # Example:
  207. # 2016/02/04 06:52:38 filePurge: successfully removed file /var/etcd/data/member/wal/00000000000006d0-00000000010a23d1.wal
  208. <source>
  209. @id etcd.log
  210. @type tail
  211. # Not parsing this, because it doesn't have anything particularly useful to
  212. # parse out of it (like severities).
  213. format none
  214. path /var/log/etcd.log
  215. pos_file /var/log/es-etcd.log.pos
  216. tag etcd
  217. </source>
  218. # Multi-line parsing is required for all the kube logs because very large log
  219. # statements, such as those that include entire object bodies, get split into
  220. # multiple lines by glog.
  221. # Example:
  222. # 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]
  223. <source>
  224. @id kubelet.log
  225. @type tail
  226. format multiline
  227. multiline_flush_interval 5s
  228. format_firstline /^\w\d{4}/
  229. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  230. time_format %m%d %H:%M:%S.%N
  231. path /var/log/kubelet.log
  232. pos_file /var/log/es-kubelet.log.pos
  233. tag kubelet
  234. </source>
  235. # Example:
  236. # 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
  237. <source>
  238. @id kube-proxy.log
  239. @type tail
  240. format multiline
  241. multiline_flush_interval 5s
  242. format_firstline /^\w\d{4}/
  243. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  244. time_format %m%d %H:%M:%S.%N
  245. path /var/log/kube-proxy.log
  246. pos_file /var/log/es-kube-proxy.log.pos
  247. tag kube-proxy
  248. </source>
  249. # Example:
  250. # 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]
  251. <source>
  252. @id kube-apiserver.log
  253. @type tail
  254. format multiline
  255. multiline_flush_interval 5s
  256. format_firstline /^\w\d{4}/
  257. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  258. time_format %m%d %H:%M:%S.%N
  259. path /var/log/kube-apiserver.log
  260. pos_file /var/log/es-kube-apiserver.log.pos
  261. tag kube-apiserver
  262. </source>
  263. # Example:
  264. # I0204 06:55:31.872680 5 servicecontroller.go:277] LB already exists and doesn't need update for service kube-system/kube-ui
  265. <source>
  266. @id kube-controller-manager.log
  267. @type tail
  268. format multiline
  269. multiline_flush_interval 5s
  270. format_firstline /^\w\d{4}/
  271. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  272. time_format %m%d %H:%M:%S.%N
  273. path /var/log/kube-controller-manager.log
  274. pos_file /var/log/es-kube-controller-manager.log.pos
  275. tag kube-controller-manager
  276. </source>
  277. # Example:
  278. # 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]
  279. <source>
  280. @id kube-scheduler.log
  281. @type tail
  282. format multiline
  283. multiline_flush_interval 5s
  284. format_firstline /^\w\d{4}/
  285. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  286. time_format %m%d %H:%M:%S.%N
  287. path /var/log/kube-scheduler.log
  288. pos_file /var/log/es-kube-scheduler.log.pos
  289. tag kube-scheduler
  290. </source>
  291. # Example:
  292. # I0603 15:31:05.793605 6 cluster_manager.go:230] Reading config from path /etc/gce.conf
  293. <source>
  294. @id glbc.log
  295. @type tail
  296. format multiline
  297. multiline_flush_interval 5s
  298. format_firstline /^\w\d{4}/
  299. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  300. time_format %m%d %H:%M:%S.%N
  301. path /var/log/glbc.log
  302. pos_file /var/log/es-glbc.log.pos
  303. tag glbc
  304. </source>
  305. # Example:
  306. # I0603 15:31:05.793605 6 cluster_manager.go:230] Reading config from path /etc/gce.conf
  307. <source>
  308. @id cluster-autoscaler.log
  309. @type tail
  310. format multiline
  311. multiline_flush_interval 5s
  312. format_firstline /^\w\d{4}/
  313. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  314. time_format %m%d %H:%M:%S.%N
  315. path /var/log/cluster-autoscaler.log
  316. pos_file /var/log/es-cluster-autoscaler.log.pos
  317. tag cluster-autoscaler
  318. </source>
  319. # Logs from systemd-journal for interesting services.
  320. # TODO(random-liu): Remove this after cri container runtime rolls out.
  321. <source>
  322. @id journald-docker
  323. @type systemd
  324. matches [{ "_SYSTEMD_UNIT": "docker.service" }]
  325. <storage>
  326. @type local
  327. persistent true
  328. path /var/log/journald-docker.pos
  329. </storage>
  330. read_from_head true
  331. tag docker
  332. </source>
  333. <source>
  334. @id journald-container-runtime
  335. @type systemd
  336. matches [{ "_SYSTEMD_UNIT": "{{ fluentd_container_runtime_service }}.service" }]
  337. <storage>
  338. @type local
  339. persistent true
  340. path /var/log/journald-container-runtime.pos
  341. </storage>
  342. read_from_head true
  343. tag container-runtime
  344. </source>
  345. <source>
  346. @id journald-kubelet
  347. @type systemd
  348. matches [{ "_SYSTEMD_UNIT": "kubelet.service" }]
  349. <storage>
  350. @type local
  351. persistent true
  352. path /var/log/journald-kubelet.pos
  353. </storage>
  354. read_from_head true
  355. tag kubelet
  356. </source>
  357. <source>
  358. @id journald-node-problem-detector
  359. @type systemd
  360. matches [{ "_SYSTEMD_UNIT": "node-problem-detector.service" }]
  361. <storage>
  362. @type local
  363. persistent true
  364. path /var/log/journald-node-problem-detector.pos
  365. </storage>
  366. read_from_head true
  367. tag node-problem-detector
  368. </source>
  369. <source>
  370. @id kernel
  371. @type systemd
  372. matches [{ "_TRANSPORT": "kernel" }]
  373. <storage>
  374. @type local
  375. persistent true
  376. path /var/log/kernel.pos
  377. </storage>
  378. <entry>
  379. fields_strip_underscores true
  380. fields_lowercase true
  381. </entry>
  382. read_from_head true
  383. tag kernel
  384. </source>
  385. forward.input.conf: |-
  386. # Takes the messages sent over TCP
  387. <source>
  388. @id forward
  389. @type forward
  390. </source>
  391. monitoring.conf: |-
  392. # Prometheus Exporter Plugin
  393. # input plugin that exports metrics
  394. <source>
  395. @id prometheus
  396. @type prometheus
  397. </source>
  398. <source>
  399. @id monitor_agent
  400. @type monitor_agent
  401. </source>
  402. # input plugin that collects metrics from MonitorAgent
  403. <source>
  404. @id prometheus_monitor
  405. @type prometheus_monitor
  406. <labels>
  407. host ${hostname}
  408. </labels>
  409. </source>
  410. # input plugin that collects metrics for output plugin
  411. <source>
  412. @id prometheus_output_monitor
  413. @type prometheus_output_monitor
  414. <labels>
  415. host ${hostname}
  416. </labels>
  417. </source>
  418. # input plugin that collects metrics for in_tail plugin
  419. <source>
  420. @id prometheus_tail_monitor
  421. @type prometheus_tail_monitor
  422. <labels>
  423. host ${hostname}
  424. </labels>
  425. </source>
  426. output.conf: |-
  427. <match **>
  428. @id elasticsearch
  429. @type elasticsearch
  430. @log_level info
  431. type_name _doc
  432. include_tag_key true
  433. host elasticsearch-logging
  434. port 9200
  435. logstash_format true
  436. <buffer>
  437. @type file
  438. path /var/log/fluentd-buffers/kubernetes.system.buffer
  439. flush_mode interval
  440. retry_type exponential_backoff
  441. flush_thread_count 2
  442. flush_interval 5s
  443. retry_forever
  444. retry_max_interval 30
  445. chunk_limit_size 2M
  446. total_limit_size 500M
  447. overflow_action block
  448. </buffer>
  449. </match>