Common YAML Gotchas

While this course presumes you know YAML, there are some common mistakes that are made that I'd like to point out now in case you run into them.

To start with, here's the correct configuration we want to specify:

scrape_configs:
 - job_name: prometheus
   static_configs:
   - targets: ['localhost:9100']


The most common mistake is creating separate list entries where you meant to instead add a field to an existing entry:

scrape_configs:
 - job_name: prometheus
 - static_configs:   # Mistake: The hyphen here creates a new scrape_config
   - targets: ['localhost:9100']


Another common mistake is incorrect indentation, for example:

scrape_configs:
 - job_name: prometheus
 static_configs:   # Mistake: The 's' should be in the same column as the 'j'
   - targets: ['localhost:9100']


The final mistake that's often seen is passing a list entry rather than a list, for example:

scrape_configs:
 - job_name: prometheus
   static_configs:
   - targets: 'localhost:9100'  # Mistake: targets takes a list of strings, not a string

Complete and Continue