下载
https://github.com/prometheus/pushgateway/releases
1 | curl https: //github .com /prometheus/pushgateway/releases/download/v1 .2.0 /pushgateway-1 .2.0.linux-amd64. tar .gz |
https://prometheus.io/download/
启动Pushgateway
1 | nohup . /pushgateway > run.log 2>&1 & |
usage: pushgateway [<flags>]
Flags:
--web.listen-address=":9091" 监听Web界面,API和遥测的地址。
--web.telemetry-path="/metrics" 公开metrics的路径。
--web.external-url= 可从外部访问Pushgateway的URL.
--web.route-prefix="" Web端点内部路由的前缀。 默认为--web.external-url的路径.
--persistence.file="" 归档以保留metrics。 如果为空,则metrics仅保留在内存中.
--persistence.interval=5m 写入持久性文件的最小间隔。
--log.level="info" 仅记录具有给定严重性或更高严重性的消息。 有效级别:[debug, info, warn, error, fatal]
--log.format="logger:stderr" 设置日志目标和格式。 示例:“ logger:syslog?appname = bob&local = 7”或“ logger:stdout?json = true”
--version 显示应用程序版本。
查看是否启动成功
1 | curl "http://localhost:9091/metrics" |
把Pushgateway信息添加到Prometheus配置文件prometheus.yml中
1 2 3 4 5 6 7 | - job_name: pushgateway honor_labels: true static_configs: - targets: [ 'localhost:9091' ] labels: instance: pushgateway service: pushgatewayservicet |
推送数据
1 2 3 4 | echo "mytest_metric 2022" | curl --data-binary @- http: //localhost :9091 /metrics/job/mytest_job #这里pushgateway_test就是prometheus主配置文件里job的名字,需要保持一致,这样数据就会推送给这个job。后面的instance则是指定机器名,使用的就是脚本里获取的那个变量值 echo "$label $count" | curl --data-binary @- http: //server .com:9091 /metrics/job/pushgateway_test/instance/ $instance_name |
1 | curl "http://localhost:9091/metrics" | grep mytest_metric |
分类:
prometheus
标签:
pushgateway
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?