prometheus+grafana+process-exporter自定义监控linux进程

Prometheus是一套开源的监控&报警&时间序列数据库的组合,Prometheus监控服务器的基础资源,也可以监控消息中间件、日志监控,当然也可以监控某个进程(应用程序)或某几个进程(进程组)。

本文主要通过process-exporter 对进程进行监控,并介绍Process-exporter的使用说明。

Prometheus+Grafana的安装参考: https://blog.csdn.net/skh2015java/article/details/102572363
process-exporter地址: https://github.com/ncabatoff/process-exporter/releases/tag/v0.5.0

process-exporter可以使用命令行参数也可以指定配置文件启动

 命令行常用的参数:

Usage of process-exporter:
  -children
        if a proc is tracked, track with it any children that aren't part of their own group (default true)
  -config.path string
        path to YAML config file
  -debug
        log debugging information to stdout
  -man
        print manual
  -namemapping string
        comma-separated list, alternating process name and capturing regex to apply to cmdline
  -once-to-stdout-delay duration
        Don't bind, just wait this much time, print the metrics once to stdout, and exit
  -procfs string
        path to read proc data from (default "/proc")
  -procnames string
        comma-separated list of process names to monitor
  -recheck
        recheck process names on each scrape
  -threads
        report on per-threadname metrics as well (default true)
  -version
        print version information and exit
  -web.listen-address string
        Address on which to expose metrics and web interface. (default ":9256")
  -web.telemetry-path string
        Path under which to expose metrics. (default "/metrics")

新建配置文件,选择要监视的进程并将它的分组,提供命令行参数或者使用YAML配置文件

touch  prometheus.yml

编辑配置文件

process_names:
  - name: "{{.Matches}}"
    cmdline:
    - 'test'

test关键字类似于

ps aux | grep test

指定配置文件后台启动

 nohup ./process-exporter  -config.path process-conf.yaml  &

 process-exporter默认会监听9256端口,使用curl测试是否启动成功

  curl  localhost:9256/metrics |grep test

Prometheus配置文件中添加,并重启

    - job_name: 'process'
        static_configs:
        - targets: ['localhost:9256']

查看是否采集到信息

Grafana图表显示:

process-exporter对应的dashboard为:https://grafana.com/grafana/dashboards/249

Import即可

 

 

 

最终效果图如下:

可以看到可以监控 进程的数量,cpu,读写速率,所占内存。
 

 

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个基于Docker Compose的搭建PrometheusGrafana、Alertmanager、Blackbox Exporter和Node Exporter的示例: ```yaml version: "3" services: prometheus: image: prom/prometheus container_name: prometheus ports: - "9090:9090" volumes: - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml command: - '--config.file=/etc/prometheus/prometheus.yml' - '--web.enable-admin-api' restart: always grafana: image: grafana/grafana container_name: grafana ports: - "3000:3000" volumes: - ./grafana:/var/lib/grafana restart: always alertmanager: image: prom/alertmanager container_name: alertmanager ports: - "9093:9093" volumes: - ./alertmanager/config.yml:/etc/alertmanager/config.yml command: - '--config.file=/etc/alertmanager/config.yml' restart: always blackbox-exporter: image: prom/blackbox-exporter container_name: blackbox-exporter ports: - "9115:9115" volumes: - ./blackbox-exporter/config.yml:/etc/blackbox-exporter/config.yml command: - '--config.file=/etc/blackbox-exporter/config.yml' restart: always node-exporter: image: prom/node-exporter container_name: node-exporter ports: - "9100:9100" restart: always ``` 需要注意的是,这里的配置文件都需要自己创建并且挂载到对应的容器中。例如,prometheus.yml、config.yml和config.yml分别对应Prometheus、Alertmanager和Blackbox Exporter的配置文件。同时,Grafana的数据目录也需要挂载到主机上以便数据持久化。 另外,需要注意的是这只是一个示例,具体的配置文件需要根据实际情况进行修改。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值