diff --git a/webhook/hook.go b/webhook/hook.go index 439f204..f79ce94 100644 --- a/webhook/hook.go +++ b/webhook/hook.go @@ -101,25 +101,28 @@ func Webhook(w http.ResponseWriter, r *http.Request, c config.Configuration) { if name, ok := data.CommonLabels["instance"]; ok { l.V(2).Infof("Creating host %v", name) - host, err = icinga.GetHost(serviceHost) + host, err = icinga.GetHost(name) if err != nil { err := icinga.CreateHost(icinga2.Host{ Name: name, DisplayName: name, Notes: "Created by signalio", + Address: name, }) if err != nil { l.Errorf("Could not create service host %v: %v\n", host, err) asJSON(w, http.StatusInternalServerError, err.Error()) return } - host, err = icinga.GetHost(serviceHost) + host, err = icinga.GetHost(name) if err != nil { l.Errorf("Did not find service host %v: %v\n", host, err) asJSON(w, http.StatusInternalServerError, err.Error()) return } } + serviceHost = name + l.V(2).Infof("Using host %v=%v", name, host) } else { l.V(2).Infof("No instance label") }