# Complex linking of datasources (lookup tables)

**URL:** <https://community.icinga.com/t/complex-linking-of-datasources-lookup-tables/14325>\
**Category:** Icinga Director\
**Created:** [November 21, 2024, 12:10pm UTC](https://community.icinga.com/t/complex-linking-of-datasources-lookup-tables/14325 "2024-11-21T12:10:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yoogie27](https://community.icinga.com/user_avatar/community.icinga.com/yoogie27/32/2064_2.png) [@yoogie27](https://community.icinga.com/u/yoogie27)\
**Post date:** [November 21, 2024, 12:10pm UTC](https://community.icinga.com/t/complex-linking-of-datasources-lookup-tables/14325/1 "2024-11-21T12:10:55Z")

</div>

Hi, I have a complex use case which I hope would be possible to implement with Director.

I am trying to automatically populate host groups based on our naming convention.  
I am using vspheredb to import all virtual machines and vm hosts. They all follow the same naming convention. The first 3 characters identify the location of an asset. We may as well work with IP ranges later, but this is where we are.

For instance, a host resource with the name ‘fraxxxxxxxx’ should be assigned to the host group ‘Frankfurt’.

For this, I have setup an import source which consists of a simple query.

> select ‘1’ as ‘key’, ‘fra’ as ‘identifier’, ‘Frankfurt’ as ‘location’ union all select ‘2’ as ‘key’, … (and so on and so fourth)

The idea is that I will use modifiers for my vspheredb import, have a field with substring(0,3) and match this against the lookup table for ‘identifier’, then take what is in ‘location’ for my asset.

I don’t think I can use a modifier and the lookup table in the filter expression.  
So far I have a modifier like this:

> property: object\_name  
> target property: locationidentifier  
> Modifier: substring  
> Start: 0  
> End: 3

This gives me a column with ‘fra’ as locationidentifier

My second modifier is this:

> Property: locationidentifier  
> Target property: location  
> Set based on filter: yes  
> Filter Expression: locationidentifier=identifier  
> Modifier: Get a property from another Import Source  
> Import Source: location\_mapping  
> Property: location

Unfortunately the location is always empty and I have no idea how to construct the filter to use the value instead of text…

---

<div class="post-metadata">

**Author:** ![yoogie27](https://community.icinga.com/user_avatar/community.icinga.com/yoogie27/32/2064_2.png) [@yoogie27](https://community.icinga.com/u/yoogie27)\
**Post date:** [November 21, 2024, 12:18pm UTC](https://community.icinga.com/t/complex-linking-of-datasources-lookup-tables/14325/2 "2024-11-21T12:18:44Z")

</div>

I am trying to give an example here to make it clearer:  
My **location\_mapping** source produces the following table:

| key | identifier | location |
| --- | --- | --- |
| 1 | fra | Frankfurt |
| 2 | wie | Wiesbaden |

My vspheredb imports an asset with **object\_name** = **frablablablubb**

My modifier rule 1 applies substring, so that **locationidentifier** = **fra**

My modifier rule 2 should do a lookup and pull **location** (Frankfurt) out of **location\_mapping** , because **locationidentifier** matched the column **identifier**.

I hope this makes sense

---

<div class="post-metadata">

**Author:** ![moreamazingnick](https://community.icinga.com/user_avatar/community.icinga.com/moreamazingnick/32/7725_2.png) [@moreamazingnick](https://community.icinga.com/u/moreamazingnick)\
**Post date:** [November 22, 2024, 11:30am UTC](https://community.icinga.com/t/complex-linking-of-datasources-lookup-tables/14325/3 "2024-11-22T11:30:36Z")

</div>

Why not using a Hostgroup apply rule?

 ![Screenshot 2024-11-22 123023](https://community.icinga.com/uploads/default/original/2X/2/22333a3fb39010d8fdc413da88680897106dac18.png)

---

<div class="post-metadata">

**Author:** ![yoogie27](https://community.icinga.com/user_avatar/community.icinga.com/yoogie27/32/2064_2.png) [@yoogie27](https://community.icinga.com/u/yoogie27)\
**Post date:** [November 22, 2024, 1:26pm UTC](https://community.icinga.com/t/complex-linking-of-datasources-lookup-tables/14325/4 "2024-11-22T13:26:52Z")

</div>

Nah, too simple! 🙂  
Thank you, I did not think about this…
