Last active
August 9, 2017 21:19
-
-
Save englishm-llnw/8e6adb3641bb149713c626fdce2b0431 to your computer and use it in GitHub Desktop.
Structured logging in Salt with `file.append` and `|json`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"a": "a value", "c": "c value", "b": "b value"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% set logline_data = { | |
'a': variable_a, | |
'b': variable_b, | |
'c': variable_c | |
} | |
%} | |
structured-logging-attempt: | |
file.append: | |
- name: /var/log/example.log | |
- text: '{{ logline_data|json }}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Without the single quotes around
{{ logline_data|json }}
the expanded text will be parsed as YAML and the following will be logged instead of the expected JSON.example.log
:Buggy code producing this result looks like: