Cloud Storage FUSE 指标

本页面简要介绍了 Cloud Storage FUSE 的指标,以及如何收集、导出和分析指标数据。

概览

当您使用 Cloud Storage FUSE 将存储桶装载到 Cloud Storage 作为文件系统时,Cloud Storage 会为 Cloud Storage FUSE 提供深入的指标。指标可帮助您持续监控性能,识别可能会影响吞吐量和延迟时间的潜在瓶颈,并在问题出现时快速解决。

出于诊断目的,您可以在使用 Cloud Storage FUSE 时在后台收集指标。Cloud Storage 提供两种收集、导出和分析指标的方法:

  • Cloud Monitoring 指标导出器:指标直接从 Cloud Storage FUSE 收集并导出到 Cloud Monitoring。然后,您可以在 Google Cloud 控制台中查看导出的指标。

  • Prometheus 端口:使用 Prometheus 开源监控和提醒工具包,以 Prometheus 指标基于文本的格式在指定的 Prometheus 端口(例如 http://Host:prometheus-port/metrics)导出指标。然后,可以使用客户端网址(例如 curl http://host:port/metrics)将指标作为输出进行查看

价格

Cloud Storage FUSE 指标的费用取决于您的用量。如需详细了解价格,请参阅 Google Cloud Observability 价格

使用 Cloud Monitoring 导出器

如需使用 Cloud Monitoring 导出器将指标从 Cloud Storage FUSE 导出、收集和分析到 Cloud Monitoring,您必须完成以下各部分中概述的步骤。

获取所需角色

如需获得使用 Cloud Monitoring 指标导出器所需的权限,请在要收集指标的项目中授予 Monitoring Metric Writer (roles/monitoring.metricWriter) IAM 角色。

此预定义角色包含使用 Cloud Monitoring 指标导出器所需的权限。如需详细了解 Monitoring Metric Writer 角色,请参阅有关 roles/monitoring.metricWriter 的 IAM 文档

如需了解如何授予项目角色,请参阅管理对项目的访问权限

准备工作

  1. 启用 Cloud Monitoring API

  2. 启用 Cloud Storage API。

    前往 Cloud Storage API

设置 Cloud Monitoring 导出器

如需设置 Cloud Monitoring 导出器来收集、导出和分析 Cloud Storage FUSE 指标,请使用 Cloud Storage FUSE 配置文件或 Cloud Storage FUSE CLI 通过 metrics:cloud-metrics-export-interval-secs 配置字段或 --cloud-metrics-export-interval-secs 指定一个以秒为单位的整数值。

使用 Google Cloud 控制台查看指标

如需使用 Google Cloud 控制台查看 Cloud Storage FUSE 指标,请按照以下说明操作:

  1. 在 Google Cloud 控制台中,前往 Metrics Explorer 页面。

    转到 Metrics Explorer

  2. 选择要查看指标的项目。

  3. 指标下拉菜单中,点击选择指标

  4. 选择虚拟机实例,然后点击自定义并输入要查看的指标的名称。如需查看 Cloud Storage 为 Cloud Storage FUSE 提供的指标,请参阅可用指标

使用 Prometheus 导出、收集和分析指标

以下部分介绍了如何配置和使用 Prometheus 来导出、收集和分析 Cloud Storage FUSE 指标。

配置 Prometheus

如需配置 Prometheus,请按照为 Ops Agent 配置 Prometheus 中的说明操作。

使用 Prometheus

  1. 使用 Cloud Storage FUSE CLI,通过 Cloud Storage FUSE 配置文件中的 prometheus-port 配置选项或 --prometheus-port CLI 选项指定要将指标导出到的 HTTP 端口。

  2. 使用以下命令验证 Prometheus 指标端点:

     curl https://localhost:8080/metrics

    如果成功,该命令会返回包含如下所示的文本的输出:

     # HELP file_cache_read_bytes_count The cumulative number of bytes read from file cache along with read type - Sequential/Random
     # TYPE file_cache_read_bytes_count counter
     file_cache_read_bytes_count{read_type="Random"} 0
     file_cache_read_bytes_count{read_type="Sequential"} 80
     # HELP file_cache_read_count Specifies the number of read requests made via file cache along with type - Sequential/Random and cache hit - true/false
     # TYPE file_cache_read_count counter
     file_cache_read_count{cache_hit="false",read_type="Random"} 215
     file_cache_read_count{cache_hit="false",read_type="Sequential"} 5
     # HELP file_cache_read_latencies The cumulative distribution of the file cache read latencies along with cache hit - true/false
     # TYPE file_cache_read_latencies histogram
     file_cache_read_latencies_bucket{cache_hit="false",le="1"} 215
     file_cache_read_latencies_bucket{cache_hit="false",le="2"} 216
     file_cache_read_latencies_bucket{cache_hit="false",le="3"} 216
     file_cache_read_latencies_bucket{cache_hit="false",le="4"} 216
     file_cache_read_latencies_bucket{cache_hit="false",le="5"} 216
     ...
     file_cache_read_latencies_sum{cache_hit="false"} 483.62783500000023
     file_cache_read_latencies_count{cache_hit="false"} 220
     # HELP fs_ops_count The cumulative number of ops processed by the file system.
     # TYPE fs_ops_count counter
     fs_ops_count{fs_op="FlushFile"} 9
     fs_ops_count{fs_op="GetInodeAttributes"} 91
     fs_ops_count{fs_op="LookUpInode"} 584
     fs_ops_count{fs_op="OpenDir"} 122
     fs_ops_count{fs_op="OpenFile"} 9
     fs_ops_count{fs_op="ReadDir"} 184
     fs_ops_count{fs_op="ReadFile"} 220
     fs_ops_count{fs_op="ReleaseDirHandle"} 122
     fs_ops_count{fs_op="ReleaseFileHandle"} 9
     fs_ops_count{fs_op="StatFS"} 10
     # HELP fs_ops_error_count The cumulative number of errors generated by file system operations
     # TYPE fs_ops_error_count counter
     fs_ops_error_count{fs_error_category="NOT_IMPLEMENTED",fs_op="GetXattr"} 1
     fs_ops_error_count{fs_error_category="NOT_IMPLEMENTED",fs_op="ListXattr"} 1
     fs_ops_error_count{fs_error_category="INTERRUPT_ERROR",fs_op="LookUpInode"} 58
     fs_ops_error_count{fs_error_category="NO_FILE_OR_DIR",fs_op="LookUpInode"} 6
     # HELP fs_ops_latency The cumulative distribution of file system operation latencies
     # TYPE fs_ops_latency histogram
     fs_ops_latency_bucket{fs_op="FlushFile",le="1"} 9
     fs_ops_latency_bucket{fs_op="FlushFile",le="2"} 9
     fs_ops_latency_bucket{fs_op="FlushFile",le="3"} 9
     fs_ops_latency_bucket{fs_op="FlushFile",le="4"} 9
     fs_ops_latency_bucket{fs_op="FlushFile",le="5"} 9
     ...
     fs_ops_latency_sum{fs_op="FlushFile"} 0.28800000000000003
     fs_ops_latency_count{fs_op="FlushFile"} 9
     # HELP gcs_download_bytes_count The cumulative number of bytes downloaded from GCS along with type - Sequential/Random
     # TYPE gcs_download_bytes_count counter
     gcs_download_bytes_count{read_type="Sequential"} 2.0971528e+08
     # HELP gcs_read_count Specifies the number of gcs reads made along with type - Sequential/Random
     # TYPE gcs_read_count counter
     gcs_read_count{read_type="Sequential"} 5
     ```

可用指标

Cloud Storage FUSE 提供以下指标。

文件系统指标

文件系统指标可让您深入了解对已挂载的存储桶执行的操作,例如延迟时间和错误率。

指标名称 指标说明
fs/ops_count 文件系统处理的操作数。此指标允许按 op_type 分组,以获取各个操作的计数。
fs/ops_error_count 文件系统操作生成的错误数。 此指标可按 op_typeerror_category 分组。每个错误都以多对一的关系映射到 error_category
fs/ops_latency 文件系统操作延迟时间的累积分布。 此指标可按 op_type 分组。

Cloud Storage 指标

Cloud Storage 指标可让您深入了解 Cloud Storage FUSE 与 Cloud Storage 之间的互动。

指标名称 指标说明
gcs/download_bytes_count 从 Cloud Storage 下载的字节数以及读取类型。读取类型指定顺序读取、随机读取或并行读取。
gcs/read_bytes_count 从 Cloud Storage 对象读取的字节数,不同于 download_bytes_count。例如,从 Cloud Storage 中提取的数据多于应用实际使用的数据。
gcs/read_count 从 Cloud Storage 读取的次数和读取类型(顺序、随机或并行)。
gcs/reader_count 已打开或关闭的 Cloud Storage 对象读取器的数量。此指标的数据按输入/输出 (I/O) 方法类型(例如 openedclosed)分组。
gcs/request_count 已处理的 Cloud Storage 请求数。
gcs/request_latencies Cloud Storage 请求延迟时间的总体分布情况。
gcs/retry_count 向 Cloud Storage 发出的重试请求数。 此指标可按 retry_error_category 分组,该参数用于指定触发重试的错误类别。

文件缓存指标

文件缓存指标可让您深入了解 Cloud Storage FUSE 文件缓存操作的性能和行为。

指标名称 指标说明
file_cache/read_bytes_count 从文件缓存读取的字节数和读取类型(顺序或随机)。
file_cache/read_latencies 文件缓存读取延迟时间和缓存命中(true 或 false)的总分布情况。
file_cache/read_count 使用文件缓存发出的读取请求数、请求类型(例如顺序或随机)以及缓存命中(true 或 false)。

后续步骤