【发布时间】:2022-02-02 04:12:14
【问题描述】:
我正在通过 docker 部署 spring-boot 应用程序和 prometheus 容器,并成功暴露了 spring-boot /actuator/prometheus 端点。但是,当我启用 prometheus 调试日志时,我可以看到它无法抓取指标:
ts=2022-02-02T03:54:46.210Z
caller=scrape.go:1292
level=debug
component="scrape manager"
scrape_pool=spring-actuator
target=https://127.0.0.1:8443/actuator/prometheus/
msg="Scrape failed"
err="Get \"https://127.0.0.1:8443/actuator/prometheus/\": dial tcp 127.0.0.1:8443: connect: connection refused"
我认为这与我设置 spring-boot HTTPS 的方式有关。我在构建我的 spring-boot 应用程序期间使用以下命令生成自签名证书:
keytool
-genkey
-alias <alias>
-dname <dname>
-keyalg RSA
-keysize 4096
-storetype PKCS12
-keystore <path_to_keystore>
-validity 3650
-storepass <keystore_pass>
然后我将证书导出到 .pem 文件,并提取 .crt 和 .key:
openssl pkcs12 -in cert.p12 -out cert.pem -nodes -passin pass:<pass>
这是通过共享卷安装到我的 prometheus 容器中的,该容器有一个 --web.config.file 包含:
tls_server_config:
cert_file: /path/to/cert.crt
key_file: /path/to/cert.key
为了更好地衡量,我在 prometheus.yml 配置中添加了 insecure_skip_verify: true:
- job_name: 'spring-actuator'
metrics_path: '/actuator/prometheus/'
scrape_interval: 60s
scheme: https
static_configs:
- targets: [ '127.0.0.1:8443' ]
tls_config:
insecure_skip_verify: true
【问题讨论】:
标签: spring-boot openssl prometheus