跳转到主要内容
MoleSignal 支持一系列即插即用接入协议,因此大多数现有 agent 与 SDK 无需改动即可工作。除推送型 connector(用 connector token)外,每个接入端点都需 Authorization: Bearer <jwt> 认证(或使用 API token,见 安全)。

支持的协议

协议端点直接替代
OTLP gRPC:5082OpenTelemetry SDK / Collector
OTLP HTTPPOST /api/v1/{logs,metrics,traces}OTel HTTP exporter
Prometheus remote_writePOST /api/v1/prometheus/api/v1/writePrometheus / VictoriaMetrics
Elasticsearch _bulkPOST /api/v1/_bulkFilebeat、Vector ES sink、Logstash
Loki pushPOST /api/v1/loki/api/v1/pushPromtail、Vector Loki sink
Syslog UDP/TCP[syslog] udp/tcp bindrsyslog、syslog-ng
Kinesis FirehosePOST /api/v1/_kinesis_firehoseAWS Firehose
Cloudflare LogpushPOST /api/v1/_cloudflareCloudflare Logpush
Heroku log drainPOST /api/v1/_herokuHeroku
原生 HTTP JSONPOST /api/v1/ingest/{type}/:streamcurl / 应用 SDK
Syslog 无鉴权、无 org 上下文,因此通过 [syslog] 配置绑定到单一 org 与 stream (udp_bind / tcp_bind / org / stream);解析 RFC3164 与 RFC5424(PRI → facility/severity、 hostname、app、message)。Kinesis Firehose、Cloudflare Logpush、Heroku log drain 按源单独配置——见 Connector 指南。

Syslog

Syslog 带不了 Bearer token,因此不是按请求鉴权,而是在配置里固定到一个组织与 stream。启用监听器 并绑定到 org 的 slug
[syslog]
udp_bind = "0.0.0.0:5514"   # 和/或 tcp_bind(按换行分帧)
org      = "acme"           # 目标 org slug —— 必填
stream   = "syslog"         # 目标 stream
每行先解析 <PRI> 优先级(解码为 facility / severity),再按 RFC5424(1 …)或 RFC3164 提取 hostnameapp_namemessage。把任意标准 daemon 指向它即可——例如 rsyslog: *.* @ms-host:5514(UDP)或 @@ms-host:5514(TCP)。

原生 HTTP JSON

最简单的方式。把一个记录数组 POST 到 ingest/{logs,metrics,traces}/{stream}。时间戳为 Unix 纪元起 的微秒数,放在 _timestamp 字段。
curl -X POST http://localhost:5080/api/v1/ingest/logs/app \
  -H "authorization: Bearer $MS_JWT" \
  -H 'content-type: application/json' \
  -d '[{"_timestamp":1700000000000000,"level":"error","msg":"db pool exhausted","trace_id":"abc123"}]'
流在首次写入时创建,schema 随新字段出现自动演进。

OpenTelemetry

把 OTel HTTP exporter 指向 MoleSignal:
exporters:
  otlphttp:
    endpoint: http://localhost:5080/api/v1
    headers:
      authorization: "Bearer ${MS_JWT}"
日志、指标、追踪分别 POST 到 /api/v1/logs/api/v1/metrics/api/v1/traces

Prometheus remote_write

prometheus.yml 中把 MoleSignal 加为远程写入目标:
remote_write:
  - url: http://localhost:5080/api/v1/prometheus/api/v1/write
    authorization:
      credentials: "${MS_JWT}"

Loki 与 Elasticsearch

POST /api/v1/loki/api/v1/push
# 适配 Promtail 与 Vector Loki sink。

管道函数(Pipeline functions)

你可以在接入热路径上用管道函数转换事件 —— 它是挂在管道步骤上的可复用变换。支持两种语言:
  • VRL —— 始终可用。按 (function_id, updated_at) 编译,使用 vrl::compiler 标准库 (delparse_jsonto_intmatchencrypt/decrypt 等)。
  • JavaScript —— 可选,基于 deno_core(V8)。默认关闭;启用需同时具备构建特性 (--features molesignal-bootstrap/js-runtime)与 TOML 开关 [functions] js_runtime_enabled = true
JS isolate 刻意做得极简:没有 fetchsetTimeoutimportnpm。每个事件有 50 ms 墙钟预算与 32 MiB 堆。任何超出单次同步执行的逻辑在设计上都不支持。
// 把 `severity` 字段小写化,写入新的 `level` 字段。
molesignal.set("level", molesignal.fields.severity.toLowerCase());
// 删除一个敏感字段。
molesignal.del("pw");