普罗米修斯:使用 https 方案的无效主机名

Jor*_*rdi 2 prometheus

普罗米修斯告诉我:

https://some-domain.com/backoffice ” 不是有效的主机名“

我的配置文件是:

global:
  scrape_interval: 10s

scrape_configs:
  - job_name: 'spring_micrometer'
    metrics_path: '/actuator/prometheus'
    scrape_interval: 5s
    static_configs:
            - targets: ['192.168.99.102:8085', '192.168.99.102:8083', '192.168.99.102:8084', 'https://<domain>/backoffice']
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

Cho*_*wta 8

正如 Gaurav 在他的回答中所说,我们只能在数组中使用主机类型 ( <domain>) targets。为了合并 httpsscheme和 path /backoffice,您需要在配置中分别使用schememetric_path属性(如果未明确提及,则scheme默认为http和 metric_path /metrics)。

我看到您已经添加了metric_path:'/actuator/prometheus'与其他人共享的targets. 因此,您可能需要为具有不同的抓取作业创建不同的抓取作业metric_pathscheme如下所示:

  - job_name: 'spring_micrometer_2'
    scrape_interval: 5s
    metrics_path: "/backoffice/actuator/prometheus"
    scheme: "https"
    static_configs:
      - targets:<domain>
Run Code Online (Sandbox Code Playgroud)

如果您想在所有目标上使用相同的作业名称“spring_micrometer”,您可以relabel_configs在“spring_micrometer_2”作业上使用如下所示:

scrape_configs:
  - job_name: 'spring_micrometer'
    metrics_path: '/actuator/prometheus'
    scrape_interval: 5s
    static_configs:
            - targets: ['192.168.99.102:8085', '192.168.99.102:8083', '192.168.99.102:8084']
  - job_name: 'spring_micrometer_2'
    scrape_interval: 5s
    metrics_path: "/backoffice/actuator/prometheus"
    scheme: "https"
    static_configs:
      - targets:<domain>
    relabel_configs:
      - source_labels: [job]
        target_label:  job
        replacement:   `spring_micrometer`
Run Code Online (Sandbox Code Playgroud)


小智 4

静态配置目标必须是由主机名或 IP 后跟可选端口号组成的有效字符串。

这里的有效主机名<domain>不是https://<domain>/backoffice

作为参考,您可以检查以下 https://prometheus.io/docs/prometheus/latest/configuration/configuration/#host

要检查主机名是否有效,请检查以下正则表达式测试 https://www.regextester.com/23