【问题标题】:Prometheus yaml file: did not find expected keyPrometheus yaml 文件:未找到预期的密钥
【发布时间】:2020-01-27 17:50:06
【问题描述】:

我是 yml 文件格式的新手,我不知道为什么在运行应用程序时出现错误:

从“prometheus.yml”加载配置时出错:无法加载 配置 (--config.file=\"prometheus.yml\"): 解析 YAML 文件 prometheus.yml:yaml:第 34 行:没有找到预期的密钥

这是我收到的唯一通知,没有任何具体内容。这是我的文件的样子:

# my global config
global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:9090']


global:
scrape_interval: 10s
evaluation_interval: 10s
- job_name: 'kafka'
  static_configs:
   - targets:
     - localhost:7071

我的间距是否导致错误?我尝试像默认文件一样复制间距。如果我在第二次全局之后删除所有内容,它将运行。我该如何解决这个问题?

【问题讨论】:

标签: yaml prometheus


【解决方案1】:

您不能有两个“全局”部分。 “scrape_interval”和“evaluation_interval”参数已经在第一个“global”中定义了,最后不需要再定义这些了。

【讨论】: