-
Incident report
-
Resolution: Duplicate
-
Minor
-
None
-
3.2.3
-
None
-
None
Attempting to import an XML configuration for a web scenario + trigger template using the Zabbix API, but the import fails when verifying the trigger.
Here are the details of the request being made to the API and the error returned:
failed: [127.0.0.1] (item=services/website.xml.j2) => { "access_control_allow_headers": "Content-Type", "access_control_allow_methods": "POST", "access_control_allow_origin": "*", "access_control_max_age": "1000", "changed": false, "connection": "close", "content_length": "207", "content_type": "application/json", "date": "Tue, 14 Mar 2017 10:00:42 GMT", "failed": true, "failed_when_result": true, "invocation": { "module_args": { "backup": null, "body": { "auth": "f07beb1227557c992d8f6c395b48d0a7", "id": "24402", "jsonrpc": 2.0, "method": "configuration.import", "params": { "format": "xml", "rules": { "applications": { "createMissing": true, "deleteMissing": true, "updateExisting": true }, "groups": { "createMissing": true }, "items": { "createMissing": true, "deleteMissing": true, "updateExisting": true }, "templates": { "createMissing": true, "updateExisting": true }, "triggers": { "createMissing": true, "deleteMissing": true, "updateExisting": true } }, "source": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<zabbix_export>\n <version>3.2</version>\n <date>2017-03-12T12:26:11Z</date>\n <groups>\n <group>\n <name>ansible-zabbix/templates</name>\n </group>\n </groups>\n <templates>\n <template>\n <template>templates_website_check</template>\n <name>templates_website_check</name>\n <description/>\n <groups>\n <group>\n <name>ansible-zabbix/templates</name>\n </group>\n </groups>\n <applications>\n <application>\n <name>WEBSITE</name>\n </application>\n </applications>\n <items/>\n <discovery_rules/>\n <httptests>\n <httptest>\n <name>website_check</name>\n <application>\n <name>WEBSITE</name>\n </application>\n <delay>60</delay>\n <attempts>1</attempts>\n <agent>Zabbix</agent>\n <http_proxy/>\n <variables/>\n <headers/>\n <status>0</status>\n <authentication>0</authentication>\n <http_user/>\n <http_password/>\n <verify_peer>0</verify_peer>\n <verify_host>0</verify_host>\n <ssl_cert_file/>\n <ssl_key_file/>\n <ssl_key_password/>\n <steps>\n <step>\n <name>website_health</name>\n <url>{HOST.HOST}</url>\n <posts/>\n <variables/>\n <headers/>\n <follow_redirects>1</follow_redirects>\n <retrieve_mode>0</retrieve_mode>\n <timeout>300</timeout>\n <required/>\n <status_codes>200</status_codes>\n </step>\n </steps>\n </httptest>\n </httptests>\n <macros/>\n <templates/>\n <screens/>\n </template>\n </templates>\n <triggers>\n <trigger>\n <expression>{templates_website_check:web.test.fail[website_check].sum(#5)}>2</expression>\n <recovery_mode>0</recovery_mode>\n <recovery_expression/>\n <name>Greater than 60% failures on {HOST.HOST} for web scenario website_check</name>\n <correlation_mode>0</correlation_mode>\n <correlation_tag/>\n <url/>\n <status>0</status>\n <priority>4</priority> <description/>\n <type>0</type>\n <manual_close>0</manual_close>\n <dependencies/>\n <tags/>\n </trigger>\n </triggers>\n</zabbix_export>\n" } }, "body_format": "json", "content": null, "creates": null, "delimiter": null, "dest": null, "directory_mode": null, "follow": false, "follow_redirects": "safe", "force": false, "force_basic_auth": false, "group": null, "headers": { "Content-Type": "application/json" }, "http_agent": "ansible-httpget", "method": "POST", "mode": null, "owner": null, "regexp": null, "remote_src": null, "removes": null, "return_content": false, "selevel": null, "serole": null, "setype": null, "seuser": null, "src": null, "status_code": [ 200 ], "timeout": 30, "unsafe_writes": null, "url": "http://192.168.33.10/zabbix/api_jsonrpc.php", "url_password": null, "url_username": null, "use_proxy": true, "validate_certs": true }, "module_name": "uri" }, "item": "services/website.xml.j2", "json": { "error": { "code": -32602, "data": "Incorrect item key \"web.test.fail[website_check]\" provided for trigger expression on \"templates_website_check\".", "message": "Invalid params." }, "id": "24402", "jsonrpc": "2.0" }, "msg": "OK (207 bytes)", "redirected": false, "server": "Apache/2.4.6 (CentOS) PHP/5.4.16", "status": 200, "url": "http://192.168.33.10/zabbix/api_jsonrpc.php", "x_powered_by": "PHP/5.4.16" }
And here is what the XML looks like before being serialized into a string:
<?xml version="1.0" encoding="UTF-8"?> <zabbix_export> <version>3.2</version> <date>2017-03-12T12:26:11Z</date> <groups> <group> <name>ansible-zabbix/templates</name> </group> </groups> <templates> <template> <template>templates_website_check</template> <name>templates_website_check</name> <description/> <groups> <group> <name>ansible-zabbix/templates</name> </group> </groups> <applications> <application> <name>WEBSITE</name> </application> </applications> <items/> <discovery_rules/> <httptests> <httptest> <name>website_check</name> <application> <name>WEBSITE</name> </application> <delay>60</delay> <attempts>1</attempts> <agent>Zabbix</agent> <http_proxy/> <variables/> <headers/> <status>0</status> <authentication>0</authentication> <http_user/> <http_password/> <verify_peer>0</verify_peer> <verify_host>0</verify_host> <ssl_cert_file/> <ssl_key_file/> <ssl_key_password/> <steps> <step> <name>website_health</name> <url>{HOST.HOST}</url> <posts/> <variables/> <headers/> <follow_redirects>1</follow_redirects> <retrieve_mode>0</retrieve_mode> <timeout>300</timeout> <required/> <status_codes>200</status_codes> </step> </steps> </httptest> </httptests> <macros/> <templates/> <screens/> </template> </templates> <triggers> <trigger> <expression>{templates_website_check:web.test.fail[website_check].sum(#5)}>2</expression> <recovery_mode>0</recovery_mode> <recovery_expression/> <name>Greater than 60% failures on {HOST.HOST} for web scenario website_check</name> <correlation_mode>0</correlation_mode> <correlation_tag/> <url/> <status>0</status> <priority>4</priority> <description/> <type>0</type> <manual_close>0</manual_close> <dependencies/> <tags/> </trigger> </triggers> </zabbix_export>
The XML should be ok as I manually created the template with web scenario and trigger on an existing Zabbix server then exported the XML from there.
I can also import this XML successfully using the Zabbix frontend, but when trying to import through the API it fails.
- duplicates
-
ZBX-11754 Quotation marks absent in triggerns section when exporting Template with Web Scenario
- Closed