使用 Pipeline 写入日志
本文档介绍如何通过 HTTP 接口使用指定的 Pipeline 进行处理后将日志写入 GreptimeDB。
在写入日志之前,请先阅读 Pipeline 配置和管理 Pipeline 完成配置的设定和上传。
HTTP API
您可以使用以下命令通过 HTTP 接口写入日志:
curl -X "POST" "http://localhost:4000/v1/ingest?db=<db-name>&table=<table-name>&pipeline_name=<pipeline-name>&version=<pipeline-version>" \
-H "Content-Type: application/x-ndjson" \
-H "Authorization: Basic {{authentication}}" \
-d "$<log-items>"
请求参数
此接口接受以下参数:
db:数据库名称。table:表名称。pipeline_name:Pipeline 名称。version:Pipeline 版本号。可选,默认使用最新版本。
Content-Type 和 Body 数据格式
GreptimeDB 使用 Content-Type header 来决定如何解码请求体内容。目前我们支持以下两种格式:
application/json: 包括普通的 JSON 格式和 NDJSON 格式。application/x-ndjson: 指定 NDJSON 格式,会尝试先分割行再进行解析,可以达到精确的错误检查。text/plain: 通过换行符分割的多行日志文本行。