Categraf
Categraf 是一个可以采集指标和日志的代理。Categraf 使用 prometheus remote write 作为指标数据推送协议,因此可以将指标推送到夜莺,日志的话,Categraf 是对接写给 Kafka。
配置
Categraf 的配置文件: conf/config.toml
[writer_opt]
batch = 2000
chan_size = 10000
[[writers]] url = "http://N9E:17000/prometheus/v1/write"
basic_auth_user = ""
basic_auth_pass = ""
timeout = 5000 dial_timeout = 2500 max_idle_conns_per_host = 100
[heartbeat] enable = true
url = "http://N9E:17000/v1/n9e/heartbeat"
interval = 10
basic_auth_user = ""
basic_auth_pass = ""
timeout = 5000 dial_timeout = 2500 max_idle_conns_per_host = 100
|
我们建议您使用 Categraf 采集机器的 CPU、内存等常规指标,因为 Categraf 和夜莺的对接最为丝滑。Categraf 会自动采集机器的元信息并且和夜莺对接提供告警自愈能力。
至于 MySQL、Redis、Oracle、ElasticSearch、Kafka 等各类监控对象的数据采集,您也可以使用 Categraf,也可以使用您熟悉的其他采集器。
边缘模式
如果您采用了夜莺的边缘模式,即在某个边缘机房部署了 n9e-edge 组件,那边缘机房的 Categraf 就可以直接将数据推送到边缘机房的 n9e-edge 组件上,不需要推送到中心机房的夜莺。即:Categraf 配置文件中的 writer 和 heartbeat 的两个 url 都改为边缘机房的 n9e-edge 地址即可。
FAQ
1.如何监控多个目标?
比如有多个 MySQL 实例要监控,或者有多个进程要监控,应该如何配置?
Categraf 大部分插件的样例配置里都有一个 [[instances]] 的配置段,但凡有这个配置段的插件,就可以通过增加 [[instances]] 来监控多个目标。Categraf 的配置文件是 toml 格式,双中括号表示数组。比如 MySQL 插件的配置样例:
[[instances]] address = "10.1.2.3:3306" username = "categraf" password = "XXXXXXXX" labels = { instance="n9e-mysql-01" }
[[instances]] address = "10.1.2.4:3306" username = "categraf" password = "XXXXXXXX" labels = { instance="n9e-mysql-02" }
|
再比如进程监控插件 procstat 的配置样例:
[[instances]] search_exec_substring = "mysqld" gather_total = true gather_per_pid = true gather_more_metrics = [ "threads", "fd", "io", "uptime", "cpu", "mem", "limit", ]
[[instances]] search_exec_substring = "n9e-plus" gather_total = true gather_per_pid = true gather_more_metrics = [ "threads", "fd", "io", "uptime", "cpu", "mem", "limit", ]
|