Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prometheus cannot unmarshal !!map into []*config.FileSDConfig #2426

Closed
aali1 opened this Issue Feb 14, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@aali1
Copy link

aali1 commented Feb 14, 2017

Environment

  • System information:
    Linux 3.10.0-327.36.3.el7.x86_64 x86_64

  • Prometheus version:

prometheus, version 1.4.1 (branch: master, revision: 2a89e87)
build user: root@e685d23d8809
build date: 20161128-09:59:22
go version: go1.7.3

  • Prometheus configuration file:
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).

  # Attach these labels to any time series or alerts when communicating with
  # external systems (federation, remote storage, Alertmanager).
  external_labels:
      monitor: 'codelab-monitor'

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first.rules"
  # - "second.rules"

# 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'.
    file_sd_configs:
      names:
        - 'tgconf.json'
      job_name: 'file_sd'
  • I also tried
    file_sd_configs:
      names: ['tgconf.json']
      job_name: 'file_sd'
  • tgconf.json
[
  {
    "targets": ["localhost:9090", "reporting-01.lab.aws:9100"],
    "labels": {
      "job": "my_servers"
    }
  }
]
  • Logs:
INFO[0000] Starting prometheus (version=1.4.1, branch=master, revision=2a89e8733f240d3cd57a6520b52c36ac4744ce12)  source=main.go:77
INFO[0000] Build context (go=go1.7.3, user=root@e685d23d8809, date=20161128-09:59:22)  source=main.go:78
INFO[0000] Loading configuration file prometheus.yml     source=main.go:250
ERRO[0000] Error loading config: couldn't load configuration (-config.file=prometheus.yml): yaml: unmarshal errors:
  line 25: cannot unmarshal !!map into []*config.FileSDConfig  source=main.go:152

@juliusv

This comment has been minimized.

Copy link
Member

juliusv commented Feb 14, 2017

That's not a valid file_sd_configs section (it's a single item, not a list, and the field names are off). Take a look at a valid file-SD config section here: https://github.com/prometheus/prometheus/blob/master/config/testdata/conf.good.yml#L32-L39

@juliusv juliusv closed this Feb 14, 2017

@aali1

This comment has been minimized.

Copy link
Author

aali1 commented Feb 15, 2017

Thanks @juliusv it worked! By the way, when to use dash (-) and when not to?

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 24, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.