Logconfig

A namespace-level CRD, which represents a log collection task, is used to collect Pod container logs.

Example

define sink/interceptor directly

  1. apiVersion: loggie.io/v1beta1
  2. kind: LogConfig
  3. metadata:
  4. name: tomcat
  5. namespace: default
  6. spec:
  7. selector:
  8. type: pod
  9. labelSelector:
  10. app: tomcat
  11. pipeline:
  12. sources: |
  13. - type: file
  14. name: common
  15. paths:
  16. - stdout
  17. sink: |
  18. type: dev
  19. printEvents: false
  20. interceptors: |
  21. - type: rateLimit
  22. qps: 90000

reference sink/interceptor

  1. apiVersion: loggie.io/v1beta1
  2. kind: LogConfig
  3. metadata:
  4. name: nginx
  5. namespace: default
  6. spec:
  7. selector:
  8. type: pod
  9. labelSelector:
  10. app: nginx
  11. pipeline:
  12. sources: |
  13. - type: file
  14. name: mylog
  15. paths:
  16. - stdout
  17. sinkRef: default
  18. interceptorRef: default

spec.selector

Indicates the scope of the Pipeline configuration. You can choose to collect a batch of Pods logs.

type: pod

Collect Pods logs

fieldtyperequireddefaultdescription
labelSelectormaptrueUse this label to match Pods, support using to match value, such as app:

Example

  1. spec:
  2. selector:
  3. type: pod
  4. labelSelector:
  5. app: nginx

Indicates that logs of all Pods logs with label app: nginx under the namespace are collected.

Warning

When using type: pod, pipeline can only use file source. Only log collecting in this scene.

cluster

fieldtyperequireddefaultdescription
clusterstringfalse“”Indicates the configuration of the specified delivery Loggie cluster. When deploying multiple sets of Loggie, it is used in with the global system configuration discovery.kubernetes.cluster

spec.pipeline

Indicates one Pipeline, and multiple Pipelines are not supported.

The difference from Pipelines in the configuration file is:

  • sources is actually a string. used in yaml to keep newlines.
  • sinkRef, which represents the referenced Sink CRD instance.
  • interceptorRef, which represents the referenced Interceptor CRD instance.

sources

In LogConfig, when type: pod, several parameters specifically for containerization are added into file source:

fieldtyperequireddefaultdescription
containerNamestringfalseindicates the container name of the specified collection, it is recommended to fill in when the Pod contains multiple containers
excludeContainerPatternsstring arrayfalseexcluded container names, in regular expression form
matchFieldsfalseadd information from Pod to Fields
matchFields.labelKeystring arrayfalseSpecify the Label Key value on the Pod. For example, the Pod contains Label: app: demo, and fill labelKey: appin here. In this case, the label app: demo on the Pod will be added to the file source fields, and the collected logs will be added with the label information. Suitable for pods that matched with different labels. ““ is supported to get all labels.
matchFields.annotationKeystring arrayfalseSimilar to the above labelKey. Inject annotations of pod. ““ is supported
matchFields.envstring arrayfalseSimilar to the above labelKey. Inject env of pod. “*” is supported

Example

  1. apiVersion: loggie.io/v1beta1
  2. kind: LogConfig
  3. metadata:
  4. name: nginx
  5. namespace: default
  6. spec:
  7. selector:
  8. type: pod
  9. labelSelector:
  10. app: nginx
  11. pipeline:
  12. sources: |
  13. - type: file
  14. name: mylog
  15. containerName: nginx
  16. matchFields:
  17. labelKey: ["app"]
  18. paths:
  19. - stdout

interceptors

fieldtyperequireddefaultdescription
interceptorsstringfalseIndicates the interceptor of the Pipeline, which is used in a similar way to the sources above

sink

fieldtyperequireddefaultdescription
sinkstringfalseRepresents the sink of the Pipeline, which is used in a similar way to the sources above

If you want the sink and interceptor to be reused between different ClusterLogConfig/LogConfig, you can use the following ref method:

sinkRef

fieldtyperequireddefaultdescription
sinkRefstringfalseRepresents the Sink CR referenced by this Pipeline

interceptorRef

fieldtyperequireddefaultdescription
interceptorRefstringfalseRepresents the Interceptor CR referenced by this Pipeline