From 3089f1574560d2a33b07c18d8e321e3c2dc12651 Mon Sep 17 00:00:00 2001
From: Amine Chikhaoui <amine.chikhaoui91@gmail.com>
Date: Wed, 26 Jul 2017 15:20:40 +0100
Subject: [PATCH 1/6] Add hydra status dd timeboard expression

---
 dd-dashboard.nix | 161 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 161 insertions(+)
 create mode 100644 dd-dashboard.nix

diff --git a/dd-dashboard.nix b/dd-dashboard.nix
new file mode 100644
index 00000000..683449f0
--- /dev/null
+++ b/dd-dashboard.nix
@@ -0,0 +1,161 @@
+{
+  host
+, appKey
+, apiKey
+, ...
+}:
+{
+  resources.datadogTimeboards.dash = {
+    inherit appKey apiKey;
+    description = "Hydra build farm status (hydra.nixos.org)";
+    graphs = [
+      {
+        definition = builtins.toJSON {
+          requests = [
+            { q = "avg:hydra.queue.steps.active{$host}"; }
+            { q = "avg:hydra.queue.steps.building{$host}"; }
+            { q = "avg:hydra.queue.steps.copying_to{$host}"; }
+            { q = "avg:hydra.queue.steps.copying_from{$host}"; }
+            { q = "avg:hydra.queue.steps.waiting{$host}"; }
+          ];
+          viz = "timeseries";
+        };
+        title = "Active/building steps";
+      }
+      {
+        definition = builtins.toJSON {
+          requests = [
+            { q = "avg:hydra.queue.steps.avg_build_time{$host}"; }
+            { q = "avg:hydra.queue.steps.avg_total_time{$host}"; }
+          ];
+          viz = "timeseries";
+        };
+        title = "Build/total time per step";
+      }
+      {
+        definition = builtins.toJSON {
+          requests = [
+            { q = "avg:hydra.queue.steps.finished{$host}"; }
+            { q = "avg:hydra.queue.builds.finished{$host}"; }
+          ];
+          viz = "timeseries";
+        };
+        title = "Finished builds/steps";
+      }
+      {
+        definition = builtins.toJSON {
+          requests = [
+            { q = "max:system.io.await{$host} by {device}"; type = "area"; }
+          ];
+          viz = "timeseries";
+        };
+        title = "Disk latency (ms, by device)";
+      }
+      {
+        definition = builtins.toJSON {
+          requests = [
+            { q = "avg:hydra.queue.steps.unfinished{$host}"; }
+            { q = "avg:hydra.queue.builds.unfinished{$host}"; }
+            { q = "avg:hydra.queue.steps.runnable{$host}"; }
+          ];
+          viz = "timeseries";
+        };
+        title = "Unfinished builds/steps";
+      }
+      {
+        definition = builtins.toJSON {
+          requests = [
+            { q = "avg:system.load.1{$host}"; }
+            { q = "avg:system.load.5{$host}"; }
+            { q = "avg:system.load.15{$host}"; }
+          ];
+          viz = "timeseries";
+        };
+        title = "Load Averages 1-5-15";
+      }
+      {
+        definition = builtins.toJSON {
+          requests = [
+            { q = "per_hour(ewma_20(avg:hydra.queue.steps.finished{$host}))"; }
+            {
+              q = "per_hour(ewma_20(avg:hydra.queue.builds.finished{$host}))";
+            }
+          ];
+          viz = "timeseries";
+        };
+        title = "Finished builds/steps / hour";
+      }
+      {
+        definition = builtins.toJSON {
+          requests = [ { q = "avg:hydra.mem.dirty{$host}"; } ];
+          viz = "timeseries";
+        };
+        title = "Dirty memory";
+      }
+      {
+        definition = builtins.toJSON {
+          requests = [
+            {
+              aggregator = "avg";
+              conditional_formats = [];
+              q = "avg:system.mem.used{$host}";
+              type = "line";
+            }
+            {
+              conditional_formats = [];
+              q = "avg:system.mem.free{$host}";
+              type = "line";
+            }
+            {
+              conditional_formats = [];
+              q = "avg:system.mem.usable{$host}";
+              type = "line";
+            }
+          ];
+          viz = "timeseries";
+        };
+        title = "Memory usage";
+      }
+      {
+        definition = builtins.toJSON {
+          requests = [
+            { q = "avg:hydra.queue.bytes_sent{$host}"; type = "line"; }
+            { q = "avg:hydra.queue.bytes_received{$host}"; type = "line"; }
+          ];
+          viz = "timeseries";
+        };
+        title = "Stores paths sent/received";
+      }
+      {
+        definition = builtins.toJSON {
+          requests = [
+            { q = "per_minute(ewma_20(avg:hydra.queue.bytes_sent{$host}))"; }
+            {
+              q = "per_minute(ewma_20(avg:hydra.queue.bytes_received{$host}))";
+            }
+          ];
+          viz = "timeseries";
+        };
+        title = "Store paths sent/received (GiB / minute)";
+      }
+      {
+        definition = builtins.toJSON {
+          requests = [
+            { q = "avg:hydra.queue.machines.total{$host}"; type = "line"; }
+            { q = "avg:hydra.queue.machines.in_use{$host}"; type = "line"; }
+          ];
+          viz = "timeseries";
+        };
+        title = "Total and active machines";
+      }
+    ];
+    templateVariables = [
+      {
+        default = "host:${host}";
+        name = "host";
+        prefix = "host";
+      }
+    ];
+    title = "Hydra Status (deployed from nixops)";
+  };
+}

