我有一个 Ubuntu 18.04 操作系统,我已经prometheus
按照以下步骤安装了它这里(我只是更改了链接和版本)。
但是当我尝试使用 启动服务时sudo systemctl start prometheus
,出现以下错误/var/log/syslog
:
Jan 11 21:46:57 ZiZi prometheus[11585]: level=error ts=2020-01-11T18:16:57.051Z caller=main.go:727 err="error loading config from \"/etc/prometheus/prometheus.yml\": couldn't load configuration (--config.file=\"/etc/prometheus/prometheus.yml\"): parsing YAML file /etc/prometheus/prometheus.yml: yaml: unmarshal errors:\n line 15: field static_configs not found in type config.plain"
/etc/prometheus/prometheus.yml
这是(如上述教程中所述)的内容:
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds.
evaluation_interval: 15s # Evaluate rules every 15 seconds.
scrape_timeout: 15s # scrape_timeout is set to the global default (10s).
# 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']
我该如何修复这个错误?
答案1
您所遵循的教程对文件格式有误;缩进在 YAML 中是有意义的,与实际的 prometheus doco 进行比较:https://prometheus.io/docs/prometheus/latest/getting_started...static_configs:
属于scrape_configs:
,因此缩进
答案2
我会先尝试一个新的 vanilla 配置https://github.com/prometheus/prometheus/blob/release-2.15/config/testdata/conf.good.yml
然后使用--config.file指定启动时使用哪个文件
编辑:
与该 cmd 的输出相同吗?
./prometheus --config.file=prometheus.yml