Healthwatch apply changes fails with error filling alertmanager.yml.erb template
search cancel

Healthwatch apply changes fails with error filling alertmanager.yml.erb template

book

Article ID: 293637

calendar_today

Updated On:

Products

Operations Manager

Issue/Introduction

You encounter an error during Apply Changes and BOSH is not able to render the template alertmanager.yml.erb.


Environment

Product Version: 2.1

Resolution

When configuring alerts for Healthwatch 2.x, you encounter an error like the one below during an Apply Changes:

Task 13591 | 06:39:00 | Preparing deployment: Rendering templates (00:00:14)
L Error: Unable to render instance groups for deployment. Errors are:
- Unable to render jobs for instance group 'tsdb'. Errors are:
- Unable to render templates for job 'alertmanager'. Errors are:
Exit code 1
- Error filling in template 'alertmanager.yml.erb' (line 119: (): did not find expected key while parsing a block mapping at line 2 column 3)
Task 13591 | 06:39:14 | Error: Unable to render instance groups for deployment. Errors are:
- Unable to render jobs for instance group 'tsdb'. Errors are:
- Unable to render templates for job 'alertmanager'. Errors are:
- Error filling in template 'alertmanager.yml.erb' (line 119: (): did not find expected key while parsing a block mapping at line 2 column 3)
 

The cause of this issue is that the YAML configuration is not formatted correctly. The alertmanager.yml.erb template is used to generate the Alert Manager configuration. This template is using ruby YAML.load to reformat the configuration. Given that the YAML is not valid, the `YAML.load` fails.

111 global:
112 <%= route = p('routes')
113   route_yaml = {}
114   if route.empty?
115     route_yaml["route"]= {}
116     route_yaml["route"]["routes"]= nil
117     route_yaml["route"]["receiver"]= "default-receiver"
118   else
119     base_route_yaml = YAML.load(route)
120
121     if base_route_yaml.has_key?("route")
122       route_yaml = base_route_yaml
123     else
124       route_yaml["route"] = base_route_yaml
125     end
126
127   end
128 YAML.dump(route_yaml).sub("---\n", "")
129 %>
 

You should validate the correctness of the YAML using a validator.

  • Online: You can use the online validator.
  • Locally: You can use various scripting languages:
# ruby
$ ruby -ryaml -e "p YAML.load(STDIN.read)" < data.yaml
# python 2
$ python -c 'import yaml, sys; yaml.safe_load(sys.stdin)' < data.yaml
# python 3
$ python3 -c 'import yaml, sys, pprint; pprint.pprint(yaml.safe_load(sys.stdin))' < data.yaml
# Docker and yamllint
$ docker run --rm -v :/yaml sdesbure/yamllint yamllint data.yaml