Loading configurations failed while starting prometheus service in Ubuntu 18.04

2

I have an Ubuntu 18.04 OS and I have installed prometheus on it following steps here (I just changed links and versions).

But when I tried to start the service with sudo systemctl start prometheus, I got the following error in /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"

This is the content of /etc/prometheus/prometheus.yml (as described in the above mentioned tutorial):

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']

How can I fix the error?

Zeinab Abbasimazar

Posted 2020-01-12T08:03:17.460

Reputation: 175

Answers

1

The tutorial you're following is doing the file-format wrong; indentation is meaningful in YAML, compare to the actual prometheus doco: https://prometheus.io/docs/prometheus/latest/getting_started ... static_configs: belongs under scrape_configs:, thus indented

tink

Posted 2020-01-12T08:03:17.460

Reputation: 1 419

0

I would first just try a new vanilla config https://github.com/prometheus/prometheus/blob/release-2.15/config/testdata/conf.good.yml

then use --config.file to specify which file when starting

edit:

Same output with this cmd?

./prometheus --config.file=prometheus.yml

TheRoot3dUser

Posted 2020-01-12T08:03:17.460

Reputation: 1