Ad Widget

Collapse

Need help with getting an item to display in trigger alert.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TheVito
    Junior Member
    • Oct 2016
    • 6

    #1

    Need help with getting an item to display in trigger alert.

    I am using 7.0 forgot to mention that.

    I am using zabbix_sender to send a text item that looks like this: customer-1, customer is the name of the customer and the 1 is the error number.

    I created an item that is a zabbix Trapper named: CustomerLogError
    The key field is named customerID-errorID
    I created 2 other items they are both dependent on CustomerLogError.

    The first one is named CustomerLogError: CustomerLogErrorID it is a dependent item
    with Key value of CustomerLogError.ID it has a preprocessing regular expresssion of ^[^-]*-(.*)$ \1
    which grabs the “1” off of the data sent via zabbix_sender.

    The second one is named CustomerLogError: CustomerLogName it is a dependent item
    with the Key value of CustomerLog.name it has a preprocessing regular expresssion of ^(.*)-.*$ \1
    which grabs the “customer” off of the data sent via zabbix_sender.

    There are two triggers setup which use the CustomerLogError.ID to evaluate which error occurred.

    last(/PRDLOGSVR1/CustomerLogError.ID)=1
    and
    last(/PRDLOGSVR1/CustomerLogError.ID)=2

    I have a trigger action setup which is setup like this:

    Action

    Name: CustomerLogAction

    Type of calculation: Custom expression (A or B)

    Conditions:

    Label Name Action

    A Trigger equals PRDLOGSVR1: CustomerConnectionLeakTrigger Remove

    B Trigger equals PRDLOGSVR1: CustomerPrimaryKeyTrigger Remove

    Add

    Enabled

    The Operation is set to send an email, no matter what I have tried I can not get CustomerLog.name
    to display in the email, as you can see below I tried multiple ways, it doesn’t display the customer name, it just puts the syntax of the macro in the email

    Problem started at {EVENT.TIME} on {EVENT.DATE}

    Problem name: {TRIGGER.NAME}

    Host: {HOST.NAME}

    Severity: {TRIGGER.SEVERITY}

    Item: {ITEM.NAME}

    Current Value: {ITEM.VALUE}

    Description: {TRIGGER.DESCRIPTION}

    Event Details:

    - Trigger Expression: {TRIGGER.EXPRESSION}

    - Event ID: {EVENT.ID}

    - Original Problem ID: {EVENT.ID}

    Additional Information:

    - Operational Data: {ITEM.VALUE1}Log into PRDLOGSVR1 and review the log. It will be in this folder E:\ProductionAppServerLogs\{HOST.HOST}:CustomerLog .name.last()-connection-leaks-as-of-{EVENT.DATE}

    {{HOST.HOST}:CustomerLog.name.last()}-connection-leaks-as-of-{EVENT.DATE}

    Custom Log Name: {{PRDLOGSVR1:CustomerLog.key}}

    {servername:top.last(0)} {PRDLOGSVR1::CustomerLogName.last()}

    {HOST.TAG} {HOST.INVENTORY.VENDOR}

    {$CUSTOMER_LOG_NAME}





    Last edited by TheVito; 21-06-2024, 17:50.
  • markfree
    Senior Member
    • Apr 2019
    • 868

    #2
    You see... There are some formatting options available in the message editor. They help to make the text visually easier to read. Also, pictures help to visualize the context.

    Anyway... So you must include the customer's name in the email message and this name is stored in the "CustomerLogError: CustomerLogName" item with the "CustomerLog.name" key. Right?

    Are you using Expression Macros for this?

    Comment

    • TheVito
      Junior Member
      • Oct 2016
      • 6

      #3
      That is correct I am trying to get that item to display in the alert email, but everything i try does not produce it. I am not sure what i am doing wrong, and no i am not using Expression Macros, should I be?

      Comment

      • markfree
        Senior Member
        • Apr 2019
        • 868

        #4
        Originally posted by TheVito
        That is correct I am trying to get that item to display in the alert email, but everything i try does not produce it. I am not sure what i am doing wrong, and no i am not using Expression Macros, should I be?
        Look at the expression macro syntax at the link above and try using it. This seems like a good approach.

        Comment

        • TheVito
          Junior Member
          • Oct 2016
          • 6

          #5
          I have tried everything i am sure it has to be something simple, i just do not know how to use these macros properly i am guessing....

          Here is the latest output from the trigger alert, I tried numerous variations to try to get the NAME displayed.

          Problem started at 07:05:52 on 2024.06.24

          Problem name: CustomerConnectionLeakTrigger
          Host: PRDLOGSVR1
          Severity: High
          Item: CustomerLogErrorID
          Current Value: 1

          Event Details:
          - Trigger Expression: last(/PRDLOGSVR1/CustomerLogError.ID)=1
          - Event ID: 33241
          - Original Problem ID: 33241

          Additional Information:

          {PRDLOGSVR1:CustomerLogName.last())} I tried multiple variations to try to get this to print the value tstdoc
          What is the correct syntax to do this, please help :-)

          Here is a screen shot of the latest data: as you can see it has a value of tstdoc

          Click image for larger version

