Ad Widget

Collapse

Count unique values from multiple items

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • markfree
    Senior Member
    • Apr 2019
    • 868

    #1

    Count unique values from multiple items

    A host has multiple items with a status string value of either "Ended OK" or "Ended Not OK".
    I need to create another item that counts how many items have each value.

    To find the value I am looking for, I was thinking of using the "find" function like this:
    Code:
    find(//ctm.job.status[*],,,"Ended Not OK")

    With that I could try to use the "sum_foreach", but I'm not sure how to make them work together.
    Something like this, but valid.
    Code:
    sum_foreach(find(//status[*],,"eq","Ended Not OK")
    Any suggestions?
  • markfree
    Senior Member
    • Apr 2019
    • 868

    #2
    So far, I've found this reference for the "foreach" functions.
    Conditions expression
    The conditions expression supports:
    operands:
    group - host group
    tag - item tag
    "<text>" - string constant, with the \ escape character to escape " and \
    case-sensitive string comparison operators: =, <>
    logical operators: and, or, not
    grouping with parentheses: ( )
    Quotation of string constants is mandatory. Only case-sensitive full string comparison is supported.
    I didn't understand how a "<text>" can be an operand.

    If my expression is
    Code:
    count_foreach(//ctm.job.status[*]?["Ended OK"],5m)
    When I test it, Zabbix gives the following error since aggregate calculations do not support strings.
    Code:
    unsupported calculated value result "double vector[0:0]" of type "double vector"
    Click image for larger version  Name:	teste_count_foreach.png Views:	0 Size:	19.9 KB ID:	479670

    And when I try to add the item with the "count_foreach" expression, another error is displayed.
    Code:
    Invalid parameter "/1/params": incorrect expression starting from "count_foreach(//ctm.job.status[*]?["Ended OK"],5m)".
    Click image for larger version  Name:	add_error_count_foreach.png Views:	0 Size:	5.9 KB ID:	479671

    So, this "<text>" string constant as an operand doesn't make sense to me.
    Also, I could not find a single example with just a string as an operand.​
    Last edited by markfree; 26-02-2024, 15:57.

    Comment

    • markfree
      Senior Member
      • Apr 2019
      • 868

      #3
      This all looks like a frequency distribution to me, and the status values are the actual classes, but I can't wrap my head around it.
      Has anyone been able to work with categorical variables in Zabbix?

      Comment

      Working...