Ad Widget

Collapse

Preprocessing an item: how to force string type before discard?

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gammuts
    Junior Member
    • Feb 2016
    • 6

    #1

    Preprocessing an item: how to force string type before discard?

    How can I force a value to be text during preprocessing?



    Background:

    I'm monitoring the latest archived WAL with pgBackRest. I get these kind of JSON replies:
    Code:
    {"archive":[{"max":"000000050000002900000018"}]}
    I can extract it with preprocessing JSONPath "$.max", no problem there.

    However, I want to use "Discard", but it discards is currently "too much". Values 000000050000002900000018 and 000000050000002900000019 are treated as equal (!). Why? I think zbx_variant_compare() in src/libs/zbxvariant/variant.c is too blame:
    Code:
    661:int    zbx_variant_compare(const zbx_variant_t *value1, const zbx_variant_t *value2)
    662:{
    (...)
    678:    if ((ZBX_VARIANT_STR != value1->type || SUCCEED == zbx_is_double(value1->data.str, NULL)) &&
    679:            (ZBX_VARIANT_STR != value2->type || SUCCEED == zbx_is_double(value2->data.str, NULL)))
    680:    {
    681:        return variant_compare_dbl(value1, value2);
    682:    }
    Zabbix seems to auto upgrade a string to a double, if possible. Why are the values the same? Because they ARE the same when converted to a double:
    Code:
    000000050000002900000018 == 0x436634579b73efa2
    000000050000002900000019 == 0x436634579b73efa2
    (A double simply does not have the precision for my data.) But my data is NOT a double, it is text. "00000005000000290000001A" is also a valid value for instance.

    I already tried several text preprocessing options, like regex replace .* with \0, but doesn't seem to force text type.

    My situation: Zabbix 7.0.18
    Last edited by Gammuts; 24-09-2025, 14:48.
  • Answer selected by Gammuts at 25-09-2025, 19:54.
    Gammuts
    Junior Member
    • Feb 2016
    • 6

    I have something that seems to work:
    1. Extract data with JSONPath.
    2. Regular expression with pattern ".*" and output "\x0".
    3. Discard unchanged.
    4. Left trim, list of characters "x".

    Comment

    • Gammuts
      Junior Member
      • Feb 2016
      • 6

      #2
      I have something that seems to work:
      1. Extract data with JSONPath.
      2. Regular expression with pattern ".*" and output "\x0".
      3. Discard unchanged.
      4. Left trim, list of characters "x".

      Comment

      • Gammuts
        Junior Member
        • Feb 2016
        • 6

        #3
        FWIW: I filed a bug report for the implicit conversion of string to double. https://support.zabbix.com/browse/ZBX-27022

        Comment

        Working...