您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
pushgateway搭建并为prometheus增加targets
发布时间:2022-11-14 23:22:04编辑:雪饮阅读()
上集说到了prometheus的搭建,那么接下来我们需要为prometheus新增一个pushgateway的targets
step1
去prometheus官网下与我们系统合适的pushgateway资源包
我这里呢是用这个了
pushgateway-1.4.3.linux-amd64.tar.gz
解压后直接运行即可
[root@localhost pushgateway-1.4.3.linux-amd64]# ./pushgateway
ts=2022-11-14T14:58:14.818Z caller=main.go:85 level=info msg="starting pushgateway" version="(version=1.4.3, branch=HEAD, revision=f9dc1c8664050edbc75916c3664be1df595a1958)"
ts=2022-11-14T14:58:14.818Z caller=main.go:86 level=info build_context="(go=go1.18.2, user=root@75e397dd33fe, date=20220530-19:02:00)"
ts=2022-11-14T14:58:14.862Z caller=main.go:139 level=info listen_address=:9091
ts=2022-11-14T14:58:14.863Z caller=tls_config.go:195 level=info msg="TLS is disabled." http2=false
可见其默认是监听在9091端口上
step2
配置prometheus增加target
[root@localhost prometheus-2.37.2.linux-amd64]# cat prometheus.yml
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# 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: "my_is_gateway"
static_configs:
- targets: ['localhost:9091']
labels:
instance: localhost
没有错,这里我们prometheus和pushgateway运行在同一个环境下。
这里target也绑定在localhost:9091(上面运行pushgateway可以看到其默认是9091)
然后稍等片刻就可以看到咱们新增的pushgateway了
关键字词:pushgateway,搭建,prometheus,增加,targets