Log Streaming¶
启动一个 HTTP Server,接收日志文本数据,上报到观测云。HTTP URL 固定为:/v1/write/logstreaming
,即 http://Datakit_IP:PORT/v1/write/logstreaming
注:如果 DataKit 以 DaemonSet 方式部署在 Kubernetes 中,可以使用 Service 方式访问,地址为
http://datakit-service.datakit:9529
配置¶
进入 DataKit 安装目录下的 conf.d/log
目录,复制 logstreaming.conf.sample
并命名为 logstreaming.conf
。示例如下:
[inputs.logstreaming]
ignore_url_tags = true
## Threads config controls how many goroutines an agent cloud start to handle HTTP request.
## buffer is the size of jobs' buffering of worker channel.
## threads is the total number fo goroutines at running time.
# [inputs.logstreaming.threads]
# buffer = 100
# threads = 8
## Storage config a local storage space in hard dirver to cache trace data.
## path is the local file path used to cache data.
## capacity is total space size(MB) used to store data.
# [inputs.logstreaming.storage]
# path = "./log_storage"
# capacity = 5120
配置好后,重启 DataKit 即可。
目前可以通过 ConfigMap 方式注入采集器配置来开启采集器。
支持参数¶
Log-Streaming 支持在 HTTP URL 中添加参数,对日志数据进行操作。参数列表如下:
type
:数据格式,目前只支持influxdb
。- 当
type
为inflxudb
时(/v1/write/logstreaming?type=influxdb
),说明数据本身就是行协议格式(默认 precision 是s
),将只添加内置 Tags,不再做其他操作 - 当此值为空时,会对数据做分行和 Pipeline 等处理
- 当
source
:标识数据来源,即行协议的 measurement。例如nginx
或者redis
(/v1/write/logstreaming?source=nginx
)- 当
type
是influxdb
时,此值无效 - 默认为
default
- 当
service
:添加 service 标签字段,例如(/v1/write/logstreaming?service=nginx_service
)- 默认为
source
参数值。
- 默认为
pipeline
:指定数据需要使用的 pipeline 名称,例如nginx.p
(/v1/write/logstreaming?pipeline=nginx.p
)tags
:添加自定义 tag,以英文逗号,
分割,例如key1=value1
和key2=value2
(/v1/write/logstreaming?tags=key1=value1,key2=value2
)
使用方式¶
- Fluentd 使用 Influxdb Output 文档
- Fluentd 使用 HTTP Output 文档
- Logstash 使用 Influxdb Output 文档
- Logstash 使用 HTTP Output 文档
只需要将 Output Host 配置为 Log-Streaming URL(http://Datakit_IP:PORT/v1/write/logstreaming
)并添加对应参数即可。
日志¶
default
¶
Using source
field in the config file, default is default
.
- 标签
Tag | Description |
---|---|
ip_or_hostname |
Request IP or hostname. |
service |
Service name. Using the service parameter in the URL. |
- 指标列表
Metric | Description | Type | Unit |
---|---|---|---|
message |
Message text, existed when default. Could use Pipeline to delete this field. | string | - |
status |
Log status. | string | - |