Ad Widget

Collapse

Getting not null values from API history

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • damino312
    Junior Member
    • Jul 2024
    • 1

    #1

    Getting not null values from API history

    Hello, I need to get the latest not "0" value from history. Unfortunately, zabbix filter does not provide an opportunity to look for values that does not match a set one, I can only find those which match.
    I have tried to get values with 'search' param writing next params:
    Code:
    search: {
    value: ['0']
    },
    excludeSearch: true
    but I get an error from API:
    code: -32602,
    message: 'Invalid params.',
    data: 'Invalid parameter "/search": should be empty.'
    I also have tried to seach without 'excludeSearch' param to make sure that seach does not work here at all.

    Here is my code:
    Code:
    const response = await axios.post(
    "http://zabbix.gmkzoloto.ru/zabbix/api_jsonrpc.php",
    {
    jsonrpc: "2.0",
    method: "history.get",
    params: {
    output: ["value"],
    history: 0,
    itemids,
    time_till: endTimestamp,
    sortfield: "clock",
    sortorder: "DESC",
    limit: 1,
    },
    id: 1,
    auth: token,
    },
    {
    headers: {
    "Content-Type": "application/json-rpc",
    },
    }
    );
    ​​

    Any ideas on this thing?
    Zabbix version is 6.0.32.
  • NgRox
    Member
    • Jun 2022
    • 44

    #2
    In this case where there is no way to define the value in the call, wouldn't it be easier to deal with it later?

    Comment

    Working...