Ad Widget

Collapse

How to relate zabbix host and hostgroup tables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Leonardo Andrade
    Junior Member
    • Sep 2023
    • 2

    #1

    How to relate zabbix host and hostgroup tables

    I'm new here on the Forum, I'm developing a process where I make some requests to the Zabbix API through Data Factory, I'm managing to load the data and make it available in the raw data layers (raw) normally, I linked the event table with the host by the hostid where I got most of the data through PySpark, and now I need to get to the Host Group table, but there's the problem, within the Host Group I don't have an attribute that allows the Host Group to relate to a host or an event , would anyone have a solution for this case?

    Thanks.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    "hstgrp" has all the hostgroups, "hosts" has all the hosts, "hosts_groups" has all the info, which hosts belong to which group... one line per group belonging...
    Code:
    zabbix=# \d+ hosts_groups;
                                            Table "public.hosts_groups"
       Column    |  Type  | Collation | Nullable | Default | Storage | Compression | Stats target | Description
    -------------+--------+-----------+----------+---------+---------+-------------+--------------+-------------
     hostgroupid | bigint |           | not null |         | plain   |             |              |
     hostid      | bigint |           | not null |         | plain   |             |              |
     groupid     | bigint |           | not null |         | plain   |             |              |
    Indexes:
        "hosts_groups_pkey" PRIMARY KEY, btree (hostgroupid)
        "hosts_groups_1" UNIQUE, btree (hostid, groupid)
        "hosts_groups_2" btree (groupid)
    Foreign-key constraints:
        "c_hosts_groups_1" FOREIGN KEY (hostid) REFERENCES hosts(hostid) ON DELETE CASCADE
        "c_hosts_groups_2" FOREIGN KEY (groupid) REFERENCES hstgrp(groupid) ON DELETE CASCADE
    Access method: heap​
    hostid is same as hostid in "hosts" and groupid is same as groupid in "hstgrp"

    Comment

    Working...