当前位置: 首页 > news >正文

Prometheus监控harbor仓库

1、将harbor的metrics打开

# values.yaml
···
metrics:     enabled: true             # 打开core:path: /metricsport: 8001registry:path: /metricsport: 8001jobservice:path: /metricsport: 8001exporter:path: /metricsport: 8001···# 更新helm
helm upgrade harbor -n harbor -f values.yaml .

2、修改Prometheus的values文件

# values.yaml
···prometheus.yml:rule_files:- /etc/config/recording_rules.yml- /etc/config/alerting_rules.yml## Below two files are DEPRECATED will be removed from this default values file- /etc/config/rules- /etc/config/alertsscrape_configs:                            - job_name: prometheusstatic_configs:- targets:- localhost:9090- job_name: 'harbor'                        # 往这添加一个harbor的jobstatic_configs:- targets: ['harbor.xwk.local']         # harbor的访问地址metrics_path: /metricstls_config:insecure_skip_verify: true              # 跳过证书认证
···# 更新
helm upgrade prometheus -n prometheus -f values.yaml .

3、访问Prometheus的页面

f259f468-be79-471f-8399-350da8601995

可以看出监控并没有成功,报错:Error scraping target: received unsupported Content-Type "text/html" and no fallback scrape_protocol specified for target
原因就在于没有加重定向,ingress会把访问/metrics的流量转发到80端口上,所以会出现这个问题

4、解决方法

编辑harbor仓库的ingress去添加一条规则
kubectl edit ingress harbor-ingress -n harbor
···- backend:                        # 将这个添加进去service:name: harbor-exporter       # harbor接口svc的地址port:number: 8001path: /metricspathType: Prefix···# 再试试
[root@master-11 prometheus]# curl -H "Host: harbor.xwk.local" http://10.0.0.200/metrics     # 换成你的harbor地址与IP
# 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"} 2.6613e-05
go_gc_duration_seconds{quantile="0.25"} 6.0318e-05
go_gc_duration_seconds{quantile="0.5"} 9.2387e-05
go_gc_duration_seconds{quantile="0.75"} 0.000227891
go_gc_duration_seconds{quantile="1"} 0.002910467
go_gc_duration_seconds_sum 0.007297454
go_gc_duration_seconds_count 33
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 12
# HELP go_info Information about the Go environment.
# TYPE go_info gauge
go_info{version="go1.21.9"} 1
# HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.
# TYPE go_memstats_alloc_bytes gauge
go_memstats_alloc_bytes 3.237288e+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.8977496e+07
# 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 5060
# HELP go_memstats_frees_total Total number of frees.
# TYPE go_memstats_frees_total counter
go_memstats_frees_total 155160
# HELP go_memstats_gc_sys_bytes Number of bytes used for garbage collection system metadata.
# TYPE go_memstats_gc_sys_bytes gauge
go_memstats_gc_sys_bytes 4.035304e+06
·····
这样就成功的监控了harbor仓库,若是遇到了其他的服务需要去监控,也可以通过这种方法去添加规则使访问/metrics的流量转发到正确的地方
大部分的cncf服务的values中都会有暴漏metrics的参数,将他打开,更新helm,然后在Prometheus的values中添加一条- job_name:以及后面的参数,更新完helm,添加一条重定向的规则就能成功访问

微信图片_2025-09-09_002746_200

http://www.agseo.cn/news/520/

相关文章:

  • kubernetes集群重置部署
  • 文件不只是数据-一份稳健的文件处理指南
  • 第一次作业
  • freeRTOS的信号量,是不是有点像中断
  • 【去日本玩了2】跟随空色轨迹一起去日本演出(2025年)
  • weston 桌面使用及工作架构
  • 滑动窗口
  • helm 部署 prometheus
  • windows将服务器文件夹映射到windows本地
  • assert 调试断言用法详解
  • [huggingface] huggingface 有和 `git clone` 一样方便的命令
  • 基础操作指令
  • buildroot 工具使用问题
  • 计数杂题选刷 Part II
  • 泛型
  • general planning
  • PHP反序列化漏洞-初学1
  • 2025.9.8 树套树
  • Rust异步运行时最小实现 - extreme 分享
  • 复健。(11~20,OI)
  • 诗-春江花月夜
  • MIDI简谱编辑器1.1程序代码QZQ-2025-8-20
  • MIDI简谱播放器1.1程序代码QZQ-2025-8-20
  • python语言网页版MIDI钢琴软件代码QZQ
  • 【2024-2025第二学期】助教工作学期总结(算法与数据结构)
  • p型编码
  • 赣江游记
  • OTA 升级问题的分析
  • 初识Dataset
  • Day15可变参数