无法使用基于日志的指标显示数据 [英] Can't display data with with log-based metric
问题描述
我正在努力创建带有基于日志指标的具有堆栈驱动器监视功能的图表。我的指标是默认情况下没有单位的计数器。
日志可用于基于日志的指标,但是当我使用指标创建图表时,它说无可用数据...
。
这是我有效的指标(称为isOperatorAllowed):
I’m struggling to create a chart with stackdriver monitoring with a log-based metric. My metric is a counter one with no unit by default.
Logs are available for my log-based metric but when I create a chart with my metric, it says no data is available for the...
.
Here’s my metric which does work (called isOperatorAllowed):
resource.type="container"
resource.labels.namespace_id="default"
jsonPayload.message="CaseForOperator flags"
logName="projects/PROJECT-ID/logs/app"
jsonPayload.caseForOperatorFlags.isOperatorAllowed=true
这是我的JSON配置我的图表
And here’s my JSON config of my chart
{
"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"
}
}
有人知道我在做什么错吗?
Does someone know what I’m doing wrong?
推荐答案
经过讨论和帮助,答案是:
基于日志的度量标准在创建后仅接受日志。因此,如果您的日志早于度量标准创建时间戳记,则它们将不会显示在度量标准计数/分布中
示例:
After discussions and helps, the answer is:
the logs-based metric takes only logs after its creation. So if your logs are older than the metric creation timestamp, they won't appear in the metric count/distribution
Example:
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)
这是文档:
新日志条目可能与指标的日志查询不匹配。基于日志的度量标准从创建度量标准后接收到的匹配日志条目中获取数据。日志记录不会从以前的日志条目回填指标。
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.
这篇关于无法使用基于日志的指标显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!