托管 Prometheus 服务支持监控云服务器(ECS)实例,获取云服务器的指标信息。本文为您介绍如何配置云服务器(ECS)实例监控。
为了保证您能够使用部署在 VKE 集群中的采集器,正确采集到相同 VPC 内的其他 ECS 的监控数据,您需要首先检查 VPC 安全组的配置。步骤如下:



wget https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz && tar -xvf node_exporter-1.5.0.linux-amd64.tar.gz

说明
如果您无法在 ECS 云服务器中下载 exporter,可以尝试在本地主机中下载并上传至 ECS 云服务器。详情请参见 本地 Linux 或 macOS 系统通过 SCP 上传文件到 Linux 云服务器。
nohup ./node_exporter &
curl http://127.0.0.1:9100/metrics
说明
curl http://ecs-ip:9100/metrics),检查连接是否通畅,避免由于被安全组限制,导致无法正确抓取到指标数据。如果 node-exporter 工作正常,预期能够获得以下返回结果。
# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles. # TYPE go_gc_duration_seconds summary go_gc_duration_seconds{quantile="0"} 0 go_gc_duration_seconds{quantile="0.25"} 0 go_gc_duration_seconds{quantile="0.5"} 0 go_gc_duration_seconds{quantile="0.75"} 0 go_gc_duration_seconds{quantile="1"} 0 go_gc_duration_seconds_sum 0 go_gc_duration_seconds_count 0 # HELP go_goroutines Number of goroutines that currently exist. # TYPE go_goroutines gauge go_goroutines 7 # HELP go_info Information about the Go environment. # TYPE go_info gauge go_info{version="go1.19.3"} 1 # HELP go_memstats_alloc_bytes Number of bytes allocated and still in use. # TYPE go_memstats_alloc_bytes gauge go_memstats_alloc_bytes 2.626832e+06 # HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed. # TYPE go_memstats_alloc_bytes_total counter go_memstats_alloc_bytes_total 2.626832e+06 # HELP go_memstats_buck_hash_sys_bytes Number of bytes used by the profiling bucket hash table. # TYPE go_memstats_buck_hash_sys_bytes gauge go_memstats_buck_hash_sys_bytes 1.447059e+06 # HELP go_memstats_frees_total Total number of frees. # TYPE go_memstats_frees_total counter go_memstats_frees_total 2055 ......
apiVersion: operator.victoriametrics.com/v1beta1 kind: VMStaticScrape metadata: name: ecs # 配置服务发现规则的名称 namespace: default # 配置服务发现所在的命名空间,指定存在的任意命名空间即可 labels: volcengine.vmp: "true" # 配置服务发现规则的标签,允许被 Prometheus-agent 发现 spec: jobName: "ecs" targetEndpoints: - targets: ["192.168.1.9:9100"] # 指定 ECS 云服务器的私网 IP 地址和端口号 path: "metrics" # 填写指标暴露的 URI 路径,不填默认为 /metrics
说明
更多服务发现配置的相关说明,请参见 官方文档。
您可以使用托管 Prometheus 服务的 Explore 功能来查看监控指标数据。详情请参见 指标查询。
如果托管 Prometheus 接入了自建的 Grafana,也可以通过 Grafana 查看监控数据。详情请参见 在容器服务集群中部署 Grafana 并接入工作区。


您可以在云服务器实例的控制台中,执行以下命令,检查接口是否被占用。
ss -naltp | grep 9100
返回如下信息时,表示 9100 端口已经被占用。
LISTEN 0 128 [::]:9100 [::]:* users:(("node_exporter",pid=1654,fd=3))
node-exporter 缺省使用 9100 端口对外暴露指标,当云服务器中的 9100 端口被占用时,您可以在启动 node-exporter 时,通过--web.listen-address参数,修改 node-exporter 的指标暴露端口。例如修改为 9200 端口。
nohup ./node_exporter --web.listen-address=":9200"&