Icinga2 Director Data Fields Import

Hi there. i’m new with icinga2 and im looking for a workaround for import multiple data fields to icinga director. i tried multiple scenarios to solve this, but i just can’t get through. I know the data fields can’t be called via cli or Rest API (no function at least directly). If you POST or PUT vars._ via API it show’s in the host or service preview, but not shown in the data/fields and if i changed the object, it will deleted.
What i want to achive is put multiple datafields in the director and assign it to the corresponding service template. I’m working on an ansible installer script that’s why i can’t put it in via web
thanks for the help.

I’am using the ansible directormodul for this. Ansible modules for Icinga Director

You need to use the director rest api and not the icinga2 api. If i want to add vars with Powershell f.e. i read out the existing vars into an array, add the new and write them back.

not quite what i’m looking for, but i look into it, maybe i can figure out something. What do you mean using director rest api above icinga2 api i used it as the docs says (https://icinga.com/docs/director/latest/doc/70-REST-API/) “Maybe i mislead you cause i wrote wrongly” . If you can show me an example i think it can help me a lot. Thanks.

As you are using the Director api, forget what i said about the icinga2 api :slight_smile:

Hi, do you have an example of your API request so we could get an idea what went wrong or how your request should be look like?

BTW: Do you know the FileShipper Module for the director? https://icinga.com/docs/director/latest/fileshipper/doc/02-Installation/ With this you can import csv, json, xslx, xml-files.
Some weeks ago I adopt our import from csv to json. Now we are really flexible with multiple var fields. Of course the logic is in an import script which creates one json file from diffrent data sources. But it works really fine.
If your data source is a database you can also directly connect to this and fetch the data from there

Hi there! i tried the fileshipper, there is an example of my problem. I created a service template with vars included:

[ { "check_command": "pgsql",
    "groups": [ "ekr_default_linux_services" ],
    "object_name": "pgsql",
    "object_type": "template",
    "use_agent": true,
    "vars": {
        "pgsql_hostname": "localhost",
        "pgsql_password": "icinga",
        "pgsql_username": "icinga"
    } } ]

the shipper setup:

the first problem is if i try to modify it, then trigger a sync, it failed saying trying to recreate the service. (as if ignoring the update policy)
the second, if i want to modify the template, in the service tab, the custom fields doesn’t show up. I see them in the Preview as vars and as custom Variables in director/data/fields but i want them as Data Fields. Im using pgsql as director database. I want to avoid updating the database directly with query.

I got a similar problem when i’m used the API. The fileshipper seems more flexible that’s why i posted this. Sry for the late answer, i had lot to do

For me it looks fine. But we only import hosts with a lot of custom vars. And the assignment of the services is based on this information.

Maybe a problem could be that the imported services are named in the same way. As I remember from a training the imported services are “single services” not “Service apply rules” nor “service sets”. A solution could be you are working with macros to create service with unique names

You can import hosts multiple times with the same name? or “update” the host configuration with it? i got “recreating” error when i try it.

No the hostname is unique. If not you, get an error like “duplicate entry”

then what’s the purpose in the sync_rule “update policy” option. I just don’t get it.
I will try to create a Service apply rule for a service group hope it can work.

we use “replace” because we have only one (big json-)file to import

can you share that file with me? or a part of it, like 1 host with the more service_check + 1 more host (to see the dependencies) i would really appreciate it :slight_smile:


this is a JSON-example (in short and anonymized form) from host with Icinga Agent

      "template_extra_xx" : "",
      "accept_config" : "y",
      "template_extra_yy" : "",
      "template" : "template_zz",
      "zone" : "server",
      "has_agent" : "y",
      "vars" : {
         "Contact" : [
            "Person A",
            "Person B"
         "OS" : "W2012R2",
         "Devicetype" : "Server",
         "Hardware" : null,         
         "Location" : "Virtuell",
         "WartungOS" : "ST4",
         "Monitoring_with_Icinga_Agent" : "y"
      "hostname" : "host_aaaa",
      "master_should_connect" : "y",
      "template_extra_zz" : "y",
      "displayname" : "this is doing this and that",
      "ipadresse" : "xx.xx.xx.xx"

background info: I create the JSON-File with a perl script. This is catching the data form all our databases, APIs etc.

We are using diffrent templates. If you add a field like “template_extra_xx”, you can add this sync rule in the director:

And if you put your custom vars in the field vars, you can copy them 1:1 from the json file into the field in in icinga:

The other rules should be clear:

Because of processing the catched data in my perl script, I don’t need any modifiers in the import function.

With the diffrent information from host (incl. custom vars) you can create your diffrent apply for rules, service sets etc. like