Skip to content

Commit 65c4003

Browse files
committed
update categraf doc
1 parent df03f71 commit 65c4003

2 files changed

Lines changed: 110 additions & 2 deletions

File tree

content/en/docs/agent/categraf.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "Categraf"
33
description: "Use Categraf as collector for Nightingale"
44
lead: ""
55
date: 2022-05-12T13:26:54+01:00
6-
lastmod: 2025-01-26T10:55:54+08:00
6+
lastmod: 2025-08-08T10:32:43.773+08:00
77
draft: false
88
images: []
99
menu:
@@ -65,3 +65,57 @@ max_idle_conns_per_host = 100
6565
```
6666

6767
We highly recommend that you use Categraf as collector for Nightingale.
68+
69+
## FAQ
70+
71+
### 1. How to collect multiple instances?
72+
73+
For example, if there are multiple MySQL instances or multiple processes to monitor, how should the configuration be done?
74+
75+
Most plugin sample configurations in Categraf include a `[[instances]]` configuration section. For any plugin with this section, you can monitor multiple targets by adding more `[[instances]]` sections. Categraf's configuration files are in toml format, where double square brackets indicate an array. Take the configuration sample of the MySQL plugin as an example:
76+
77+
```toml
78+
[[instances]]
79+
address = "10.1.2.3:3306"
80+
username = "categraf"
81+
password = "XXXXXXXX"
82+
labels = { instance="n9e-mysql-01" }
83+
84+
[[instances]]
85+
address = "10.1.2.4:3306"
86+
username = "categraf"
87+
password = "XXXXXXXX"
88+
labels = { instance="n9e-mysql-02" }
89+
```
90+
91+
Another example is the configuration sample of the process monitoring plugin procstat:
92+
93+
```toml
94+
[[instances]]
95+
search_exec_substring = "mysqld"
96+
gather_total = true
97+
gather_per_pid = true
98+
gather_more_metrics = [
99+
"threads",
100+
"fd",
101+
"io",
102+
"uptime",
103+
"cpu",
104+
"mem",
105+
"limit",
106+
]
107+
108+
[[instances]]
109+
search_exec_substring = "n9e-plus"
110+
gather_total = true
111+
gather_per_pid = true
112+
gather_more_metrics = [
113+
"threads",
114+
"fd",
115+
"io",
116+
"uptime",
117+
"cpu",
118+
"mem",
119+
"limit",
120+
]
121+
```

content/zh/docs/agent/categraf.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "Categraf"
33
description: "使用 Categraf 作为夜莺监控的采集器,采集指标、日志等数据,和夜莺项目丝滑对接。Categraf 是一个开源的采集器,支持 Prometheus remote write 协议。通过 Prometheus remote write 协议,Categraf 可以将指标数据推送到夜莺监控。Categraf 还可以采集日志数据,并将其写入 Kafka。"
44
lead: ""
55
date: 2025-01-26T10:55:54+08:00
6-
lastmod: 2025-05-31T17:39:29.974+08:00
6+
lastmod: 2025-08-08T10:32:43.773+08:00
77
draft: false
88
images: []
99
menu:
@@ -71,3 +71,57 @@ max_idle_conns_per_host = 100
7171
## 边缘模式
7272

7373
如果您采用了夜莺的边缘模式,即在某个边缘机房部署了 n9e-edge 组件,那边缘机房的 Categraf 就可以直接将数据推送到边缘机房的 n9e-edge 组件上,不需要推送到中心机房的夜莺。即:Categraf 配置文件中的 writer 和 heartbeat 的两个 url 都改为边缘机房的 n9e-edge 地址即可。
74+
75+
## FAQ
76+
77+
### 1.如何监控多个目标?
78+
79+
比如有多个 MySQL 实例要监控,或者有多个进程要监控,应该如何配置?
80+
81+
Categraf 大部分插件的样例配置里都有一个 `[[instances]]` 的配置段,但凡有这个配置段的插件,就可以通过增加 `[[instances]]` 来监控多个目标。Categraf 的配置文件是 toml 格式,双中括号表示数组。比如 MySQL 插件的配置样例:
82+
83+
```toml
84+
[[instances]]
85+
address = "10.1.2.3:3306"
86+
username = "categraf"
87+
password = "XXXXXXXX"
88+
labels = { instance="n9e-mysql-01" }
89+
90+
[[instances]]
91+
address = "10.1.2.4:3306"
92+
username = "categraf"
93+
password = "XXXXXXXX"
94+
labels = { instance="n9e-mysql-02" }
95+
```
96+
97+
再比如进程监控插件 procstat 的配置样例:
98+
99+
```toml
100+
[[instances]]
101+
search_exec_substring = "mysqld"
102+
gather_total = true
103+
gather_per_pid = true
104+
gather_more_metrics = [
105+
"threads",
106+
"fd",
107+
"io",
108+
"uptime",
109+
"cpu",
110+
"mem",
111+
"limit",
112+
]
113+
114+
[[instances]]
115+
search_exec_substring = "n9e-plus"
116+
gather_total = true
117+
gather_per_pid = true
118+
gather_more_metrics = [
119+
"threads",
120+
"fd",
121+
"io",
122+
"uptime",
123+
"cpu",
124+
"mem",
125+
"limit",
126+
]
127+
```

0 commit comments

Comments
 (0)