Best way to lint Prometheus YAML in CI?

1,128 views
Skip to first unread message

Dave Cadwallader

unread,
Feb 23, 2018, 3:38:26 PM2/23/18
to Prometheus Users
I'm storing all my prometheus config in source control, including prometheus server config, and alert rules.

I've currently got a CI pipeline set up to validate my alert rules using promtool and it's working great!

I'd also like to validate my prometheus server config's yml, so i can avoid errors like this:

level=error ts=2018-02-23T19:17:06.217109599Z caller=main.go:446 msg="Error reloading config" err="couldn't load configuration (--config.file=/etc/prometheus.yml): parsing YAML file /etc/prometheus.yml: yaml: unmarshal errors:\n  line 17: cannot unmarshal !!map into []*config.AlertmanagerConfig"

Any recommendations for a tool to catch yaml errors (and also any way to auto-prettify yaml)?  Searching around github I couldn't seem to find any popular choices so I'm curious what everyone else does.

Brian Brazil

unread,
Feb 23, 2018, 4:34:03 PM2/23/18
to Dave Cadwallader, Prometheus Users
Promtool can also check prometheus.yml.

--

Dave Cadwallader

unread,
Feb 23, 2018, 4:47:14 PM2/23/18
to Prometheus Users
That's great news!  Are there any docs for this?  The only reference I could find was how to check rules.yml.

Dave Cadwallader

unread,
Feb 23, 2018, 5:25:40 PM2/23/18
to Prometheus Users
Found it in the source :) 

promtool check config path/to/prometheus.yml
Reply all
Reply to author
Forward
0 new messages