> ## Documentation Index
> Fetch the complete documentation index at: https://docs.molesignal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 快速开始

> 几分钟内启动 MoleSignal、写入日志事件并完成查询。

本指南将在本地启动 MoleSignal，通过认证后的 HTTP API 写入一条日志事件并完成查询。

## 前置条件

* **Docker** 与 **Docker Compose**（沙箱会拉起 Postgres + MinIO + MoleSignal）。
* standalone profile 大约需要 2 GB 空闲内存。

## 启动沙箱

<Steps>
  <Step title="克隆并启动">
    ```bash theme={null}
    git clone https://github.com/molesignal/molesignal
    cd molesignal

    # 一条命令的沙箱：Postgres + MinIO + MoleSignal standalone
    docker compose -f deploy/docker/docker-compose.yaml --profile standalone up
    ```

    启动后：

    * **UI：** [http://localhost:5080](http://localhost:5080)
    * **S3 控制台（MinIO）：** [http://localhost:9001](http://localhost:9001) —— `minioadmin` / `minioadmin`
  </Step>

  <Step title="登录拿 token">
    认证以获取 JWT 和对应的 `org_id`：

    ```bash theme={null}
    curl -X POST http://localhost:5080/api/v1/auth/signin \
      -H 'content-type: application/json' \
      -d '{"email":"admin@example.com","password":"admin"}'
    ```

    响应中包含 JWT 与 `org_id`。导出两个值供后续步骤使用：

    ```bash theme={null}
    export MS_JWT="<响应里的 jwt>"
    export MS_ORG="<响应里的 org_id>"
    ```
  </Step>

  <Step title="发送第一条数据">
    原生 HTTP JSON 接入开箱即用，适配 `curl`、应用 SDK、Vector、Fluent Bit。时间戳为 Unix 纪元起
    的微秒数，放在 `_timestamp` 字段。

    ```bash theme={null}
    curl -X POST http://localhost:5080/api/v1/intake/logs/app \
      -H "authorization: Bearer $MS_JWT" \
      -H 'content-type: application/json' \
      -d '[{"_timestamp":1700000000000000,"level":"error","msg":"db pool exhausted","trace_id":"abc123"}]'
    ```
  </Step>

  <Step title="查询事件">
    通过 HTTP API 查询 `app` 日志流：

    ```bash theme={null}
    curl -X POST http://localhost:5080/api/v1/query \
      -H "authorization: Bearer $MS_JWT" \
      -H 'content-type: application/json' \
      -d "{\"org_id\":\"$MS_ORG\",\"language\":\"sql\",
           \"statement\":\"SELECT * FROM app WHERE trace_id = 'abc123'\",
           \"time_range\":{\"start\":0,\"end\":2000000000000000},
           \"stream\":{\"name\":\"app\",\"stream_type\":\"logs\"}}"
    ```

    结果包含 `columns`、`rows`、`scanned_rows` 和 `took_ms`。
  </Step>
</Steps>

## 下一步

<CardGroup cols={2}>
  <Card title="从现有技术栈接入" icon="inbox" href="/zh-Hans/intake">
    接入 OpenTelemetry、Prometheus、Loki JSON 发送端、Filebeat 与云数据源。
  </Card>

  <Card title="跨信号关联" icon="link" href="/zh-Hans/correlation">
    用共享上下文关联日志、指标、链路、性能剖析和 RUM。
  </Card>

  <Card title="正式部署" icon="server" href="/zh-Hans/deployment">
    从沙箱走向多角色或 Kubernetes 部署。
  </Card>

  <Card title="配置" icon="gear" href="/zh-Hans/configuration">
    TOML 配置与 `MS_*` 环境变量覆盖。
  </Card>
</CardGroup>
