You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Prometheus监控HTTPS端点报错:INVALID并非有效起始令牌

问题原因

报错的核心不是HTTPS scheme配置错误,而是你指定的metrics_path: '/v6/latest/USD'返回的是JSON格式的汇率数据,并非Prometheus可直接解析的OpenMetrics/Prometheus exposition格式(这类格式以# HELP/# TYPE开头)。Prometheus在尝试解析响应内容时,发现开头不是预期的metrics标识,从而抛出了误导性的scheme相关错误。

解决方案

根据你的需求,分两种场景处理:

场景1:仅监控端点是否可达(存活状态)

使用Blackbox Exporter来探测HTTPS端点的可用性,步骤如下:

  1. 部署Blackbox Exporter(Windows下可直接下载对应二进制包运行)
  2. 配置Blackbox Exporter的blackbox.yml(示例):
modules:
  http_2xx:
    prober: http
    http:
      method: GET
      tls_config:
        insecure_skip_verify: true
  1. 修改Prometheus的prometheus.yml,添加Blackbox的抓取配置,通过它来探测目标端点:
scrape_configs:
  - job_name: "blackbox"
    metrics_path: /probe
    params:
      module: [http_2xx]
    static_configs:
      - targets:
        - https://open.er-api.com/v6/latest/USD
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: localhost:9115  # Blackbox Exporter的地址

场景2:需要监控汇率数值(将JSON转为metrics)

你需要一个自定义exporter或者使用通用的JSON exporter来把目标端点的JSON数据转换成Prometheus metrics格式:

  1. 部署JSON Exporter(比如prometheus-json-exporter,Windows下可下载二进制)
  2. 配置JSON Exporter的config.yml(示例,提取汇率数据):
modules:
  er_api:
    metrics:
      - name: exchange_rate_usd
        type: gauge
        path: "{$.rates.CNY}"  # 假设你要监控人民币对美元的汇率,根据实际JSON结构调整
        help: "CNY to USD exchange rate"
  1. 修改Prometheus的prometheus.yml,添加JSON Exporter的抓取配置:
scrape_configs:
  - job_name: "exchange_rate"
    metrics_path: /probe
    params:
      module: [er_api]
      target: [https://open.er-api.com/v6/latest/USD]
    static_configs:
      - targets:
        - localhost:7979  # JSON Exporter的地址
额外说明

你的原配置中scheme: https和targets: ["open.er-api.com:443"]是正确的,问题出在目标端点的返回格式不符合Prometheus的抓取要求,和Windows操作系统无关。

内容的提问来源于stack exchange,提问作者Pratik

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.22 20:42:19