Ad Widget

Collapse

unable to preprocess timestamp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • blackbasket
    Junior Member
    • Jan 2025
    • 13

    #1

    unable to preprocess timestamp

    Hi community,

    I am trying to convert a given timestamp into date format to compare it. If I try, I always get NaN or invalid date in ZABBIX 7.0, but in JavaScript test page (https://developer.mozilla.org/en-US/...cts/Date/parse) ist is working. I tried with and without timezone. Same results.

    May someone help me please?

    Preprocessing:
    Click image for larger version

Name:	grafik.png
Views:	125
Size:	25.6 KB
ID:	497451

    JavaScript:
    Code:
    var a = Date.parse(value);
    return a;​
    Click image for larger version

Name:	grafik.png
Views:	73
Size:	36.9 KB
ID:	497452

    Regards,
    Marcel

  • Brambo
    Senior Member
    • Jul 2023
    • 245

    #2
    First try your jsonpath and add .first() to the path, this should get rit of those brackets
    Second I believe const and let aren't available in duktape javascript so use var for your variables.
    As I'm no javascript guru I would suggest to take a look at: https://www.zabbix.com/forum/zabbix-...ersion-problem

    Comment

    • blackbasket
      Junior Member
      • Jan 2025
      • 13

      #3
      Thank you, Brambo... the link helped... obviously I was to stupid to search for the right phrase

      BTW: In the zabbix code (see the code tag) I used var

      Comment

      • benisfroms
        Junior Member
        • Aug 2025
        • 2

        #4
        I see what you mean, and I agree — parsing timestamps can behave differently depending on the environment, which makes debugging in Zabbix a bit tricky compared to JavaScript directly in the browser. Sometimes the preprocessing step in Zabbix requires a custom transformation rule rather than relying on native parsing.

        Comment

        • benisfroms
          Junior Member
          • Aug 2025
          • 2

          #5
          I see what you mean, and I agree

          Comment

          Working...