diff --git a/docs/reference/discovery/kubernetes/clusterlogconfig.md b/docs/reference/discovery/kubernetes/clusterlogconfig.md index adb5063..f7d1415 100644 --- a/docs/reference/discovery/kubernetes/clusterlogconfig.md +++ b/docs/reference/discovery/kubernetes/clusterlogconfig.md @@ -51,7 +51,7 @@ Cluster级别CRD,可用于: 表示采集带有标签 `app: nginx`的所有Pod的日志。 !!! warning -在`type: pod`时,下面的Pipeline只能使用file source,此时的场景只能是采集日志。 + 在`type: pod`时,下面的Pipeline只能使用file source,此时的场景只能是采集日志。 ### type: node 下发Pipeline配置至该批节点。 diff --git a/docs/reference/discovery/kubernetes/logconfig.md b/docs/reference/discovery/kubernetes/logconfig.md index b60b7a8..96fb519 100644 --- a/docs/reference/discovery/kubernetes/logconfig.md +++ b/docs/reference/discovery/kubernetes/logconfig.md @@ -4,26 +4,56 @@ namespace级别CRD,表示一个日志采集任务,用于采集Pod容器日 !!! example - ```yaml - apiVersion: loggie.io/v1beta1 - kind: LogConfig - metadata: - name: nginx - namespace: default - spec: - selector: - type: pod - labelSelector: - app: nginx - pipeline: - sources: | - - type: file - name: mylog - paths: - - stdout - sinkRef: default - interceptorRef: default - ``` + === "直接定义sink/interceptor方式" + + ```yaml + apiVersion: loggie.io/v1beta1 + kind: LogConfig + metadata: + name: tomcat + namespace: default + spec: + selector: + type: pod + labelSelector: + app: tomcat + pipeline: + sources: | + - type: file + name: common + paths: + - stdout + sink: | + type: dev + printEvents: false + interceptors: | + - type: rateLimit + qps: 90000 + ``` + + === "引用sink和interceptor方式" + + ```yaml + apiVersion: loggie.io/v1beta1 + kind: LogConfig + metadata: + name: nginx + namespace: default + spec: + selector: + type: pod + labelSelector: + app: nginx + pipeline: + sources: | + - type: file + name: mylog + paths: + - stdout + sinkRef: default + interceptorRef: default + ``` + ## spec.selector 表示Pipeline配置适用的范围,可以选择采集一批Pods的日志 @@ -106,6 +136,19 @@ namespace级别CRD,表示一个日志采集任务,用于采集Pod容器日 ``` +### interceptors +| `字段` | `类型` | `是否必填` | `默认值` | `含义` | +| ---------- | ----------- | ----------- | --------- | -------- | +| interceptors | string | 非必填 | | 表示该Pipeline的interceptor,使用方式和以上sources类似 | + +### sink +| `字段` | `类型` | `是否必填` | `默认值` | `含义` | +| ---------- | ----------- | ----------- | --------- | -------- | +| sink | string | 非必填 | | 表示该Pipeline的sink,使用方式和以上的sources类似 | + + +如果你希望sink和interceptor可以在不同的ClusterLogConfig/LogConfig间复用,则可以使用以下ref的方式: + ### sinkRef | `字段` | `类型` | `是否必填` | `默认值` | `含义` | diff --git a/docs/reference/global/args.md b/docs/reference/global/args.md index 0521b64..bd39162 100644 --- a/docs/reference/global/args.md +++ b/docs/reference/global/args.md @@ -1,7 +1,10 @@ ## 系统参数 -- `-config.system`: 默认为loggie.yml,表示指定Loggie系统配置的路径和文件名称 -- `-config.pipeline`: 默认为pipelines.yml,表示Pipeline配置文件所在的路径,需要填写符合glob匹配的路径,比如具体的路径和文件名`/etc/loggie/pipelines.yml`,或者glob匹配的方式,比如`/etc/loggie/*.yml` +- `-config.from`: 默认为file,即默认使用文件的配置方式。可选:env,此时会从环境变量中读取配置(此时不支持reload)。 +- `-config.system`: 默认为loggie.yml,表示指定Loggie系统配置的路径和文件名称。 + (如果`-config.from=env`,则为system配置的环境变量名称) +- `-config.pipeline`: 默认为pipelines.yml,表示Pipeline配置文件所在的路径,需要填写符合glob匹配的路径,比如具体的路径和文件名`/etc/loggie/pipelines.yml`,或者glob匹配的方式,比如`/etc/loggie/*.yml`。 + (如果`-config.from=env`,则为pipeline配置的环境变量名称) !!! warning 值得注意的是,如果`config.pipeline=/etc/loggie`,glob匹配会认为`/etc/loggie`为`/etc`目录下的`loggie`文件,而不是匹配`/etc/loggie`目录下的文件,请避免类似的设置方式 diff --git a/docs/reference/global/discovery.md b/docs/reference/global/discovery.md index 8d44313..4dd7019 100644 --- a/docs/reference/global/discovery.md +++ b/docs/reference/global/discovery.md @@ -37,8 +37,9 @@ | podLogDirPrefix | string | 非必填 | /var/log/pods | kubernetes默认放置的pod标准输出路径 | | fields | map | 非必填 | | 自动添加的元信息 | | fields.node.name | string | 非必填 | node.name | 添加所在节点node name作为元信息,同时使用该值为key | +| fields.node.ip | string | 非必填 | node.ip | 添加所在节点node ip作为元信息,同时使用该值为key | | fields.namespace | string | 非必填 | namespace | 添加namespace作为元信息,同时使用该值为key | | fields.pod.name | string | 非必填 | pod.name | 添加pod name作为元信息,同时使用该值为key | +| fields.pod.ip | string | 非必填 | pod.ip | 添加pod ip作为元信息,同时使用该值为key | | fields.container.name | string | 非必填 | container.name | 添加container name作为元信息,同时使用该值为key | -| fields.logConfig | string | 非必填 | logConfig | 添加logConfig name作为元信息,同时使用该值为key | - +| fields.logConfig | string | 非必填 | logConfig | 添加logConfig name作为元信息,同时使用该值为key | \ No newline at end of file diff --git a/docs/reference/index.md b/docs/reference/index.md index 784c7d8..c9bceda 100644 --- a/docs/reference/index.md +++ b/docs/reference/index.md @@ -88,3 +88,7 @@ Loggie定义了以下几个CRD用于在Kubernetes集群环境里下发配置: - [**Sink**](discovery/kubernetes/sink.md):cluster级别,表示一个sink配置,可以在LogConfig/ClusterLogConfig中引用该Sink。 - [**Interceptors**](discovery/kubernetes/interceptors.md):cluster级别,表示一个interceptors组,可以在LogConfig中引用该interceptors组。 + +!!! note + ClusterLogConfig/LogConfig中的pipeline可以定义sink和interceptor,用于该pipeline的sink/interceptor。 + 如果你希望在多个ClusterLogConfig/LogConfig中复用sink或者interceptor,可以创建Sink/Interceptor CR,在ClusterLogConfig/LogConfig中使用sinkRef/interceptorRef进行引用。 \ No newline at end of file diff --git a/docs/reference/pipelines/interceptor/normalize.md b/docs/reference/pipelines/interceptor/normalize.md index afd8e58..58397c7 100644 --- a/docs/reference/pipelines/interceptor/normalize.md +++ b/docs/reference/pipelines/interceptor/normalize.md @@ -278,6 +278,7 @@ | timestamp.convert[n].fromLayout | string | 必填 | 无 | 指定字段的时间格式(golang形式) | | timestamp.convert[n].toLayout | string | 必填 | 无 | 转换后的时间格式(golang形式),另外可为`unix`和`unix_ms` | | timestamp.convert[n].toType | string | 非必填 | 无 | 转换后的时间字段类型 | +| timestamp.convert[n].local | bool | 非必填 | false | 是否将解析的时间转成当前时区 | !!! example ```yaml @@ -316,7 +317,23 @@ const ( ``` 还可以根据实际情况修改。 - +### fmt + +字段内容重新格式化。可根据其他字段内容进行组合和格式化。 + +| `字段` | `类型` | `是否必填` | `默认值` | `含义` | +| ---------- | ----------- | ----------- | --------- | -------- | +| fmt.fields | map | 必填 | 无 | key表示需要格式化的字段名称,value为需要格式化的内容。可使用`${}`的方式表示取值某个字段 | + +!!! example + ```yaml + interceptors: + - type: normalize + processors: + - fmt: + fields: + d: new-${a.b}-${c} + ``` diff --git a/docs/reference/pipelines/sink/elasticsearch.md b/docs/reference/pipelines/sink/elasticsearch.md index ef07509..ef215eb 100644 --- a/docs/reference/pipelines/sink/elasticsearch.md +++ b/docs/reference/pipelines/sink/elasticsearch.md @@ -50,7 +50,7 @@ | `字段` | `类型` | `是否必填` | `默认值` | `含义` | | ---------- | ----------- | ----------- | --------- | -------- | -| sniff | bool | 非必填 | true | 是否开启sniffer | +| sniff | bool | 非必填 | false | 是否开启sniffer | ## gzip @@ -58,5 +58,9 @@ | ---------- | ----------- | ----------- | --------- | -------- | | gzip | bool | 非必填 | false | 发送数据是否开启gzip压缩 | +## documentId +| `字段` | `类型` | `是否必填` | `默认值` | `含义` | +| ---------- | ----------- | ----------- | --------- | -------- | +| documentId | string | 非必填 | | 发送至elasticsearch的id值,可使用`${}`的方式取某个字段 | diff --git a/docs/reference/pipelines/sink/loki.md b/docs/reference/pipelines/sink/loki.md new file mode 100644 index 0000000..2e39c33 --- /dev/null +++ b/docs/reference/pipelines/sink/loki.md @@ -0,0 +1,39 @@ +# loki + +loki sink用于发送数据至Loki存储。Loki文档可参考[这里](https://grafana.com/docs/loki/latest/)。 + + + +!!! example + + ```yaml + sink: + type: loki + url: "http://localhost:3100/loki/api/v1/push" + ``` + +## url + +| `字段` | `类型` | `是否必填` | `默认值` | `含义` | +| ---------- | ----------- | ----------- | --------- | -------- | +| url | string | 必填 | | push loki的api | + +## tenantId + +| `字段` | `类型` | `是否必填` | `默认值` | `含义` | +| ---------- | ----------- | ----------- | --------- | -------- | +| tenantId | string | 非必填 | | 发送使用的租户名称 | + +## timeout + +| `字段` | `类型` | `是否必填` | `默认值` | `含义` | +| ---------- | ----------- | ----------- | --------- | -------- | +| timeout | time.Duration | 非必填 | 30s | 发送的超时时间 | + +## entryLine + +| `字段` | `类型` | `是否必填` | `默认值` | `含义` | +| ---------- | ----------- | ----------- | --------- | -------- | +| entryLine | string | 非必填 | | 发送至Loki的日志内容,默认为loggie event的body | + +Loki的日志数据结构大概分为label和主体数据,loggie会默认将header里的元信息字段,转成以下划线`_`连接的label。 \ No newline at end of file diff --git a/docs/reference/pipelines/sink/overview.md b/docs/reference/pipelines/sink/overview.md index f8d49c4..3394dcf 100644 --- a/docs/reference/pipelines/sink/overview.md +++ b/docs/reference/pipelines/sink/overview.md @@ -34,3 +34,16 @@ | ---------- | ----------- | ----------- | --------- | -------- | | codec.pretty | | 非必填 | false | 是否进行json格式美化 | | codec.beatsFormat | | 非必填 | false | 日志转成类filebeats格式:增加`@timestamp`字段,同时body字段命名为`message` | + +#### type: raw + +用于发送采集的原始body数据。 + +!!! example + + ```yaml + sink: + type: dev + codec: + type: raw + ``` \ No newline at end of file diff --git a/docs/reference/pipelines/source/file.md b/docs/reference/pipelines/source/file.md index 07c8c67..0e1d2e2 100644 --- a/docs/reference/pipelines/source/file.md +++ b/docs/reference/pipelines/source/file.md @@ -34,7 +34,6 @@ file source用于日志采集。 - /tmp/loggie/**/access.log{,.[2-9][0-9][0-9][0-9]-[01][0-9]-[0123][0-9]} ``` -### ## excludeFiles @@ -54,6 +53,30 @@ file source用于日志采集。 | ------------- | ------ | ---------- | -------- | -------------------------------- | | ignoreSymlink | bool | 非必填 | false | 是否忽略符号链接(软链接)的文件 | + +## addonMeta + +| `字段` | `类型` | `是否必填` | `默认值` | `含义` | +| ------------- | ------ | ---------- | -------- | -------------------------------- | +| addonMeta | bool | 非必填 | false | 是否添加默认的日志采集state元信息 | + +!!! example "event示例" + + ```json + { + "body": "this is test", + "state": { + "pipeline": "local", + "source": "demo", + "filename": "/var/log/a.log", + "timestamp": "2006-01-02T15:04:05.000Z", + "offset": 1024, + "bytes": 4096, + "hostname": "node-1" + } + } + ``` + ## workerCount | `字段` | `类型` | `是否必填` | `默认值` | `含义` | diff --git a/docs/reference/pipelines/source/kube-event.md b/docs/reference/pipelines/source/kube-event.md index 60ef1b8..929170c 100644 --- a/docs/reference/pipelines/source/kube-event.md +++ b/docs/reference/pipelines/source/kube-event.md @@ -29,4 +29,18 @@ | `字段` | `类型` | `是否必填` | `默认值` | `含义` | | ---------- | ----------- | ----------- | --------- | -------- | -| bufferSize | int | 非必填 | 1000 | 监听的队列大小,最小为1 | \ No newline at end of file +| bufferSize | int | 非必填 | 1000 | 监听的队列大小,最小为1 | + +## watchLatestEvents + +| `字段` | `类型` | `是否必填` | `默认值` | `含义` | +| ---------- | ----------- | ----------- | --------- | -------- | +| watchLatestEvents | bool | 非必填 | false | 是否只监听最新的events | + +由于Loggie重启后会重新list所有的events,会导致重复发送,如果不希望重复发送,可以设置为true,当然可能导致重启时间段内新产生的events丢失。 + +## blackListNamespaces + +| `字段` | `类型` | `是否必填` | `默认值` | `含义` | +| ---------- | ----------- | ----------- | --------- | -------- | +| blackListNamespaces | string数组 | 非必填 | | 不接收其中定义的namespaces中产生的events | \ No newline at end of file diff --git a/nav.yml b/nav.yml index 5d8af41..25f17a0 100644 --- a/nav.yml +++ b/nav.yml @@ -66,6 +66,7 @@ nav: - Overview: reference/pipelines/sink/overview.md - elasticsearch: reference/pipelines/sink/elasticsearch.md - kafka: reference/pipelines/sink/kafka.md + - loki: reference/pipelines/sink/loki.md - grpc: reference/pipelines/sink/grpc.md - file: reference/pipelines/sink/file.md - dev: reference/pipelines/sink/dev.md