[local_storage] Add new space usage metrics

Adds metrics for {bytes, inodes} {used, allocated}, as well as
corresponding reports.  The reports are per-device per-day maximum value
percentiles (e.g. N% of devices reported a max value of X bytes / Y
inodes on this day), which is slightly less useful than histograms but
requires less maintenance (since histograms need explicit pre-defined
buckets, which will vary depending on the disk size).

Note that some of these already exist (e.g. total_inodes) but they're
only used/populated on blobfs and it would be complicated to change the
code to prevent blobfs from logging twice when adding logging for these
new metrics, so the simplest thing to do was just to add new replacement
metrics altogether.

Change-Id: I9a449649b6318def323d931296ff896ddcbc35ec
Reviewed-on: https://fuchsia-review.googlesource.com/c/cobalt-registry/+/584043
Commit-Queue: James Sullivan <jfsulliv@google.com>
Reviewed-by: Cameron Dale <camrdale@google.com>
Reviewed-by: Brett Wilson <brettw@google.com>
Privacy-Approval: Cameron Dale <camrdale@google.com>
diff --git a/fuchsia/local_storage/metrics.yaml b/fuchsia/local_storage/metrics.yaml
index 76da08f..b60e4a0 100644
--- a/fuchsia/local_storage/metrics.yaml
+++ b/fuchsia/local_storage/metrics.yaml
@@ -2084,6 +2084,200 @@
 
 ################################################################################
 
