You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

328 lines
13 KiB

  1. apiVersion: v1
  2. kind: ConfigMap
  3. metadata:
  4. name: fluentd-config
  5. namespace: "kube-system"
  6. data:
  7. {{ fluentd_config_file }}: |
  8. # This configuration file for Fluentd / td-agent is used
  9. # to watch changes to Docker log files. The kubelet creates symlinks that
  10. # capture the pod name, namespace, container name & Docker container ID
  11. # to the docker logs for pods in the /var/log/containers directory on the host.
  12. # If running this fluentd configuration in a Docker container, the /var/log
  13. # directory should be mounted in the container.
  14. #
  15. # These logs are then submitted to Elasticsearch which assumes the
  16. # installation of the fluent-plugin-elasticsearch & the
  17. # fluent-plugin-kubernetes_metadata_filter plugins.
  18. # See https://github.com/uken/fluent-plugin-elasticsearch &
  19. # https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter for
  20. # more information about the plugins.
  21. # Maintainer: Jimmi Dyson <jimmidyson@gmail.com>
  22. #
  23. # Example
  24. # =======
  25. # A line in the Docker log file might look like this JSON:
  26. #
  27. # {"log":"2014/09/25 21:15:03 Got request with path wombat\n",
  28. # "stream":"stderr",
  29. # "time":"2014-09-25T21:15:03.499185026Z"}
  30. #
  31. # The time_format specification below makes sure we properly
  32. # parse the time format produced by Docker. This will be
  33. # submitted to Elasticsearch and should appear like:
  34. # $ curl 'http://elasticsearch-logging:9200/_search?pretty'
  35. # ...
  36. # {
  37. # "_index" : "logstash-2014.09.25",
  38. # "_type" : "fluentd",
  39. # "_id" : "VBrbor2QTuGpsQyTCdfzqA",
  40. # "_score" : 1.0,
  41. # "_source":{"log":"2014/09/25 22:45:50 Got request with path wombat\n",
  42. # "stream":"stderr","tag":"docker.container.all",
  43. # "@timestamp":"2014-09-25T22:45:50+00:00"}
  44. # },
  45. # ...
  46. #
  47. # The Kubernetes fluentd plugin is used to write the Kubernetes metadata to the log
  48. # record & add labels to the log record if properly configured. This enables users
  49. # to filter & search logs on any metadata.
  50. # For example a Docker container's logs might be in the directory:
  51. #
  52. # /var/lib/docker/containers/997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b
  53. #
  54. # and in the file:
  55. #
  56. # 997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b-json.log
  57. #
  58. # where 997599971ee6... is the Docker ID of the running container.
  59. # The Kubernetes kubelet makes a symbolic link to this file on the host machine
  60. # in the /var/log/containers directory which includes the pod name and the Kubernetes
  61. # container name:
  62. #
  63. # synthetic-logger-0.25lps-pod_default_synth-lgr-997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b.log
  64. # ->
  65. # /var/lib/docker/containers/997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b/997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b-json.log
  66. #
  67. # The /var/log directory on the host is mapped to the /var/log directory in the container
  68. # running this instance of Fluentd and we end up collecting the file:
  69. #
  70. # /var/log/containers/synthetic-logger-0.25lps-pod_default_synth-lgr-997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b.log
  71. #
  72. # This results in the tag:
  73. #
  74. # var.log.containers.synthetic-logger-0.25lps-pod_default_synth-lgr-997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b.log
  75. #
  76. # The Kubernetes fluentd plugin is used to extract the namespace, pod name & container name
  77. # which are added to the log message as a kubernetes field object & the Docker container ID
  78. # is also added under the docker field object.
  79. # The final tag is:
  80. #
  81. # kubernetes.var.log.containers.synthetic-logger-0.25lps-pod_default_synth-lgr-997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b.log
  82. #
  83. # And the final log record look like:
  84. #
  85. # {
  86. # "log":"2014/09/25 21:15:03 Got request with path wombat\n",
  87. # "stream":"stderr",
  88. # "time":"2014-09-25T21:15:03.499185026Z",
  89. # "kubernetes": {
  90. # "namespace": "default",
  91. # "pod_name": "synthetic-logger-0.25lps-pod",
  92. # "container_name": "synth-lgr"
  93. # },
  94. # "docker": {
  95. # "container_id": "997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b"
  96. # }
  97. # }
  98. #
  99. # This makes it easier for users to search for logs by pod name or by
  100. # the name of the Kubernetes container regardless of how many times the
  101. # Kubernetes pod has been restarted (resulting in a several Docker container IDs).
  102. #
  103. # TODO: Propagate the labels associated with a container along with its logs
  104. # so users can query logs using labels as well as or instead of the pod name
  105. # and container name. This is simply done via configuration of the Kubernetes
  106. # fluentd plugin but requires secrets to be enabled in the fluent pod. This is a
  107. # problem yet to be solved as secrets are not usable in static pods which the fluentd
  108. # pod must be until a per-node controller is available in Kubernetes.
  109. # Prevent fluentd from handling records containing its own logs. Otherwise
  110. # it can lead to an infinite loop, when error in sending one message generates
  111. # another message which also fails to be sent and so on.
  112. <match fluent.**>
  113. type null
  114. </match>
  115. # Example:
  116. # {"log":"[info:2016-02-16T16:04:05.930-08:00] Some log text here\n","stream":"stdout","time":"2016-02-17T00:04:05.931087621Z"}
  117. <source>
  118. type tail
  119. path /var/log/containers/*.log
  120. pos_file /var/log/es-containers.log.pos
  121. time_format %Y-%m-%dT%H:%M:%S.%NZ
  122. tag kubernetes.*
  123. format json
  124. read_from_head true
  125. </source>
  126. # Example:
  127. # 2015-12-21 23:17:22,066 [salt.state ][INFO ] Completed state [net.ipv4.ip_forward] at time 23:17:22.066081
  128. <source>
  129. type tail
  130. format /^(?<time>[^ ]* [^ ,]*)[^\[]*\[[^\]]*\]\[(?<severity>[^ \]]*) *\] (?<message>.*)$/
  131. time_format %Y-%m-%d %H:%M:%S
  132. path /var/log/salt/minion
  133. pos_file /var/log/es-salt.pos
  134. tag salt
  135. </source>
  136. # Example:
  137. # Dec 21 23:17:22 gke-foo-1-1-4b5cbd14-node-4eoj startupscript: Finished running startup script /var/run/google.startup.script
  138. <source>
  139. type tail
  140. format syslog
  141. path /var/log/startupscript.log
  142. pos_file /var/log/es-startupscript.log.pos
  143. tag startupscript
  144. </source>
  145. # Examples:
  146. # time="2016-02-04T06:51:03.053580605Z" level=info msg="GET /containers/json"
  147. # time="2016-02-04T07:53:57.505612354Z" level=error msg="HTTP Error" err="No such image: -f" statusCode=404
  148. <source>
  149. type tail
  150. format /^time="(?<time>[^)]*)" level=(?<severity>[^ ]*) msg="(?<message>[^"]*)"( err="(?<error>[^"]*)")?( statusCode=($<status_code>\d+))?/
  151. path /var/log/docker.log
  152. pos_file /var/log/es-docker.log.pos
  153. tag docker
  154. </source>
  155. # Example:
  156. # 2016/02/04 06:52:38 filePurge: successfully removed file /var/etcd/data/member/wal/00000000000006d0-00000000010a23d1.wal
  157. <source>
  158. type tail
  159. # Not parsing this, because it doesn't have anything particularly useful to
  160. # parse out of it (like severities).
  161. format none
  162. path /var/log/etcd.log
  163. pos_file /var/log/es-etcd.log.pos
  164. tag etcd
  165. </source>
  166. # Multi-line parsing is required for all the kube logs because very large log
  167. # statements, such as those that include entire object bodies, get split into
  168. # multiple lines by glog.
  169. # Example:
  170. # 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]
  171. <source>
  172. type tail
  173. format multiline
  174. multiline_flush_interval 5s
  175. format_firstline /^\w\d{4}/
  176. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  177. time_format %m%d %H:%M:%S.%N
  178. path /var/log/kubelet.log
  179. pos_file /var/log/es-kubelet.log.pos
  180. tag kubelet
  181. </source>
  182. # Example:
  183. # 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
  184. <source>
  185. type tail
  186. format multiline
  187. multiline_flush_interval 5s
  188. format_firstline /^\w\d{4}/
  189. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  190. time_format %m%d %H:%M:%S.%N
  191. path /var/log/kube-proxy.log
  192. pos_file /var/log/es-kube-proxy.log.pos
  193. tag kube-proxy
  194. </source>
  195. # Example:
  196. # 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]
  197. <source>
  198. type tail
  199. format multiline
  200. multiline_flush_interval 5s
  201. format_firstline /^\w\d{4}/
  202. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  203. time_format %m%d %H:%M:%S.%N
  204. path /var/log/kube-apiserver.log
  205. pos_file /var/log/es-kube-apiserver.log.pos
  206. tag kube-apiserver
  207. </source>
  208. # Example:
  209. # I0204 06:55:31.872680 5 servicecontroller.go:277] LB already exists and doesn't need update for service kube-system/kube-ui
  210. <source>
  211. type tail
  212. format multiline
  213. multiline_flush_interval 5s
  214. format_firstline /^\w\d{4}/
  215. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  216. time_format %m%d %H:%M:%S.%N
  217. path /var/log/kube-controller-manager.log
  218. pos_file /var/log/es-kube-controller-manager.log.pos
  219. tag kube-controller-manager
  220. </source>
  221. # Example:
  222. # 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]
  223. <source>
  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-scheduler.log
  231. pos_file /var/log/es-kube-scheduler.log.pos
  232. tag kube-scheduler
  233. </source>
  234. # Example:
  235. # I1104 10:36:20.242766 5 rescheduler.go:73] Running Rescheduler
  236. <source>
  237. type tail
  238. format multiline
  239. multiline_flush_interval 5s
  240. format_firstline /^\w\d{4}/
  241. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  242. time_format %m%d %H:%M:%S.%N
  243. path /var/log/rescheduler.log
  244. pos_file /var/log/es-rescheduler.log.pos
  245. tag rescheduler
  246. </source>
  247. # Example:
  248. # I0603 15:31:05.793605 6 cluster_manager.go:230] Reading config from path /etc/gce.conf
  249. <source>
  250. type tail
  251. format multiline
  252. multiline_flush_interval 5s
  253. format_firstline /^\w\d{4}/
  254. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  255. time_format %m%d %H:%M:%S.%N
  256. path /var/log/glbc.log
  257. pos_file /var/log/es-glbc.log.pos
  258. tag glbc
  259. </source>
  260. # Example:
  261. # I0603 15:31:05.793605 6 cluster_manager.go:230] Reading config from path /etc/gce.conf
  262. <source>
  263. type tail
  264. format multiline
  265. multiline_flush_interval 5s
  266. format_firstline /^\w\d{4}/
  267. format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
  268. time_format %m%d %H:%M:%S.%N
  269. path /var/log/cluster-autoscaler.log
  270. pos_file /var/log/es-cluster-autoscaler.log.pos
  271. tag cluster-autoscaler
  272. </source>
  273. <filter kubernetes.**>
  274. type kubernetes_metadata
  275. </filter>
  276. ## Prometheus Exporter Plugin
  277. ## input plugin that exports metrics
  278. #<source>
  279. # type prometheus
  280. #</source>
  281. #<source>
  282. # type monitor_agent
  283. #</source>
  284. #<source>
  285. # type forward
  286. #</source>
  287. ## input plugin that collects metrics from MonitorAgent
  288. #<source>
  289. # @type prometheus_monitor
  290. # <labels>
  291. # host ${hostname}
  292. # </labels>
  293. #</source>
  294. ## input plugin that collects metrics for output plugin
  295. #<source>
  296. # @type prometheus_output_monitor
  297. # <labels>
  298. # host ${hostname}
  299. # </labels>
  300. #</source>
  301. ## input plugin that collects metrics for in_tail plugin
  302. #<source>
  303. # @type prometheus_tail_monitor
  304. # <labels>
  305. # host ${hostname}
  306. # </labels>
  307. #</source>
  308. <match **>
  309. type elasticsearch
  310. user "#{ENV['FLUENT_ELASTICSEARCH_USER']}"
  311. password "#{ENV['FLUENT_ELASTICSEARCH_PASSWORD']}"
  312. log_level info
  313. include_tag_key true
  314. host elasticsearch-logging
  315. port 9200
  316. logstash_format true
  317. # Set the chunk limit the same as for fluentd-gcp.
  318. buffer_chunk_limit 2M
  319. # Cap buffer memory usage to 2MiB/chunk * 32 chunks = 64 MiB
  320. buffer_queue_limit 32
  321. flush_interval 5s
  322. # Never wait longer than 5 minutes between retries.
  323. max_retry_wait 30
  324. # Disable the limit on the number of retries (retry forever).
  325. disable_retry_limit
  326. # Use multiple threads for processing.
  327. num_threads 8
  328. </match>