无法使用基于日志的指标(指标类型:"Counter")显示数据
Can't display data with with log-based metric (metric type: "Counter")
我正在努力创建一个带有基于日志指标的 Stackdriver 监控图表。我的指标是默认没有单位的计数器。
日志可用于我基于日志的指标,但是当我使用我的指标创建图表时,它显示 no data is available for the...
.
这是我的指标,它确实有效(称为 isOperatorAllowed):
resource.type="container"
resource.labels.namespace_id="default"
jsonPayload.message="CaseForOperator flags"
logName="projects/PROJECT-ID/logs/app"
jsonPayload.caseForOperatorFlags.isOperatorAllowed=true
这是我的JSON图表配置
{
"dataSets": [
{
"timeSeriesFilter": {
"filter": "metric.type=\"logging.googleapis.com/user/IsOperatorAllowed\" resource.type=\"gke_container\"",
"perSeriesAligner": "ALIGN_RATE",
"crossSeriesReducer": "REDUCE_NONE",
"secondaryCrossSeriesReducer": "REDUCE_NONE",
"minAlignmentPeriod": "60s",
"groupByFields": [],
"unitOverride": "1"
},
"targetAxis": "Y1",
"plotType": "LINE"
}
],
"options": {
"mode": "COLOR"
},
"constantLines": [],
"timeshiftDuration": "0s",
"y1Axis": {
"label": "y1Axis",
"scale": "LINEAR"
}
}
有人知道我做错了什么吗?
经过讨论和帮助,答案是:
基于日志的指标在创建后仅采用日志。因此,如果您的日志早于指标创建时间戳,它们将不会出现在指标中 count/distribution
示例:
Metric: `03/06/2020 15:55:33`
log 1: `02/06/2020 12:00:00`
log 2: `07/06/2020 12:00:00`
Metric count result: 1 (it will be the log 2)
这里说的是 documentation:
New log entries might not match your metric's logs query. A logs-based metric gets data from matching log entries that are received after the metric is created. Logging does not backfill the metric from previous log entries.
我正在努力创建一个带有基于日志指标的 Stackdriver 监控图表。我的指标是默认没有单位的计数器。
日志可用于我基于日志的指标,但是当我使用我的指标创建图表时,它显示 no data is available for the...
.
这是我的指标,它确实有效(称为 isOperatorAllowed):
resource.type="container"
resource.labels.namespace_id="default"
jsonPayload.message="CaseForOperator flags"
logName="projects/PROJECT-ID/logs/app"
jsonPayload.caseForOperatorFlags.isOperatorAllowed=true
这是我的JSON图表配置
{
"dataSets": [
{
"timeSeriesFilter": {
"filter": "metric.type=\"logging.googleapis.com/user/IsOperatorAllowed\" resource.type=\"gke_container\"",
"perSeriesAligner": "ALIGN_RATE",
"crossSeriesReducer": "REDUCE_NONE",
"secondaryCrossSeriesReducer": "REDUCE_NONE",
"minAlignmentPeriod": "60s",
"groupByFields": [],
"unitOverride": "1"
},
"targetAxis": "Y1",
"plotType": "LINE"
}
],
"options": {
"mode": "COLOR"
},
"constantLines": [],
"timeshiftDuration": "0s",
"y1Axis": {
"label": "y1Axis",
"scale": "LINEAR"
}
}
有人知道我做错了什么吗?
经过讨论和帮助,答案是:
基于日志的指标在创建后仅采用日志。因此,如果您的日志早于指标创建时间戳,它们将不会出现在指标中 count/distribution
示例:
Metric: `03/06/2020 15:55:33`
log 1: `02/06/2020 12:00:00`
log 2: `07/06/2020 12:00:00`
Metric count result: 1 (it will be the log 2)
这里说的是 documentation:
New log entries might not match your metric's logs query. A logs-based metric gets data from matching log entries that are received after the metric is created. Logging does not backfill the metric from previous log entries.