Added support for multiline JSON strings in YAML fields (similar to alert_text)
http_post2_payload: |
{
"description": "An event came from IP {{ _data["client.ip"] }}",
"username": "{{ _data['username'] }}"
{%- for k, v in some_field.items() -%}
,"{{ k }}": "changed_{{ v }}"
{%- endfor -%}
}
http_post2_headers: |
{
"authorization": "Basic 123dr3234",
"X-custom-{{key}}": "{{type}}"
}
Added jinja_root_name support to the HTTP POST2 alerter
Changed the --data argument for rule testing to accept both a file with a single JSON document or a file with a proper JSON list of objects
Example file with single JSON object
{"fieldname": "value"}
Example file with list of JSON objects:
[{"fieldname":"value1"},{"fieldname":"value2"}]
Additional error checking has been added around JSON decoding and jinja templates for HTTP POST2 headers and payloads
The change to --data for rule testing was added just for convenience. I was doing some testing and didn't realize the document needed to be a list of JSON objects. I didn't see anything stating it needed to be a list so I changed the code to allow for a single JSON object in the file or a list of JSON objects. The intent of this PR was not to make this change so if it's not wanted I'm okay with removing it
Description
Added support for multiline JSON strings in YAML fields (similar to alert_text)
Added
jinja_root_name
support to the HTTP POST2 alerterChanged the
--data
argument for rule testing to accept both a file with a single JSON document or a file with a proper JSON list of objects Example file with single JSON objectExample file with list of JSON objects:
Additional error checking has been added around JSON decoding and jinja templates for HTTP POST2 headers and payloads
Checklist
make test-docker
with my changes.Questions or Comments
The change to
--data
for rule testing was added just for convenience. I was doing some testing and didn't realize the document needed to be a list of JSON objects. I didn't see anything stating it needed to be a list so I changed the code to allow for a single JSON object in the file or a list of JSON objects. The intent of this PR was not to make this change so if it's not wanted I'm okay with removing it