Name:	image.png
Views:	248
Size:	36.3 KB
ID:	486255
          My trigger email definition looks like this:
          Click image for larger version

Name:	image.png
Views:	247
Size:	45.6 KB
ID:	486256
          Click image for larger version

Name:	image.png
Views:	252
Size:	13.2 KB
ID:	486257​​
          Attached Files

          Comment

          • earth-spark
            Junior Member
            • Jun 2025
            • 3

            #6
            Did you ever manage to do this? I want to enrich the description with another item related to the host. This will then give the operator further context, without manually checking on the host.

            Comment

            • earth-spark
              Junior Member
              • Jun 2025
              • 3

              #7
              Originally posted by earth-spark
              Did you ever manage to do this? I want to enrich the description with another item related to the host. This will then give the operator further context, without manually checking on the host.
              Some further context: I have two traps being sent via Zabbix Trapper.

              One is a numeric value; the other is a string value.

              I want to display the string within the problem description to give more context for the agent. An example of the string being passed:

              FAILURE: ERROR: Authentication failed for A.B.C.D. Details: 401 Client Error: Unauthorized for url: https://A.B.C.D/mmi/api/jsonrpc

              I can only seem to reference items utilised in the expression, so I included the value within the expression even though it's not required to identify the problem.

              Even doing this, the string is truncated in the description.

              See both the Trigger and Problem screenshots.
              Click image for larger version  Name:	Trigger_Screenshot.png Views:	0 Size:	79.6 KB ID:	504391
              Click image for larger version  Name:	Problem_Screenshot.png Views:	0 Size:	21.2 KB ID:	504390

              Is there a method to show the full string received within the description of the problem triggered?

              It's not the best fix; however, I could patch /usr/share/zabbix/ui/include/items.inc.php—so true $trim = false is false.

              function formatAggregatedHistoryValueRaw($value, array $item, int $function, bool $force_units = false,
              bool $trim = false, array $convert_options = []): array {
              $units = $force_units || CAggFunctionData:reservesUnits($function) ? $item['units'] : '';



              Attached Files
              Last edited by earth-spark; 23-06-2025, 18:52.

              Comment

              • cyber
                Senior Member
                Zabbix Certified SpecialistZabbix Certified Professional
                • Dec 2006
                • 4807

                #8
                Originally posted by markfree

                Look at the expression macro syntax at the link above and try using it. This seems like a good approach.
                but you can still only use those items and values that you are using in trigger expression... If expression only uses CustomerLogErrorID, then you cannot use CustomerLogName. So, to have a name also available, you can add another (useless) equation to expression ... like bytelenght(last(host/item))>0 and then you can reference that items value in your event name.

                Comment

                Working...