 (defn- label-metrics
   "Get metrics based on labels"
   []
-  (let [labels (db/select 'CardLabel)]
+  (let [labels (db/select 'Label)
+        cardlabels (db/select ['CardLabel :card_id :label_id])]
     {:labels (count labels)
-     :num_labels_per_card (micro-histogram labels :card_id)
-     :num_cards_per_label (medium-histogram labels :label_id)}))
+     :num_labels_per_card (micro-histogram cardlabels :card_id)
+     :num_cards_per_label (medium-histogram cardlabels :label_id)}))
+
+
+(defn collection-metrics
+  "Get metrics on collection usage"
+  []
+  (let [collections (db/select 'Collection)
+        cards (db/select ['Card :collection_id])]
+    {:collections (count collections)
+     :num_cards_per_collection (medium-histogram cards :collection_id)}
+    )
+  )
 
 ;; Metadata Metrics
 (defn- database-dims

  "Get metrics based on questions
  TODO characterize by # executions and avg latency"
  []
  (let [questions (db/select 'Card)]
    {:questions (apply add-summaries (map question-dims questions))}))

(defn- dashboard-metrics
  "Get metrics based on dashboards
  TODO characterize by # of revisions, and created by an admin"
  []
  (let [dashboards (db/select 'Dashboard)
        dashcards (db/select 'DashboardCard)]
    {:dashboards (count dashboards)
     :num_dashs_per_user (medium-histogram dashboards :creator_id)
     :num_cards_per_dash (medium-histogram dashcards :dashboard_id)

(defn- field-metrics
  "Get metrics based on fields"
  []
  (let [fields (db/select ['Field :id :table_id])]
    {:fields (count fields)
     :num_per_table (medium-histogram fields :table_id)}))

(defn- segment-metrics
  "Get metrics based on segments"
  []
  (let [segments (db/select ['Segment :id])]
    {:segments (count segments)}))


(defn- metric-metrics
  "Get metrics based on metrics"
  []
  (let [metrics (db/select ['Metric :id])]
    {:metrics (count metrics)}))