From 964811d385aee00c0f43c9ae16976c0a4e97b630 Mon Sep 17 00:00:00 2001
From: Amine Chikhaoui <amine.chikhaoui91@gmail.com>
Date: Wed, 26 Jul 2017 15:22:18 +0100
Subject: [PATCH 2/6] rename resource

---
 dd-dashboard.nix | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dd-dashboard.nix b/dd-dashboard.nix
index 683449f0..8281bbf7 100644
--- a/dd-dashboard.nix
+++ b/dd-dashboard.nix
@@ -5,7 +5,7 @@
 , ...
 }:
 {
-  resources.datadogTimeboards.dash = {
+  resources.datadogTimeboards.hydra-status = {
     inherit appKey apiKey;
     description = "Hydra build farm status (hydra.nixos.org)";
     graphs = [

From d6f029bf82ad89ed501d1378821eb879a79bef62 Mon Sep 17 00:00:00 2001
From: Amine Chikhaoui <amine.chikhaoui91@gmail.com>
Date: Wed, 26 Jul 2017 15:26:41 +0100
Subject: [PATCH 3/6] remove hydra.nixos.org reference

---
 dd-dashboard.nix | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dd-dashboard.nix b/dd-dashboard.nix
index 8281bbf7..e5ab9243 100644
--- a/dd-dashboard.nix
+++ b/dd-dashboard.nix
@@ -7,7 +7,7 @@
 {
   resources.datadogTimeboards.hydra-status = {
     inherit appKey apiKey;
-    description = "Hydra build farm status (hydra.nixos.org)";
+    description = "Hydra build farm status";
     graphs = [
       {
         definition = builtins.toJSON {

From b9ed08d70338b62bfd47232a3ae3d696db1e4249 Mon Sep 17 00:00:00 2001
From: Amine Chikhaoui <amine.chikhaoui91@gmail.com>
Date: Wed, 26 Jul 2017 16:54:04 +0100
Subject: [PATCH 4/6] move file and add a basic README

---
 datadog/README.md                            | 20 ++++++++++++++++++++
 dd-dashboard.nix => datadog/dd-dashboard.nix |  0
 2 files changed, 20 insertions(+)
 create mode 100644 datadog/README.md
 rename dd-dashboard.nix => datadog/dd-dashboard.nix (100%)

diff --git a/datadog/README.md b/datadog/README.md
new file mode 100644
index 00000000..8bfc0752
--- /dev/null
+++ b/datadog/README.md
@@ -0,0 +1,20 @@
+#Hydra status timeboard
+In order to deploy hydra status dashboard you can:
+
+* create a deployment
+
+```
+nixops create -d hydra-status /path/to/hydra/datadog/dd-dashboard.nix
+```
+
+* setup the default hostname and api/app keys
+
+```
+nixops set-args -d hydra-status --argst appKey <app_key> --argstr apiKey <api_key> --argstr host chef
+```
+
+* deploy
+
+```
+nixops deploy -d hydra-status
+```
diff --git a/dd-dashboard.nix b/datadog/dd-dashboard.nix
similarity index 100%
rename from dd-dashboard.nix
rename to datadog/dd-dashboard.nix

From 20c4655adbc942700b3121cce6976f7b15bf52af Mon Sep 17 00:00:00 2001
From: Amine Chikhaoui <amine.chikhaoui91@gmail.com>
Date: Wed, 26 Jul 2017 16:55:07 +0100
Subject: [PATCH 5/6] fix style

---
 datadog/README.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/datadog/README.md b/datadog/README.md
index 8bfc0752..3b3ce404 100644
--- a/datadog/README.md
+++ b/datadog/README.md
@@ -1,4 +1,5 @@
 #Hydra status timeboard
+
 In order to deploy hydra status dashboard you can:
 
 * create a deployment

From c0fb091fe30a6e9dd8a6a08d6a159b48a7fa99af Mon Sep 17 00:00:00 2001
From: Amine Chikhaoui <amine.chikhaoui91@gmail.com>
Date: Wed, 26 Jul 2017 16:56:16 +0100
Subject: [PATCH 6/6] add space

---
 datadog/README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/datadog/README.md b/datadog/README.md
index 3b3ce404..49634fb4 100644
--- a/datadog/README.md
+++ b/datadog/README.md
@@ -1,4 +1,4 @@
-#Hydra status timeboard
+# Hydra status timeboard
 
 In order to deploy hydra status dashboard you can: