Ad Widget

Collapse

Zabbix API Count Host with Tags

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jdoggy31
    Member
    • Feb 2019
    • 39

    #1

    Zabbix API Count Host with Tags

    Hello -

    I am trying to count all the host in a particular host group with a Tag on them. I can get it to count the host in a group with no issue, however I can not seem to figure out how to just count Hosts with a tag In postman it always returns the count for the whole group using the json request below. Any help would be greatly appreciated

    {
    "jsonrpc": "2.0",
    "method": "host.get",
    "params": {
    "output": ["hostid"],
    "groupids": "22",
    "filter": {
    "tags": [
    {
    "tag": "Importance",
    "value": "Important"
    }
    ]
    },
    "countOutput": true
    },
    "auth": "authkey here",
    "id": 1
    }
  • amirkhan
    Junior Member
    • Apr 2024
    • 1

    #2
    Please remove "filter" clause and it will work.
    Your query should look like this

    {
    "jsonrpc": "2.0",
    "method": "host.get",
    "params": {
    "output": ["hostid"],
    "groupids": "22",
    "tags": [
    {
    "tag": "Importance",
    "value": "Important"
    }
    ]
    "countOutput": true
    },
    "auth": "authkey here",
    "id": 1
    }

    Comment

    • jdoggy31
      Member
      • Feb 2019
      • 39

      #3
      Thank you that worked!! I had a add a comma after the ] and before the "countOutput" but you fixed me up perfectly

      Comment

      Working...