error orccured during parsing service discovery file.

39 views
Skip to first unread message

ㅁㄴ

unread,
May 21, 2020, 9:52:30 PM5/21/20
to Prometheus Users
- prometheus.yml

global:
  scrape_interval:     3s
  evaluation_interval: 3s

rule_files:
  # - "first.rules"
  # - "second.rules"

scrape_configs:
  - job_name: prometheus
    static_configs:
      - targets: ['localhost:9090']
  - job_name: node_exporter
    file_sd_configs:
      - files:
        - '/Users/skynet/prometheus/server/sd.yml'



- sd.yml

targets:
  - "localhost:9100/metrics"
  
labels:
  - ensemble: ["127.0.0.1:2181"]
  - service_code: "test"



when I run prometheus, this error is occured.

msg="Error reading file" path=/Users/skynet/prometheus/server/sd.yml err="yaml: unmarshal errors:\n  line 1: cannot unmarshal !!map into []*targetgroup.Group"

How can i fix?

Brian Candler

unread,
May 22, 2020, 1:59:48 AM5/22/20
to Prometheus Users
Firstly, the top level of the targets file must be a list, which means "bullet points" required at the top:

- targets: ...
  labels: ...

- targets: ...
  labels: ...

Secondly, the labels themselves can only be strings, not lists.

- targets:
    - "localhost:9100/metrics"

  labels:
    - ensemble: "127.0.0.1:2181"
    - service_code: "test"
    - node: "127.0.0.1:11211"

You can't have two values for the label "node".

Reply all
Reply to author
Forward
0 new messages