Ad Widget

Collapse

Zabbix api empty result

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • apollontzx
    Junior Member
    • May 2021
    • 5

    #1

    Zabbix api empty result

    hi, i'm send query to zabbix api,
    first query

    Code:
    {
        "jsonrpc": "2.0",
        "method": "item.get",
        "params": {
            "output": "extend",
            "hostids": "10360",
            "sortfield": "name"
        },
        "auth": "3de0e68699be49677d7eaf4892e69420",
        "id": 1
    }

    return

    Code:
    {
        "jsonrpc": "2.0",
        "result": [
            {
                "itemid": "34898",
                "type": "19",
                "snmp_oid": "",
                "hostid": "10360",
                "name": "totaldata",
                "key_": "trades.today.total",
                "delay": "1m",
                "history": "180d",
                "trends": "0",
                "status": "0",
                "value_type": "4",
                "trapper_hosts": "",
                "units": "",
                "formula": "",
                "logtimefmt": "",
                "templateid": "0",
                "valuemapid": "0",
                "params": "",
                "ipmi_sensor": "",
                "authtype": "0",
                "username": "",
                "password": "",
                "publickey": "",
                "privatekey": "",
                "flags": "0",
                "interfaceid": "0",
                "description": "",
                "inventory_link": "0",
                "lifetime": "30d",
                "evaltype": "0",
                "jmx_endpoint": "",
                "master_itemid": "0",
                "timeout": "3s",
                "url": "192.168.61.134:3344/data.json",
                "query_fields": [],
                "posts": "",
                "status_codes": "200",
                "follow_redirects": "1",
                "post_type": "0",
                "http_proxy": "",
                "headers": [],
                "retrieve_mode": "0",
                "request_method": "0",
                "output_format": "0",
                "ssl_cert_file": "",
                "ssl_key_file": "",
                "ssl_key_password": "",
                "verify_peer": "0",
                "verify_host": "0",
                "allow_traps": "0",
                "discover": "0",
                "state": "0",
                "error": "",
                "lastclock": "0",
                "lastns": "0",
                "lastvalue": "",
                "prevvalue": ""
            },
            {
                "itemid": "34900",
                "type": "18",
                "snmp_oid": "",
                [B]"hostid": "10360",[/B]
                "name": "trades_cost",
                "key_": "trades.cost",
                "delay": "0",
                "history": "90d",
                "trends": "365d",
                "status": "0",
                "value_type": "0",
                "trapper_hosts": "",
                "units": "",
                "formula": "",
                "logtimefmt": "",
                "templateid": "0",
                "valuemapid": "0",
                "params": "",
                "ipmi_sensor": "",
                "authtype": "0",
                "username": "",
                "password": "",
                "publickey": "",
                "privatekey": "",
                "flags": "0",
                "interfaceid": "0",
                "description": "",
                "inventory_link": "0",
                "lifetime": "30d",
                "evaltype": "0",
                "jmx_endpoint": "",
                "master_itemid": "34898",
                "timeout": "3s",
                "url": "",
                "query_fields": [],
                "posts": "",
                "status_codes": "200",
                "follow_redirects": "1",
                "post_type": "0",
                "http_proxy": "",
                "headers": [],
                "retrieve_mode": "0",
                "request_method": "0",
                "output_format": "0",
                "ssl_cert_file": "",
                "ssl_key_file": "",
                "ssl_key_password": "",
                "verify_peer": "0",
                "verify_host": "0",
                "allow_traps": "0",
                "discover": "0",
                "state": "0",
                "error": "",
                "lastclock": "0",
                "lastns": "0",
                "lastvalue": "0",
                "prevvalue": "0"
            }
        ],
        "id": 1
    }


    now, i need get history via history.get with my itemID (43900
    Query:

    Code:
    {
        "jsonrpc": "2.0",
        "method": "history.get",
        "params": {
            "output": "extend",
            "history": 0,
            [B]"itemids": "34900",[/B]
            "sortfield": "clock",
            "sortorder": "DESC",
            "limit": 10
        },
        "auth": "3de0e68699be49677d7eaf4892e69420",
        "id": 1
    }
    but server result is
    Code:
    {
        "jsonrpc": "2.0",
        "result": [],
        "id": 1
    }
    what is wrong? why result is empty?
    i have a graphics and data in this item
  • apollontzx
    Junior Member
    • May 2021
    • 5

    #2
    this is data in zabbix

    Click image for larger version

Name:	photo_2021-05-18_10-44-11.jpg
Views:	905
Size:	19.9 KB
ID:	424796


    why not working api?

    Comment

    • Atsushi
      Senior Member
      • Aug 2013
      • 2028

      #3
      Looking at the item information, the value_type is 4, so it may be stored as text on the database. If so, try specifying 4 for history as an argument to history.get.


      Comment

      • dimir
        Zabbix developer
        • Apr 2011
        • 1080

        #4
        Itemid 34900, which he's interested in, has value_type 0
        {
        "itemid": "34900",
        [...]
        "name": "trades_cost",
        "key_": "trades.cost",
        [...]
        "value_type": "0",
        Everything looks correct.

        Comment

        • gcalenko
          Zabbix developer
          • Mar 2017
          • 27

          #5
          Can you please provide more information on:
          - What Zabbix version you are using
          - Do you use additional storage for values (ElasticSearch)
          - Does the item with id 34898 have value when requested via API history.get
          - Is the host with id 10360 correct host you are viewing in latest data, try to open "Latest data" page using URL https://<your domain>/<frontend dir>/zabbix.php?action=latest.view&filter_hostids%5B%5D =10360&filter_set=1

          Comment

          Working...