Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-19726

API configuration.import does not update a trigger but creates a now one

XMLWordPrintable

    • Icon: Problem report Problem report
    • Resolution: Unresolved
    • Icon: Trivial Trivial
    • None
    • 5.0.14
    • API (A)
    • None
    • Zabbix with saltstack using the API and configuration.import.

      Zabbix 5.2

      Steps to reproduce:

      I use saltstack to provision monitring, but I think the error lies within Zabbix API. Basically I use the zabbix API to create templates. After a change in the template source I also want to update zabbix. But this fails. The API create a new trigger instead of updating the existing one.

       

      Creation of the template with the following yaml works:

       

      zabbix_export:
       version: '5.2'
       date: '2021-07-23T17:37:28Z'
       groups:
         - name: Templates
         - name: Mailstore
       templates:
         -
           template: IMAP_Service_2
           name: IMAP_Service2
           groups:
             - name: Templates
             - name: Mailstore
           applications:
             - name: 'IMAP Service2'
           items:
             -  
               name: check_imap2
               type: EXTERNAL
               key: 'check_imap.sh["\{HOST.NAME}"]'
               trends: '0'
               value_type: TEXT
               description: 'output of the check_imap2 script. Output is JSON that need to be parsed afterwards in dependent items.'
               applications:
                 - name: 'IMAP Service2'
             -
               name: imap_code2
               type: DEPENDENT
               key: imap_code2
               delay: '0'
               description: 'Return code of the curl command.'
               applications:
                 -
                   name: 'IMAP Service2'
               preprocessing:
                 -
                   type: JSONPATH
                   parameters:
                     - $.code
               master_item:
                 key: 'check_imap.sh["\{HOST.NAME}"]'
               triggers:
                 -
                   expression: '{last()}>0'
                   name: 'IMAP Acess to test mailbox'
                   priority: WARNING
                   description: 'The return code of the curl command was {ITEM.VALUE1}.'
      

      Now I want to update that template with the expression "

      {last()}

      =0". Running the API call creates a new trigger in the template instead of updating the existing one. My saltstack state is

       
      
      zabbix.run_query:
       module.run:
         - method: configuration.import
         - params:
             format: yaml
             source: |
               {{ template_source | indent(10) }}
             rules:
               templates:
                 createMissing: true
                 updateExisting: true
               applications:
                 createMissing: true
               items:
                 updateExisting: true
                 createMissing: true
               triggers:
                 updateExisting: true
                 createMissing: true
      

      Result:

      Additional trigger with the new expression created. The API by the way, does not complain about any error.

      Expected:
      Update the existing trigger with the new expression.

            zabbix.dev Zabbix Development Team
            misch Michael Schwartzkopff
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: