Showing results for 
Show  only  | Search instead for 
Did you mean: 

Key check error in json using go template for monaco


I am trying to write a json file to create automatically applied tags with rules for entities I am entering in my input yaml for monaco. In the json file, I am trying to write a condition where I'll check whether a certain key exists under the 'parameters' field in yaml; if the key exists, then I'll add the required code block in final json to add that rule and if the key doesn't exist, I'll move onto the next block. With this approach, I am trying to dynamically build a json that'll have the code blocks to create rule only for entities who are present in the yaml file. When I am using the if conditions and the key isn't present, it is showing error that the mentioned key in json isn't present. I tried golang syntax to check if the key exists, but that also didn't work. Kindly suggest whether it's possible to execute in go templating in json and if it's possible, please guide with the syntax. I am attaching the example yaml file and the json that contains the two syntax I have tried so far.


DynaMight Guru
DynaMight Guru


To avoid complexity I would recommend it:

  1. Create automatic tag rule using Dynatrace UI.
  2. Download configuration using download command.
  3. Check YAML and create parameters you need.
  4. Check JSON and reference your parameters.

I would try to avoid Go templating since Dynatrace is saying this in the documentation:


Best regards

❤️ Emacs ❤️ Vim ❤️ Bash ❤️ Perl

Featured Posts