Ad Widget

Collapse

Change dependent item's "Type of information"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Delerion
    Junior Member
    • Feb 2022
    • 7

    #1

    Change dependent item's "Type of information"

    Hey Zabbixers!

    I have an item reading a windows log, being the “Type of information” as Log. From this item I have a dependent item to create a graph for the backup status, by preprocessing the results of it’s master to convert them to numbers (‘success’ to 1 / ‘failed’ to -1 so I can get a nice transition in the graph). For that graph to be created I need the type of information to be “Numeric (float)”.


    Everything works with the positive values as the work as strings anyway, but I get errors with the negative ones as they are received as strings. Is it possible to transform the values from the master item or do I have to look for a different approach with another type of widget?
    Is there any option to change the background of an Item (widget) in the dashboard according to these results without a Grafana?

    Thanks in advance!
  • Hamardaban
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • May 2019
    • 2713

    #2
    How do you convert a log to a number? What expression?

    Comment

    • Delerion
      Junior Member
      • Feb 2022
      • 7

      #3
      My main item stores the needed data with the words 'success' or 'failed', then my dependent item preprocess that item looking for the word success and returns a 1 or a -1.
      The problem is the main item is a log type, but I need the depending to be a float due to the negative sign (I want it that way as a 0 would not be different from the times between backups in a graph), or to find another way to show easily the results of my backups (colored).

      Click image for larger version

Name:	imagen.png
Views:	411
Size:	6.6 KB
ID:	449854

      For some reason I get this error when the backups fail, the weird thing is that the Type of information is Log in my main item, and Numeric (float) in my dependent... so no Numeric (unsigned) anywhere... but maybe they must be the same type to work.
      Click image for larger version

Name:	imagen.png
Views:	388
Size:	4.1 KB
ID:	449856

      Click image for larger version

Name:	imagen.png
Views:	361
Size:	5.1 KB
ID:	449855

      Comment

      • Hamardaban
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • May 2019
        • 2713

        #4
        I reproduced your situation (zabbix ver 6.2.0) - everything works as it should.
        -1 is recognized as a number, not string


        try using JS preprocessing instead of regex

        Code:
        return value.search(/success/i) >= 0 ? 1: -1;
        Last edited by Hamardaban; 16-08-2022, 15:51.

        Comment

        • Delerion
          Junior Member
          • Feb 2022
          • 7

          #5
          In the end there was no need to change the regex, my master Item was generating an unexpected value as some of the backups are ending with an 'InProgress' status even being OK. That was causing my dependent item to receive a string that it was not able to process.
          Fixed by adding (?i)success|(?i)inprogress to the preprocessing steps.

          Thanks!!!

          Comment

          Working...