Skip to content

Commit e0e61e7

Browse files
committed
docs: update prometheus and vector docs
1 parent 76b43c4 commit e0e61e7

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

docs/zh/08-integration/02-input/04-log/02-vector.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,30 @@ curl -XPOST "http://${deepflow_server_node_ip}:${port}/v1/query/" \
415415
--data-urlencode "sql=select attribute.cluster, body from log where attribute.cluster='Production'"
416416
```
417417

418+
### 基于日志构建指标序列
419+
420+
如果应用里带了一些运行时指标信息,比如 `nginx` 记录了请求时延,同样地,也可以使用 Transforms 的 Remap 模块,写一段注入指标的代码,其中,我们要求自定义标签必须写入 `.metrics` 结构体内,才能被存储、查询,示例如下:
421+
422+
```yaml
423+
transforms:
424+
inject_json_tags:
425+
type: remap
426+
inputs:
427+
- remap_kubernetes_logs
428+
source: |-
429+
.metrics = {
430+
"response_duration": xxx, # FIXME: 把从日志中提取到的指定数据添加到此处
431+
}
432+
```
433+
434+
然后,在使用 [SQL API](../../output/query/sql) 查询时,我们可以使用如下语句搜索指定的指标,同样,指标也支持此文档中的 [聚合算子](../../../features/universal-map/metrics-and-operators):
435+
436+
```bash
437+
curl -XPOST "http://${deepflow_server_node_ip}:${port}/v1/query/" \
438+
--data-urlencode "db=application_log" \
439+
--data-urlencode "sql=select metrics.response_duration from log"
440+
```
441+
418442
### 提取分布式追踪 ID
419443

420444
如果应用具有分布式追踪能力,无论是做了 [OTel](https://opentelemetry.io/docs/concepts/instrumentation/) 插桩或者应用中天然存在具有唯一性的全局流水号,且输出到日志中,同样可以上报到后端,把分布式追踪请求链路与日志关联起来。例如:将日志中的 `TID:xxx` 提取为 trace_id 的示例如下:
@@ -476,6 +500,9 @@ transforms:
476500
"cluster": "Production",
477501
"module": "nginx"
478502
}
503+
.metrics = {
504+
"ready_status": 1,
505+
}
479506
sinks:
480507
http:
481508
encoding:

docs/zh/08-integration/03-output/01-query/02-promql.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ DeepFlow 的指标对外提供 PromQL 查询时,指标名称遵循 `${database
7676
基于 PromQL 直接查询或编写告警规则时,目前已知的限制如下:
7777

7878
- 无法通过`~/!~`正则搜索 metrics 名称
79-
- 对 DeepFlow 提供的指标,必须先通过 [appregation operator](https://prometheus.io/docs/prometheus/latest/querying/operators/#aggregation-operators) 确定聚合求值方式,再进行具体的指标查询。其中,`stdvar``topk``bottomk``quantile` 这几个函数尚未支持,将会在后续的迭代中继续支持。
79+
- 对 DeepFlow 提供的指标,必须先通过 [appregation operator](https://prometheus.io/docs/prometheus/latest/querying/operators/#aggregation-operators) 确定聚合求值方式,再进行具体的指标查询。其中,`stdvar``quantile` 这几个函数尚未支持,将会在后续的迭代中继续支持。
8080

8181
# 基于 PromQL 查询 DeepFlow 指标
8282

0 commit comments

Comments
 (0)