fluentd-es-configmap.yaml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  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. # 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 name 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. time_format %Y-%m-%dT%H:%M:%S.%NZ
  117. tag raw.kubernetes.*
  118. read_from_head true
  119. <parse>
  120. @type multi_format
  121. <pattern>
  122. format json
  123. time_key time
  124. time_format %Y-%m-%dT%H:%M:%S.%NZ
  125. </pattern>
  126. <pattern>
  127. format /^(?<time>.+) (?<stream>stdout|stderr) [^ ]* (?<log>.*)$/
  128. time_format %Y-%m-%dT%H:%M:%S.%N%:z
  129. </pattern>
  130. </parse>
  131. </source>
  132. # Detect exceptions in the log output and forward them as one log entry.
  133. <match raw.kubernetes.**>
  134. @id raw.kubernetes
  135. @type detect_exceptions
  136. remove_tag_prefix raw
  137. message log
  138. stream stream
  139. multiline_flush_interval 5
  140. max_bytes 500000
  141. max_lines 1000
  142. </match>
  143. system.input.conf: |-
  144. # Example:
  145. # 2015-12-21 23:17:22,066 [salt.state ][INFO ] Completed state [net.ipv4.ip_forward] at time 23:17:22.066081
  146. <source>
  147. @id minion
  148. @type tail
  149. format /^(?<time>[^ ]* [^ ,]*)[^\[]*\[[^\]]*\]\[(?<severity>[^ \]]*) *\] (?<message>.*)$/
  150. time_format %Y-%m-%d %H:%M:%S
  151. path /var/log/salt/minion
  152. pos_file /var/log/salt.pos
  153. tag salt
  154. </source>
  155. # Example:
  156. # Dec 21 23:17:22 gke-foo-1-1-4b5cbd14-node-4eoj startupscript: Finished running startup script /var/run/google.startup.script
  157. <source>
  158. @id startupscript.log
  159. @type tail
  160. format syslog
  161. path /var/log/startupscript.log
  162. pos_file /var/log/es-startupscript.log.pos
  163. tag startupscript
  164. </source>
  165. # Examples:
  166. # time="2016-02-04T06:51:03.053580605Z" level=info msg="GET /containers/json"
  167. # time="2016-02-04T07:53:57.505612354Z" level=error msg="HTTP Error" err="No such image: -f" statusCode=404
  168. # TODO(random-liu): Remove this after cri container runtime rolls out.
  169. <source>
  170. @id docker.log
  171. @type tail
  172. format /^time="(?<time>[^)]*)" level=(?<severity>[^ ]*) msg="(?<message>[^"]*)"( err="(?<error>[^"]*)")?( statusCode=($<status_code>\d+))?/
  173. path /var/log/docker.log
  174. pos_file /var/log/es-docker.log.pos
  175. tag docker
  176. </source>
  177. # Example:
  178. # 2016/02/04 06:52:38 filePurge: successfully removed file /var/etcd/data/member/wal/00000000000006d0-00000000010a23d1.wal
  179. <source>
  180. @id etcd.log
  181. @type tail
  182. # Not parsing this, because it doesn't have anything particularly useful to
  183. # parse out of it (like severities).
  184. format none
  185. path /var/log/etcd.log
  186. pos_file /var/log/es-etcd.log.pos
  187. tag etcd
  188. </source>
  189. # Multi-line parsing is required for all the kube logs because very large log
  190. # statements, such as those that include entire object bodies, get split into
  191. # multiple lines by glog.
  192. # Example:
  193. # 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]
  194. <source>
  195. @id kubelet.log
  196. @type tail
  197. format multiline
  198. multiline_flush_interval 5s
  199. format_firstline /^\w\d{4}/
  200. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  201. time_format %m%d %H:%M:%S.%N
  202. path /var/log/kubelet.log
  203. pos_file /var/log/es-kubelet.log.pos
  204. tag kubelet
  205. </source>
  206. # Example:
  207. # I1118 21:26:53.975789 6 proxier.go:1096] Port "nodePort for logging/default-http-backend:http" (:31429/tcp) was open before and is still needed
  208. <source>
  209. @id kube-proxy.log
  210. @type tail
  211. format multiline
  212. multiline_flush_interval 5s
  213. format_firstline /^\w\d{4}/
  214. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  215. time_format %m%d %H:%M:%S.%N
  216. path /var/log/kube-proxy.log
  217. pos_file /var/log/es-kube-proxy.log.pos
  218. tag kube-proxy
  219. </source>
  220. # Example:
  221. # 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]
  222. <source>
  223. @id kube-apiserver.log
  224. @type tail
  225. format multiline
  226. multiline_flush_interval 5s
  227. format_firstline /^\w\d{4}/
  228. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  229. time_format %m%d %H:%M:%S.%N
  230. path /var/log/kube-apiserver.log
  231. pos_file /var/log/es-kube-apiserver.log.pos
  232. tag kube-apiserver
  233. </source>
  234. # Example:
  235. # I0204 06:55:31.872680 5 servicecontroller.go:277] LB already exists and doesn't need update for service logging/kube-ui
  236. <source>
  237. @id kube-controller-manager.log
  238. @type tail
  239. format multiline
  240. multiline_flush_interval 5s
  241. format_firstline /^\w\d{4}/
  242. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  243. time_format %m%d %H:%M:%S.%N
  244. path /var/log/kube-controller-manager.log
  245. pos_file /var/log/es-kube-controller-manager.log.pos
  246. tag kube-controller-manager
  247. </source>
  248. # Example:
  249. # 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]
  250. <source>
  251. @id kube-scheduler.log
  252. @type tail
  253. format multiline
  254. multiline_flush_interval 5s
  255. format_firstline /^\w\d{4}/
  256. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  257. time_format %m%d %H:%M:%S.%N
  258. path /var/log/kube-scheduler.log
  259. pos_file /var/log/es-kube-scheduler.log.pos
  260. tag kube-scheduler
  261. </source>
  262. # Example:
  263. # I1104 10:36:20.242766 5 rescheduler.go:73] Running Rescheduler
  264. <source>
  265. @id rescheduler.log
  266. @type tail
  267. format multiline
  268. multiline_flush_interval 5s
  269. format_firstline /^\w\d{4}/
  270. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  271. time_format %m%d %H:%M:%S.%N
  272. path /var/log/rescheduler.log
  273. pos_file /var/log/es-rescheduler.log.pos
  274. tag rescheduler
  275. </source>
  276. # Example:
  277. # I0603 15:31:05.793605 6 cluster_manager.go:230] Reading config from path /etc/gce.conf
  278. <source>
  279. @id glbc.log
  280. @type tail
  281. format multiline
  282. multiline_flush_interval 5s
  283. format_firstline /^\w\d{4}/
  284. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  285. time_format %m%d %H:%M:%S.%N
  286. path /var/log/glbc.log
  287. pos_file /var/log/es-glbc.log.pos
  288. tag glbc
  289. </source>
  290. # Example:
  291. # I0603 15:31:05.793605 6 cluster_manager.go:230] Reading config from path /etc/gce.conf
  292. <source>
  293. @id cluster-autoscaler.log
  294. @type tail
  295. format multiline
  296. multiline_flush_interval 5s
  297. format_firstline /^\w\d{4}/
  298. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  299. time_format %m%d %H:%M:%S.%N
  300. path /var/log/cluster-autoscaler.log
  301. pos_file /var/log/es-cluster-autoscaler.log.pos
  302. tag cluster-autoscaler
  303. </source>
  304. # Logs from systemd-journal for interesting services.
  305. # TODO(random-liu): Remove this after cri container runtime rolls out.
  306. <source>
  307. @id journald-docker
  308. @type systemd
  309. filters [{ "_SYSTEMD_UNIT": "docker.service" }]
  310. <storage>
  311. @type local
  312. persistent true
  313. </storage>
  314. read_from_head true
  315. tag docker
  316. </source>
  317. <source>
  318. @id journald-container-runtime
  319. @type systemd
  320. filters [{ "_SYSTEMD_UNIT": "{{ container_runtime }}.service" }]
  321. <storage>
  322. @type local
  323. persistent true
  324. </storage>
  325. read_from_head true
  326. tag container-runtime
  327. </source>
  328. <source>
  329. @id journald-kubelet
  330. @type systemd
  331. filters [{ "_SYSTEMD_UNIT": "kubelet.service" }]
  332. <storage>
  333. @type local
  334. persistent true
  335. </storage>
  336. read_from_head true
  337. tag kubelet
  338. </source>
  339. <source>
  340. @id journald-node-problem-detector
  341. @type systemd
  342. filters [{ "_SYSTEMD_UNIT": "node-problem-detector.service" }]
  343. <storage>
  344. @type local
  345. persistent true
  346. </storage>
  347. read_from_head true
  348. tag node-problem-detector
  349. </source>
  350. <source>
  351. @id kernel
  352. @type systemd
  353. filters [{ "_TRANSPORT": "kernel" }]
  354. <storage>
  355. @type local
  356. persistent true
  357. </storage>
  358. <entry>
  359. fields_strip_underscores true
  360. fields_lowercase true
  361. </entry>
  362. read_from_head true
  363. tag kernel
  364. </source>
  365. forward.input.conf: |-
  366. # Takes the messages sent over TCP
  367. <source>
  368. @type forward
  369. </source>
  370. monitoring.conf: |-
  371. # Prometheus Exporter Plugin
  372. # input plugin that exports metrics
  373. <source>
  374. @type prometheus
  375. </source>
  376. <source>
  377. @type monitor_agent
  378. </source>
  379. # input plugin that collects metrics from MonitorAgent
  380. <source>
  381. @type prometheus_monitor
  382. <labels>
  383. host ${hostname}
  384. </labels>
  385. </source>
  386. # input plugin that collects metrics for output plugin
  387. <source>
  388. @type prometheus_output_monitor
  389. <labels>
  390. host ${hostname}
  391. </labels>
  392. </source>
  393. # input plugin that collects metrics for in_tail plugin
  394. <source>
  395. @type prometheus_tail_monitor
  396. <labels>
  397. host ${hostname}
  398. </labels>
  399. </source>
  400. output.conf: |-
  401. # Enriches records with Kubernetes metadata
  402. <filter kubernetes.**>
  403. @type kubernetes_metadata
  404. </filter>
  405. <match **>
  406. @id elasticsearch
  407. @type elasticsearch
  408. @log_level info
  409. include_tag_key true
  410. host elasticsearch-logging
  411. port 9200
  412. logstash_format true
  413. <buffer>
  414. @type file
  415. path /var/log/fluentd-buffers/kubernetes.system.buffer
  416. flush_mode interval
  417. retry_type exponential_backoff
  418. flush_thread_count 2
  419. flush_interval 5s
  420. retry_forever
  421. retry_max_interval 30
  422. chunk_limit_size 2M
  423. queue_limit_length 8
  424. overflow_action block
  425. </buffer>
  426. </match>