Skip to content

Commit

Permalink
Fix: Add flusher_stdout Tags parameter in document examples (#1394)
Browse files Browse the repository at this point in the history
* docs: adjust the order of access_key_id and access_key

* docs: enhance __tags__ in flusher_stdout use cases, resolves #1387
  • Loading branch information
crclz authored Mar 10, 2024
1 parent eceb020 commit 3af62f2
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/cn/getting-started/k8slog-collect-to-sls.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ metadata:
namespace: ilogtail
type: Opaque
data:
access_key: <base64_access_key_secret>
access_key_id: <base64_access_key_id>
access_key: <base64_access_key_secret>
```
获取阿里云AK,进行base64。
Expand Down
2 changes: 1 addition & 1 deletion docs/cn/installation/start-with-k8s.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@
namespace: ilogtail
type: Opaque
data:
access_key: # base64 accesskey secret if you want to flush to SLS
access_key_id: # base64 accesskey id if you want to flush to SLS
access_key: # base64 accesskey secret if you want to flush to SLS
```

您也可以直接从下面的地址下载示例配置。
Expand Down
3 changes: 2 additions & 1 deletion docs/cn/plugins/flusher/flusher-stdout.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
| MaxSize | Int || 打印到文件时,需指定单个文件大小。默认1M。 |
| MaxRolls | Int || 打印到文件时,需指定文件的轮转个数。默认为1。 |
| KeyValuePairs | Boolean || |
| Tags | Boolean || |
| Tags | Boolean || 打印 `__tag__`,默认false。如果将flusher-stdout用于调试,建议设置为true。 |

## 样例

Expand All @@ -39,4 +39,5 @@ inputs:
flushers:
- Type: flusher_stdout
OnlyStdout: true
Tags: true
```
15 changes: 13 additions & 2 deletions docs/cn/plugins/input/input-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
| Multiline | object ||| 多行聚合选项。详见表1。 |
| EnableContainerDiscovery | bool || false | 是否启用容器发现功能。仅当Logtail以Daemonset模式运行,且采集文件路径为容器内路径时有效。 |
| ContainerFilters | object ||| 容器过滤选项。多个选项之间为“且”的关系,仅当EnableContainerDiscovery取值为true时有效,详见表2。 |
| ExternalK8sLabelTag | map ||| 对于部署于K8s环境的容器,需要在日志中额外添加的与Pod标签相关的tag。map中的key为Pod标签名,value为对应的tag名。 例如:在map中添加`app: k8s\_label\_app`,则若pod中包含`app=serviceA`的标签时,会将该信息以tag的形式添加到日志中,即添加字段\_\_tag\_\_:k8s\_label\_app: serviceA;若不包含`app`标签,则会添加空字段\_\_tag\_\_:k8s\_label\_app: |
| ExternalEnvTag | map ||| 对于部署于K8s环境的容器,需要在日志中额外添加的与容器环境变量相关的tag。map中的key为环境变量名,value为对应的tag名。 例如:在map中添加`VERSION: env\_version`,则当容器中包含环境变量`VERSION=v1.0.0`时,会将该信息以tag的形式添加到日志中,即添加字段\_\_tag\_\_:env\_version: v1.0.0;若不包含`VERSION`环境变量,则会添加空字段\_\_tag\_\_:env\_version: |
| ExternalK8sLabelTag | map ||| 对于部署于K8s环境的容器,需要在日志中额外添加的与Pod标签相关的tag。map中的key为Pod标签名,value为对应的tag名。 例如:在map中添加`app: k8s_label_app`,则若pod中包含`app=serviceA`的标签时,会将该信息以tag的形式添加到日志中,即添加字段\_\_tag\_\_:k8s\_label\_app: serviceA;若不包含`app`标签,则会添加空字段\_\_tag\_\_:k8s\_label\_app: |
| ExternalEnvTag | map ||| 对于部署于K8s环境的容器,需要在日志中额外添加的与容器环境变量相关的tag。map中的key为环境变量名,value为对应的tag名。 例如:在map中添加`VERSION: env_version`,则当容器中包含环境变量`VERSION=v1.0.0`时,会将该信息以tag的形式添加到日志中,即添加字段\_\_tag\_\_:env\_version: v1.0.0;若不包含`VERSION`环境变量,则会添加空字段\_\_tag\_\_:env\_version: |
| AppendingLogPositionMeta | bool || false | 是否在日志中添加该条日志所属文件的元信息,包括\_\_tag\_\_:\_\_inode\_\_字段和\_\_file\_offset\_\_字段。 |
| FlushTimeoutSecs | uint || 5 | 当文件超过指定时间未出现新的完整日志时,将当前读取缓存中的内容作为一条日志输出。 |
| AllowingIncludedByMultiConfigs | bool || false | 是否允许当前配置采集其它配置已匹配的文件。 |
Expand Down Expand Up @@ -76,6 +76,7 @@ inputs:
flushers:
- Type: flusher_stdout
OnlyStdout: true
Tags: true
```
* 输出
Expand All @@ -88,6 +89,12 @@ flushers:
}
```

注意:`__tag__` 字段的输出会由于ilogtail版本的不同而存在差别。为了在标准输出中能够准确地观察到 `__tag__`,建议仔细检查以下几点:
- flusher_stdout 的配置中,设置了 `Tags: true`
- 如果使用了较新版本的ilogtail,在观察标准输出时,`__tag__`可能会被拆分为一行单独的信息,先于日志的内容输出(这与文档中的示例输出会有差别),请注意不要观察遗漏。

此注意事项适用于后文所有观察 `__tag__` 字段输出的地方。

### 采集指定目录下的所有文件

采集`/home/test-log`路径下的所有文件名匹配`*.log`规则的文件(含递归),并将结果输出至stdout。
Expand All @@ -104,6 +111,7 @@ inputs:
flushers:
- Type: flusher_stdout
OnlyStdout: true
Tags: true
```
### 采集K8s容器文件(仅限iLogtail以Daemonset的方式部署)
Expand All @@ -129,6 +137,7 @@ inputs:
flushers:
- Type: flusher_stdout
OnlyStdout: true
Tags: true
```

### 采集简单多行日志
Expand Down Expand Up @@ -164,6 +173,7 @@ processors:
flushers:
- Type: flusher_stdout
OnlyStdout: true
Tags: true
```

* 输出
Expand Down Expand Up @@ -217,6 +227,7 @@ processors:
flushers:
- Type: flusher_stdout
OnlyStdout: true
Tags: true
```

* 输出
Expand Down
2 changes: 1 addition & 1 deletion k8s_templates/ilogtail-daemonset-file-to-sls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ metadata:
namespace: ilogtail
type: Opaque
data:
access_key: <base64_access_key_secret>
access_key_id: <base64_access_key_id>
access_key: <base64_access_key_secret>
---
apiVersion: apps/v1
kind: DaemonSet
Expand Down
2 changes: 1 addition & 1 deletion k8s_templates/ilogtail-daemonset-stdout-to-sls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ metadata:
namespace: ilogtail
type: Opaque
data:
access_key: <base64_access_key_secret>
access_key_id: <base64_access_key_id>
access_key: <base64_access_key_secret>
---
apiVersion: apps/v1
kind: DaemonSet
Expand Down
2 changes: 1 addition & 1 deletion k8s_templates/ilogtail-sidecar-file-to-sls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ metadata:
namespace: default
type: Opaque
data:
access_key: <base64_access_key_secret>
access_key_id: <base64_access_key_id>
access_key: <base64_access_key_secret>
---
apiVersion: batch/v1
kind: Job
Expand Down

0 comments on commit 3af62f2

Please sign in to comment.