Search code examples
google-cloud-storagegoogle-cloud-monitoring

Object count for GCS bucket subdirectory on monitoring dashboard


I'm wondering whether I can create charts for 'Object count' of a sub directory within a GCS bucket. Ideally, I'd like to use the 'Group by' option. This doesn't seem to be possible. Is there an alternative way where I could create a chart for 'Object count' for a bucket sub directory?


Solution

  • The metric for the object count in Google Monitoring is defined as:

    Total number of objects per bucket, grouped by storage class. [...]

    So, if you want to create a metric that counts the number of objects in a sub-folder of a bucket you could:

    List item

    1. Create a Custom Metric
    2. Create a script that list and count the objects
    3. Write the data in the Custom Metric
    4. Once you do it you can create a chart with the information.