Ad Widget

Collapse

Discovery rule - item prototype to get values for different users

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jarleler
    Junior Member
    • Jan 2025
    • 1

    #1

    Discovery rule - item prototype to get values for different users

    Hi all, I am struggling to get values into the items for an discovery rule I have in Zabbix. The users are discovered but it doesn't look like values are created for the different macros. I believe there might be an issue with my jsonpath preprocessing.
    The setup is like this:

    1. Main item that gets the users/data from a JSON data structure:
    Name: User Quota JSON
    Type: Zabbix agent
    Key: captive.portal.data
    Data: Text

    This item correctly gets json data from the agent and it looks like this:
    [
    {
    "{#USERNAME}": "laptop",
    "{#CURRENTPERIOD}": "weekly",
    "{#USAGEDAILY}": 0,
    "{#USAGEWEEKLY}": 9671900711,
    "{#USAGEMONTHLY}": 0,
    "{#USAGEUNL}": 0,
    "{#QUOTADAILY}": 0,
    "{#QUOTAWEEKLY}": "12288",
    "{#QUOTAMONTHLY}": 0,
    "{#QUOTAUNL}": 0
    },
    {
    "{#USERNAME}": "mini",
    "{#CURRENTPERIOD}": "weekly",
    "{#USAGEDAILY}": 0,
    "{#USAGEWEEKLY}": 0,
    "{#USAGEMONTHLY}": 0,
    "{#USAGEUNL}": 0,
    "{#QUOTADAILY}": 0,
    "{#QUOTAWEEKLY}": "1",
    "{#QUOTAMONTHLY}": 0,
    "{#QUOTAUNL}": 0
    }
    ]

    2. Then I have a discovery rule like this:
    Name: User Quota Discovery
    Type: Dependent Item
    Key: captive.portal.discovery
    Master Item: User Quota JSON (the main item from "1")
    Preprocessing: JSONPath parameter: $[*]

    3. For the discovery rule I am testing now with one item prototype like this:
    Name: Quota Weekly for {#USERNAME}
    Type: Dependent item
    Key: captive.portal.quotaweekly[{#USERNAME}]
    Master Item: User Quota JSON
    Preprosessing JSONPath: $[?(@['{#USERNAME}'] == '{#USERNAME}')]['{#QUOTAWEEKLY}']

    I am not able to get any values into the different macros.

    Can anyone see what I am doing wrong?



Working...