zod*_*dac 6 openssl spring-boot prometheus
我正在通过 docker 部署 spring-boot 应用程序和 prometheus 容器,并已成功公开 spring-boot/actuator/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"
Run Code Online (Sandbox Code Playgroud)
我认为这与我设置 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>
Run Code Online (Sandbox Code Playgroud)
然后,我将证书导出到 .pem 文件,并提取 .crt 和 .key:
openssl pkcs12 -in cert.p12 -out cert.pem -nodes -passin pass:<pass>
Run Code Online (Sandbox Code Playgroud)
这是通过共享卷安装到我的 prometheus 容器的,该容器有一个 --web.config.file 包含:
tls_server_config:
cert_file: /path/to/cert.crt
key_file: /path/to/cert.key
Run Code Online (Sandbox Code Playgroud)
为了更好地衡量,我添加到insecure_skip_verify: true了 prometheus.yml 配置中:
- 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
Run Code Online (Sandbox Code Playgroud)
好吧,我想我找到了我的问题。我做了两处改变:
首先,我将 web.config.file 的内容移至“spring-actuator”下的 prometheus.yml 文件中。然后我将目标更改为使用后端容器的主机名,而不是 127.0.0.1。
最终结果是一个 prometheus.yml 文件:
- job_name: 'spring-actuator'
metrics_path: '/actuator/prometheus/'
scrape_interval: 60s
scheme: https
static_configs:
- targets: [ 'backend:8443' ]
tls_config:
cert_file: /path/to/cert.crt
key_file: /path/to/cert.key
insecure_skip_verify: true
Run Code Online (Sandbox Code Playgroud)
所以只是一些愚蠢的错误,据我所知,不是由证书引起的。:)
| 归档时间: |
|
| 查看次数: |
3933 次 |
| 最近记录: |