首页 > 解决方案 > GCP 日志指标资源管理器问题

问题描述

我创建了一个非常简单的基于日志的指标来排除错误。以下是来自指标资源管理器的 JSON 视图

使用自定义指标创建的这个向我显示数据

{
  "dataSets": [
    {
      "timeSeriesFilter": {
        "filter": "metric.type=\"logging.googleapis.com/log_entry_count\" resource.type=\"app_script_function\" metric.label.\"severity\"=\"ERROR\"",
        "minAlignmentPeriod": "60s",
        "aggregations": [
          {
            "perSeriesAligner": "ALIGN_RATE",
            "crossSeriesReducer": "REDUCE_NONE",
            "alignmentPeriod": "60s",
            "groupByFields": []
          },
          {
            "crossSeriesReducer": "REDUCE_NONE",
            "alignmentPeriod": "60s"
          }
        ]
      },
      "targetAxis": "Y1",
      "plotType": "LINE"
    }
  ],
  "options": {
    "mode": "COLOR"
  },
  "constantLines": [],
  "timeshiftDuration": "0s",
  "y1Axis": {
    "label": "y1Axis",
    "scale": "LINEAR"
  }
}

使用自定义指标创建的这个不显示同一时间范围内的数据

{
  "dataSets": [
    {
      "timeSeriesFilter": {
        "filter": "metric.type=\"logging.googleapis.com/user/TestApps2\"",
        "minAlignmentPeriod": "60s",
        "aggregations": [
          {
            "perSeriesAligner": "ALIGN_RATE",
            "crossSeriesReducer": "REDUCE_NONE",
            "alignmentPeriod": "60s",
            "groupByFields": []
          },
          {
            "crossSeriesReducer": "REDUCE_NONE",
            "alignmentPeriod": "60s"
          }
        ]
      },
      "targetAxis": "Y1",
      "plotType": "LINE"
    }
  ],
  "options": {
    "mode": "COLOR"
  },
  "constantLines": [],
  "timeshiftDuration": "0s",
  "y1Axis": {
    "label": "y1Axis",
    "scale": "LINEAR"
  }
}

自定义指标 TestApps2 包含以下附加过滤器:

severity="ERROR"
resource.type="app_script_function"

请注意,在指标创建过程中,上面确实显示了预览日志中的日志。我必须使用自定义指标来添加标签并将其注入电子邮件中。

自定义指标视图失败的可能原因是什么?

标签: google-cloud-platformgoogle-cloud-logginggoogle-cloud-monitoring

解决方案


推荐阅读