Pushgateway(1)docker安装Pushgateway及在Prometheus中配置Pushgateway对应的job

也可以使用压缩包安装,但是压缩包安装实在是有点麻烦,这里便不使用压缩包安装了

第一步:查看是否安装docker

[root@localhost ~]# docker version
Client:
 Version:         1.13.1
 API version:     1.26
 Package version: 
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

如果没有安装,可以查看这篇博客进行安装docker

第二步:启动docker

[root@localhost ~]# sudo systemctl start docker

第三步:安装Pushgateway

[root@localhost ~]# docker pull prom/pushgateway
Using default tag: latest
Trying to pull repository docker.io/prom/pushgateway ... 
latest: Pulling from docker.io/prom/pushgateway
aa2a8d90b84c: Pull complete 
b45d31ee2d7f: Pull complete 
2228cb35c444: Pull complete 
b896befe0244: Pull complete 
Digest: sha256:a684e7c830a4b19e564a93bfc3bf713e85b04ab9dfcab5633c14cbba241f9231
Status: Downloaded newer image for docker.io/prom/pushgateway:latest
[root@localhost ~]#

第四步:启动Pushgateway

[root@localhost ~]# docker run -d \
>   --name=pg \
>   -p 9091:9091 \
>   prom/pushgateway
796d7c215ae831016b8beacdb674e56d59736595f0d2fa4c5f2631b43e5c4c2b
[root@localhost ~]# 

第五步:访问url(Pushgateway)

在这里插入图片描述
查看metrics数据
在这里插入图片描述


第六步:在prometheus中配置对应的job

要使Push Gateway正常工作,就需要配置对应的job在Prometheus里面

[root@localhost prometheus-2.6.1.linux-amd64]# vim prometheus.yml 
  - static_configs:
    - targets:
       - 192.168.156.134:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"
  - "/opt/prometheus/prometheus-2.6.1.linux-amd64/rules/*.rules"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:9090']
  - job_name: 'agent1'
    static_configs:
    - targets: ['192.168.156.134:9100']
  - job_name: pushgateway
    static_configs:
      - targets: ['192.168.156.134:9091']
        labels:
          instance: pushgateway
"prometheus.yml" 37L, 1212C 宸插啓鍏[?1l                                              
[root@localhost prometheus-2.6.1.linux-amd64]#

第七步:重启Prometheus

[root@localhost prometheus-2.6.1.linux-amd64]# pkill prometheus
[root@localhost prometheus-2.6.1.linux-amd64]# level=warn ts=2022-02-10T09:00:41.205762698Z caller=main.go:405 msg="Received SIGTERM, exiting gracefully..."
level=info ts=2022-02-10T09:00:41.205814019Z caller=main.go:430 msg="Stopping scrape discovery manager..."
level=info ts=2022-02-10T09:00:41.205820974Z caller=main.go:444 msg="Stopping notify discovery manager..."
level=info ts=2022-02-10T09:00:41.205825681Z caller=main.go:466 msg="Stopping scrape manager..."
level=info ts=2022-02-10T09:00:41.205870076Z caller=main.go:426 msg="Scrape discovery manager stopped"
level=info ts=2022-02-10T09:00:41.205883045Z caller=main.go:440 msg="Notify discovery manager stopped"
level=info ts=2022-02-10T09:00:41.20589595Z caller=manager.go:664 component="rule manager" msg="Stopping rule manager..."
level=info ts=2022-02-10T09:00:41.205904859Z caller=manager.go:670 component="rule manager" msg="Rule manager stopped"
level=info ts=2022-02-10T09:00:41.206058181Z caller=main.go:460 msg="Scrape manager stopped"
level=info ts=2022-02-10T09:00:41.207038976Z caller=notifier.go:521 component=notifier msg="Stopping notification manager..."
level=info ts=2022-02-10T09:00:41.207069697Z caller=main.go:615 msg="Notifier manager stopped"
level=info ts=2022-02-10T09:00:41.207195903Z caller=main.go:627 msg="See you next time!"

[1]+  瀹屾垚                  ./prometheus --config.file=prometheus.yml
[root@localhost prometheus-2.6.1.linux-amd64]# lsof -i:9090
[root@localhost prometheus-2.6.1.linux-amd64]# ./prometheus --config.file=prometheus.yml & 


第八步:查看job是否启动

在这里插入图片描述

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
一、prometheus简介 Prometheus是一个开源的系统监控和告警系统,现在已经加入到CNCF基金会,成为继k8s之后第二个在CNCF维护管理的项目,在kubernetes容器管理系统,通常会搭配prometheus进行监控,prometheus支持多种exporter采集数据,还支持通过pushgateway进行数据上报,Prometheus再性能上可支撑上万台规模的集群。 二、prometheus架构图 三、prometheus组件介绍 1.Prometheus Server: 用于收集和存储时间序列数据。 2.Client Library: 客户端库,检测应用程序代码,当Prometheus抓取实例的HTTP端点时,客户端库会将所有跟踪的metrics指标的当前状态发送到prometheus server端。 3.Exporters: prometheus支持多种exporter,通过exporter可以采集metrics数据,然后发送到prometheus server端 4.Alertmanager: 从 Prometheus server 端接收到 alerts 后,会进行去重,分组,并路由到相应的接收方,发出报警,常见的接收方式有:电子邮件,微信,钉钉, slack等。 5.Grafana:监控仪表盘 6.pushgateway: 各个目标主机可上报数据到pushgatewy,然后prometheus server统一从pushgateway拉取数据。 四、课程亮点 五、效果图展示 六、讲师简介 先超(lucky):高级运维工程师、资深DevOps工程师,在互联网上市公司拥有多年一线运维经验,主导过亿级pv项目的架构设计和运维工作 主要研究方向: 1.云计算方向:容器 (kubernetes、docker),虚拟化(kvm、Vmware vSphere),微服务(istio),PaaS(openshift),IaaS(openstack)等2.系统/运维方向:linux系统下的常用组件(nginx,tomcat,elasticsearch,zookeeper,kafka等),DevOps(Jenkins+gitlab+sonarqube+nexus+k8s),CI/CD,监控(zabbix、prometheus、falcon)等 七、课程大纲

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

?abc!

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值