快速入门
本指南将引导你完成使用 GreptimeDB 日志服务的基本步骤。
你将学习如何使用内置的 greptime_identity pipeline 写入日志并集成日志收集器。
GreptimeDB 提供了强大的基于 pipeline 的日志写入系统。
你可以使用内置的 greptime_identity pipeline 快速写入 JSON 格式的日志,
该 pipeline 具有以下特点:
- 自动处理从 JSON 到表列的字段映射
- 如果表不存在则自动创建表
- 灵活支持变化的日志结构
- 需要最少的配置即可开始使用
直接通过 HTTP 写入日志
GreptimeDB 日志写入最简单的方法是通过使用 greptime_identity pipeline 发送 HTTP 请求。
例如,你可以使用 curl 发送带有 JSON 日志数据的 POST 请求:
curl -X POST \
"http://localhost:4000/v1/ingest?db=public&table=demo_logs&pipeline_name=greptime_identity" \
-H "Content-Type: application/json" \
-H "Authorization: Basic {{authentication}}" \
-d '[
{
"timestamp": "2024-01-15T10:30:00Z",
"level": "INFO",
"service": "web-server",
"message": "用户登录成功",
"user_id": 12345,
"ip_address": "192.168.1.100"
},
{
"timestamp": "2024-01-15T10:31:00Z",
"level": "ERROR",
"service": "database",
"message": "连接超时",
"error_code": 500,
"retry_count": 3
}
]'