Overview

The sources field is an array, and multiple source configurations can be filled in a Pipeline.

Therefore, please note that name of all sources is required as the unique identifier of the source in the pipeline.

Source Common Configuration

The following configurations are available for all sources.

enabled

fieldtyperequireddefaultdescription
enabledboolfalsetruewhether to enable the source

name

fieldtyperequireddefaultdescription
namestringtruesource name

fields

fieldtyperequireddefaultdescription
fieldsmapfalsecustomize additional fields added to the event

For example:

Example

  1. sources:
  2. - type: file
  3. name: access
  4. paths:
  5. - /var/log/*.log
  6. fields:
  7. service: demo

service: demo will be added to all collected logs.

fieldsFromEnv

fieldtyperequireddefaultdescription
fieldsFromEnvmapfalseadditional fields added to the event, the value is the key of the env

For example:

Example

  1. sources:
  2. - type: file
  3. name: access
  4. paths:
  5. - /var/log/*.log
  6. fieldsFromEnv:
  7. service: SVC_NAME

Loggie will get the value ${SVC_NAME} from the environment variable where Loggie is located, and then add a field to all log events:service: ${SVC_NAME}.

fieldsUnderRoot

fieldtyperequireddefaultdescription
fieldsUnderRootboolfalsefalsewhether the additional fields are placed at the root of the event

For example, by default, the output log format is:

  1. {
  2. "body": "hello world",
  3. "fields": {
  4. "service": "demo"
  5. }
  6. }

If you set fieldsUnderRoot=true, the output log format is:

  1. {
  2. "body": "hello world",
  3. "service": "demo"
  4. }

fieldsUnderKey

fieldtyperequireddefaultdescription
fieldsUnderKeystringfalsefieldsif fieldsUnderRoot=false, the key of the field

For example, you can modify the default field fields to be tag:

  1. {
  2. "body": "hello world",
  3. "tag": {
  4. "service": "demo"
  5. }
  6. }

codec

fieldtyperequireddefaultdescription
codecfalseWhen the source receives data, it is used for parsing and preprocessing
codec.typestringfalsenone

Please note: Currently only file source supports source codec.

type: json

fieldtyperequireddefaultdescription
codec.bodyFieldsfalseUse this field in the json data asbody

Configuration example:

type: json

  1. sources:
  2. - type: file
  3. name: nginx
  4. paths:
  5. - /var/log/*.log
  6. codec:
  7. type: json
  8. bodyFields: log

If the collected log is:

  1. {"log":"I0610 08:29:07.698664 Waiting for caches to sync\n", "stream":"stderr", "time:"2021-06-10T08:29:07.698731204Z"}

Then the event after codec is:

  1. body: "I0610 08:29:07.698664 Waiting for caches to sync"

Note: Currently fields other than bodyFields are discarded.

type: regex

fieldtyperequireddefaultdescription
codec.patterntrueregular expression
codec.bodyFieldstrueuse the field extracted by the regular as body

Configuration example:

type: regex

  1. sources:
  2. - type: file
  3. name: nginx
  4. paths:
  5. - /var/log/*.log
  6. codec:
  7. type: regex
  8. pattern: ^(?P<time>[^ ^Z]+Z) (?P<stream>stdout|stderr) (?P<logtag>[^ ]*) (?P<log>.*)$
  9. bodyFields: log

If the collected log is:

  1. 2021-12-01T03:13:58.298476921Z stderr F INFO [main] Starting service [Catalina]

Then the event after codec is:

  1. body: "INFO [main] Starting service [Catalina]"

Note: Currently fields other than bodyFields are discarded.