     [celestial.security :refer (current-user)]
     [celestial.persistency.systems :as s]))
 
-; http://192.168.5.9/index.html#/dashboard/script/logstash.js?query=tid:b8d9d3aa-0e2b-4d28-a495-d9f77858d454
+; 
 
 (import-logging)
 
 (defmodel hash)
+
+(defn tid-link [tid]
+  (let [{:keys [host type]} (get! :celestial :log :gelf)]
+    (case type
+     :kibana (<< "http://~{host}/index.html#/dashboard/script/logstash.js?query=tid:~{tid}")
+     :gralog2 "TBD"
+     :logstash "Nan"
+     (warn (<< "no matching tid link found for ~{type}")))))
+
+(defn add-tid-link [{:keys [tid] :as job}]
+  (assoc job :tid-link (tid-link tid)))
 
 (defn schedule-job 
   ([id action msg]


(ns celestial.api.jobs
  "Jobs manangement API"
  (:refer-clojure :exclude [hash])
  (:require 
    [swag.model :refer (defmodel)]
    [clojure.core.strint :refer (<<)]
    [celestial.common :refer (bad-req success import-logging)]
    [gelfino.timbre :refer (get-tid)]
    [celestial.persistency :as p]
    [celestial.jobs :as jobs]

  (GET- "/jobs" []
        {:nickname "jobsStatus" :summary "Global job status tracking" 
         :notes "job status can be either pending, processing, done or nil"}
        (success 
          (map-vals 
            (merge {:jobs (jobs/running-jobs-status)} (jobs/done-jobs-status)) (partial map add-tid-link))))

  )
