# DB-Keys between service and contact\_group

**URL:** <https://community.icinga.com/t/db-keys-between-service-and-contact-group/4084>\
**Category:** Icinga 2\
**Created:** [April 14, 2020, 2:11pm UTC](https://community.icinga.com/t/db-keys-between-service-and-contact-group/4084 "2020-04-14T14:11:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alfderheld](https://community.icinga.com/letter_avatar_proxy/v4/letter/a/73ab20/32.png) [@alfderheld](https://community.icinga.com/u/alfderheld)\
**Post date:** [April 14, 2020, 2:11pm UTC](https://community.icinga.com/t/db-keys-between-service-and-contact-group/4084/1 "2020-04-14T14:11:25Z")

</div>

In a short way: Im looking for the correlation between a contact\_group to a single service in database:  
icinga\_services.service\_id = 12345  
icinga\_objects.object\_id = 67890  
icinga\_servicestatus.servicestatus\_id = 9876

icinga\_contactgroups.contactgroup\_id = 54321  
icinga\_contactgroups.contactgroup\_object\_id = 11111

Thx & kind regards

Alf

---

<div class="post-metadata">

**Author:** ![anon66228339](https://community.icinga.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@anon66228339](https://community.icinga.com/u/anon66228339)\
**Post date:** [April 14, 2020, 2:38pm UTC](https://community.icinga.com/t/db-keys-between-service-and-contact-group/4084/2 "2020-04-14T14:38:51Z")

</div>

Hello,

you can read about it in the [docs](https://icinga.com/docs/icinga2/latest/doc/24-appendix/#db-ido-schema)

Regards,  
Carsten

---

<div class="post-metadata">

**Author:** ![alfderheld](https://community.icinga.com/letter_avatar_proxy/v4/letter/a/73ab20/32.png) [@alfderheld](https://community.icinga.com/u/alfderheld)\
**Post date:** [April 15, 2020, 5:52am UTC](https://community.icinga.com/t/db-keys-between-service-and-contact-group/4084/3 "2020-04-15T05:52:50Z")

</div>

Hi Carsten,

I can read, thx. But dont need a description of every field, i need the Correlation between two fields like service and contactgroups. I cant find this on the DB Scheme. I try to describe: In web2 there are a cobtactgroup defined for every service on a host. But how is the correlation between the service and the contactgroup? Ive got an object-id for the service and another one for contact-group. But where is the correlation between both objects? There are special Apply-Rules for services to contact\_groups but i dont think, that the correlation is made by this.

KR

Alf

---

<div class="post-metadata">

**Author:** ![nilmerg](https://community.icinga.com/user_avatar/community.icinga.com/nilmerg/32/277_2.png) [@nilmerg](https://community.icinga.com/u/nilmerg)\
**Post date:** [April 15, 2020, 6:34am UTC](https://community.icinga.com/t/db-keys-between-service-and-contact-group/4084/4 "2020-04-15T06:34:13Z")

</div>

> [@alfderheld](#):
>
> I can read, thx.

If you’ve already read it without getting the information you wanted, just say it. No need to get to a harsh/arrogant tone.

Anyway, what you want is probably this:

```sql
SELECT so.name1, so.name2, s.display_name, ic.alias FROM icinga_services s
INNER JOIN icinga_objects so on so.object_id = s.service_object_id AND so.is_active = 1 and so.objecttype_id = 2
LEFT JOIN icinga_service_contactgroups isc on s.service_id = isc.service_id
LEFT JOIN icinga_objects scgo on isc.contactgroup_object_id = scgo.object_id AND scgo.is_active = 1 AND scgo.objecttype_id = 10
LEFT JOIN icinga_contactgroups ic on isc.contactgroup_object_id = ic.contactgroup_object_id
WHERE ic.contactgroup_id IS NOT NULL

```

The IDO uses the `icinga_objects` table to establish relations to most other tables.

---

<div class="post-metadata">

**Author:** ![alfderheld](https://community.icinga.com/letter_avatar_proxy/v4/letter/a/73ab20/32.png) [@alfderheld](https://community.icinga.com/u/alfderheld)\
**Post date:** [April 15, 2020, 8:44am UTC](https://community.icinga.com/t/db-keys-between-service-and-contact-group/4084/5 "2020-04-15T08:44:03Z")

</div>

> [@nilmerg](#):
>
> If you’ve already read it without getting the information you wanted, just say it. No need to get to a harsh/arrogant tone.

sry, that was not my intention. I only want to say, that I read this. I will try now try the statement
