D
D
dflbrhekbn2020-02-14 18:17:28
JavaScript
dflbrhekbn, 2020-02-14 18:17:28

How to "trim" a string in JSON in Zabbix in preprocessing using JavaScript?

Good afternoon. In zabbix using low-level discovery I get JSON

[
   {
      "AllocatedSpace":"4500504576",
      "DiffVolume":"Win32_Volume.DeviceID=\\\"\\\\\\\\\\\\\\\\?\\\\\\\\Volume{7070e300-8301-11e9-80b5-8010667d187a}\\\\\\\\\\\"",
      "MaxSpace":"11810111488",
      "UsedSpace":"3965501440",
      "Volume":"Win32_Volume.DeviceID=\\\"\\\\\\\\\\\\\\\\?\\\\\\\\Volume{7070e300-8301-11e9-80b5-8010667d187a}\\\\\\\\\\\""
   
},
   {
      "AllocatedSpace":"3411214336",
      "DiffVolume":"Win32_Volume.DeviceID=\\\"\\\\\\\\\\\\\\\\?\\\\\\\\Volume{7060e484-82e1-11e9-80b3-806e6f6e6963}\\\\\\\\\\\"",
      "MaxSpace":"5330960384",
      "UsedSpace":"3098034176",
      "Volume":"Win32_Volume.DeviceID=\\\"\\\\\\\\\\\\\\\\?\\\\\\\\Volume{7060e484-82e1-11e9-80b3-806e6f6e6963}\\\\\\\\\\\""
   
}
]


Then, with the help of LLD, I make a macro {#VOLUME} = $.Volume , which will then go to the data element prototypes.
But the problem is that there is a lot of superfluous in the macro. I found solutions on the Internet that you can use js in preprocessing to cut off the unnecessary part in "Volume" and leave for example - {7060e484-82e1-11e9-80b3-806e6f6e6963}.
But unfortunately I can't do it on my own.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dflbrhekbn, 2020-02-21
@dflbrhekbn

return value.replace(/Win.*{([\w-]+)}\\+"/g,'$1')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question