+# Space Metrics
+# Reserved Range: [4000, 5000)
+
+################################################################################
+# Data Bytes Used
+#
+# Used to track the number of bytes a partition is using for storing data.
+# This is generally updated on a regular interval via Lapis, which queries
+# filesystem information from fshost.
+################################################################################
+- id: 4000
+  replacement_metric_id: 4001
+  metric_name: data_bytes_used
+  # Current version of cobalt doesn't support logging an integer sample.
+  # The closest is |MEMORY_USAGE|, which will be mapped to |INTEGER| once
+  # Cobalt 1.1 is released.
+  metric_type: MEMORY_USAGE
+  metric_dimensions: &space_dimensions
+    - *source_dimension
+  reports:
+    - report_name: per_device_daily_max
+      id: 1
+      report_type: PER_DEVICE_NUMERIC_STATS
+      aggregation_type: MAX
+      window_size:
+        - 1
+      system_profile_field: [BOARD_NAME, PRODUCT_NAME, SYSTEM_VERSION, CHANNEL]
+
+  meta_data:
+    max_release_stage: GA
+    expiration_date: "2022/09/21"
+
+- id: 4001
+  metric_name: data_bytes_used_migrated
+  metric_type: INTEGER
+  metric_units: BYTES
+  metric_semantics: [USAGE_COUNTING]
+  metric_dimensions: *space_dimensions
+  reports:
+    - report_name: per_device_daily_max
+      id: 1
+      report_type: UNIQUE_DEVICE_NUMERIC_STATS
+      local_aggregation_procedure: MAX_PROCEDURE
+      local_aggregation_period: WINDOW_1_DAY
+      privacy_level: NO_ADDED_PRIVACY
+      system_profile_field: [BOARD_NAME, PRODUCT_NAME, SYSTEM_VERSION, CHANNEL]
+  meta_data:
+    max_release_stage: GA
+    expiration_date: "2022/09/21"
+
+################################################################################
+# Data Bytes Allocated
+#
+# Used to track the number of bytes a partition has allocated (free + used) for
+# storing data.
+# This is generally updated on a regular interval via Lapis, which queries
+# filesystem information from fshost.
+################################################################################
+- id: 4002
+  replacement_metric_id: 4003
+  metric_name: data_bytes_allocated
+  # Current version of cobalt doesn't support logging an integer sample.
+  # The closest is |MEMORY_USAGE|, which will be mapped to |INTEGER| once
+  # Cobalt 1.1 is released.
+  metric_type: MEMORY_USAGE
+  metric_dimensions: *space_dimensions
+  reports:
+    - report_name: per_device_daily_max
+      id: 1
+      report_type: PER_DEVICE_NUMERIC_STATS
+      aggregation_type: MAX
+      window_size:
+        - 1
+      system_profile_field: [BOARD_NAME, PRODUCT_NAME, SYSTEM_VERSION, CHANNEL]
+
+  meta_data:
+    max_release_stage: GA
+    expiration_date: "2022/09/21"
+
+- id: 4003
+  metric_name: data_bytes_allocated_migrated
+  metric_type: INTEGER
+  metric_units: BYTES
+  metric_semantics: [USAGE_COUNTING]
+  metric_dimensions: *space_dimensions
+  reports:
+    - report_name: per_device_daily_max
+      id: 1
+      report_type: UNIQUE_DEVICE_NUMERIC_STATS
+      local_aggregation_procedure: MAX_PROCEDURE
+      local_aggregation_period: WINDOW_1_DAY
+      privacy_level: NO_ADDED_PRIVACY
+      system_profile_field: [BOARD_NAME, PRODUCT_NAME, SYSTEM_VERSION, CHANNEL]
+  meta_data:
+    max_release_stage: GA
+    expiration_date: "2022/09/21"
+
+################################################################################
+# Inodes Used
+#
+# Used to track the number of inodes a partition has in use.
+# This is generally updated on a regular interval via Lapis, which queries
+# filesystem information from fshost.
+################################################################################
+- id: 4004
+  replacement_metric_id: 4005
+  metric_name: inodes_used
+  # Current version of cobalt doesn't support logging an integer sample.
+  # The closest is |MEMORY_USAGE|, which will be mapped to |INTEGER| once
+  # Cobalt 1.1 is released.
+  metric_type: MEMORY_USAGE
+  metric_dimensions: &space_dimensions
+    - *source_dimension
+  reports:
+    - report_name: per_device_daily_max
+      id: 1
+      report_type: PER_DEVICE_NUMERIC_STATS
+      aggregation_type: MAX
+      window_size:
+        - 1
+      system_profile_field: [BOARD_NAME, PRODUCT_NAME, SYSTEM_VERSION, CHANNEL]
+
+  meta_data:
+    max_release_stage: GA
+    expiration_date: "2022/09/21"
+
+- id: 4005
+  metric_name: inodes_used_migrated
+  metric_type: INTEGER
+  metric_units_other: "inodes"
+  metric_semantics: [USAGE_COUNTING]
+  metric_dimensions: *space_dimensions
+  reports:
+    - report_name: per_device_daily_max
+      id: 1
+      report_type: UNIQUE_DEVICE_NUMERIC_STATS
+      local_aggregation_procedure: MAX_PROCEDURE
+      local_aggregation_period: WINDOW_1_DAY
+      privacy_level: NO_ADDED_PRIVACY
+      system_profile_field: [BOARD_NAME, PRODUCT_NAME, SYSTEM_VERSION, CHANNEL]
+  meta_data:
+    max_release_stage: GA
+    expiration_date: "2022/09/21"
+
+################################################################################
+# Inodes Allocated
+#
+# Used to track the number of inodes a partition has capacity for (free + used).
+# This is generally updated on a regular interval via Lapis, which queries
+# filesystem information from fshost.
+################################################################################
+- id: 4006
+  replacement_metric_id: 4007
+  metric_name: inodes_allocated
+  # Current version of cobalt doesn't support logging an integer sample.
+  # The closest is |MEMORY_USAGE|, which will be mapped to |INTEGER| once
+  # Cobalt 1.1 is released.
+  metric_type: MEMORY_USAGE
+  metric_dimensions: *space_dimensions
+  reports:
+    - report_name: per_device_daily_max
+      id: 1
+      report_type: PER_DEVICE_NUMERIC_STATS
+      aggregation_type: MAX
+      window_size:
+        - 1
+      system_profile_field: [BOARD_NAME, PRODUCT_NAME, SYSTEM_VERSION, CHANNEL]
+
+  meta_data:
+    max_release_stage: GA
+    expiration_date: "2022/09/21"
+
+- id: 4007
+  metric_name: inodes_allocated_migrated
+  metric_type: INTEGER
+  metric_units_other: "inodes"
+  metric_semantics: [USAGE_COUNTING]
+  metric_dimensions: *space_dimensions
+  reports:
+    - report_name: per_device_daily_max
+      id: 1
+      report_type: UNIQUE_DEVICE_NUMERIC_STATS
+      local_aggregation_procedure: MAX_PROCEDURE
+      local_aggregation_period: WINDOW_1_DAY
+      privacy_level: NO_ADDED_PRIVACY
+      system_profile_field: [BOARD_NAME, PRODUCT_NAME, SYSTEM_VERSION, CHANNEL]
+  meta_data:
+    max_release_stage: GA
+    expiration_date: "2022/09/21"
+
+# Next ID: 4008
+
+################################################################################
+
 # Temporary Metrics
 # Reserved Range: [9000, 10000)