似乎应该在Kubernetes集群的每个节点(即每个计算实例,即每台机器)上安装Google Monitoring Agent(由Stackdriver提供支持).
然而,新的插件,如Nginx,Redis,ElasticSearch ......,需要这些代理知道这些服务的IP.这意味着kube-proxy运行和设置应该意味着在Pod上运行Google Monitoring Agent.
这两个冲突:一方面,代理监视整个计算机,另一方面监视一台或多台计算机上运行的服务.
这些Stackdriver插件可以在Google Container Engine(GKE)/ Kubernetes集群上运行吗?
google-cloud-platform kubernetes google-kubernetes-engine stackdriver google-cloud-monitoring
我有一个在Kubernetes上的docker镜像中运行Java的项目.日志由流畅的代理自动提取,最终在Stackdriver中.
但是,日志的格式是错误的:多行日志在Stackdriver中被放入单独的日志行中,并且所有日志都具有"INFO"日志级别,即使它们确实是警告或错误.
我一直在搜索有关如何配置logback以输出正确格式以使其正常工作的信息,但我在google Stackdriver或GKE文档中找不到这样的指南.
我的猜测是我应该输出某种形式的JSON,但是我在哪里可以找到关于格式的信息,甚至是如何正确设置这个管道的指南.
谢谢!
我正在使用Google Cloud Functions和模块@ google-cloud/logging-winston.
我的第一个问题是使用此模块属性
labels: {
execution_id: "idHere"
}
Run Code Online (Sandbox Code Playgroud)
不在Stackdriver日志中,就像我使用常规console.log(''); 是否可以将execution_id恢复到日志中?
此外,我可以向日志添加自定义标签,例如用户ID.我正在尝试使我的日志记录过程更容易,因此我可以通过execution_id查看每个API端点请求的流程,并且还能够通过添加用户ID标签查看特定用户的所有日志.
我当前的日志代码是
'use strict'
import * as winston from 'winston';
const Logger = winston.Logger;
const Console = winston.transports.Console;
import { LoggingWinston } from '@google-cloud/logging-winston'
const loggingWinston = new LoggingWinston();
const logger = new Logger({
level: 'debug', // log at 'debug' and above
transports: [
// Log to the console
new Console(),
// And log to Stackdriver Logging
loggingWinston,
],
});
function formatMessage(message) {
return message;
};
export const …Run Code Online (Sandbox Code Playgroud) logging google-cloud-platform google-cloud-functions stackdriver
tldr:
- 我正在写一个运行在Google Cloud之外的python应用程序的日志
- 我正在使用gcplogs将日志导入到Stackdriver - 导入的日志
必须是错误的格式,因为它们不会在Stackdriver日志记录中显示
我很难搞清楚如何配置gcplogs Docker日志驱动程序,以便在Stackdriver日志记录中显示日志.这是日志目前的样子:

看起来stackdriver没有正确解析这些日志.但是,如果在GKE中运行docker镜像,则日志看起来正确:
这里Stackdriver已经认识到这些日志是调试消息.
由于这两个应用程序使用相同的记录器,我认为从应用程序记录的消息格式正确,并且必须是错误或缺少某些内容的gcplogs配置.(有关python代码的信息,请参阅此存储库:https://github.com/cognitedata/python-logs-export-docker-gcplogs-test)
这是/etc/docker/daemon.json运行Docker镜像的机器上的内容:
{
"log-driver": "gcplogs",
"log-opts": {
"gcp-project": "removed",
"env": "host"
}
}
Run Code Online (Sandbox Code Playgroud)
输出docker info | grep 'Logging Driver'是Logging Driver: gcplogs.
输出docker version是:
Client:
Version: 18.03.0-ce
API version: 1.37
Go version: go1.9.2
Git commit: 0520e24
Built: Wed Mar 21 23:05:52 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.0-ce
API …Run Code Online (Sandbox Code Playgroud) 已配置的Google Stackdriver登录其中一个GCE VM,一切正常,但日志级别除外.在文件中使用了参数log_level
/etc/google-fluentd/config.d/tomcat.conf
按照http://docs.fluentd.org/articles/in_tail中的规定, 但即使这样,在Console Log Viewer中也无法查看不同级别的日志.有没有特定的方法为Google Cloud配置流畅的代理?
google-compute-engine fluentd google-cloud-platform stackdriver
是否可以计算GCP Stackdriver日志记录在特定时间段内特定日志消息出现的次数?回答问题“此时间段内此事件发生了多少次”。基本上,我想要下表中曲线的积分。
它不必是一个移动的窗口,这一次它是一次性任务。如果可以的话,高级日志查询中的计数汇总器或类似工具也可以使用。
查询如下所示:
(resource.type="container"
logName="projects/xyz-142842/logs/drs"
"Publish Message for updated entity"
) AND (timestamp>="2018-04-25T06:20:53Z" timestamp<="2018-04-26T06:20:53Z")
Run Code Online (Sandbox Code Playgroud)
google-bigquery google-cloud-console google-cloud-platform stackdriver
我最近意识到我为我的日志付出了太多:
正如您所看到的,我今天刚刚对摄取设置了“限制”。希望这会减慢速度。
但据我所知,我的日志变得如此之大,以至于我每个月都必须为它们的保留付费。我不知道如何:a) 删除某个时期(或全部)的日志 b) 使日志在 x 天后自动删除
logging google-app-engine google-cloud-platform stackdriver google-cloud-stackdriver
我想从我的应用引擎标准 python3 应用程序向堆栈驱动程序日志发送更具表现力的日志条目。通过遵循官方文档,我能够将我的日志发送到 stackdriver,并且时间戳似乎被正确解析。
但我错过了严重程度。此外,我看不到将某个请求的日志链接到操作的方法。java日志记录似乎是开箱即用的。
供参考,这是我的代码:
import logging
import os
from flask import Flask
from google.cloud import logging as glog
app = Flask(__name__)
log_client = glog.Client(os.getenv('GOOGLE_CLOUD_PROJECT'))
# Attaches a Google Stackdriver logging handler to the root logger
log_client.setup_logging()
@app.route('/_ah/push-handlers/cloudbuild', methods=['POST'])
def pubsub_push_handle():
logging.info("stdlib info")
logging.warning("stdlib warn")
logging.error("stdlib error")
Run Code Online (Sandbox Code Playgroud)
导致堆栈驱动程序的日志:
如您所见,时间戳和消息可用,而严重性奇怪地缺失,它被归类为“任何”
有人可以指出我正确的方向,还是这种级别的合并尚不可用?
谢谢你的时间!卡斯腾
google-app-engine python-3.x google-cloud-platform stackdriver google-cloud-stackdriver
我正在 Google Cloud Platform 中运行 Spring Boot 应用程序,并通过 Google Platform Logs Viewer 查看日志文件。在使用 Spring Boot 并仅使用简单的 servlet 之前,日志记录条目将显示为:
每个请求都会被分组,并且可以通过展开行来查看该请求的所有日志记录信息。然而,当使用 Spring Boot 时,请求不再分组,日志条目只是逐行显示。当存在多个请求时,日志条目会变得非常混乱,因为无法以分组方式查看它们。我以同样的方式设置了logging.properties:
.level = INFO
handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=FINEST
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format = [%1$tc] %4$s: %2$s - %5$s %6$s%n
Run Code Online (Sandbox Code Playgroud)
记录器在每个类中初始化为:
private static final java.util.logging.Logger LOG = java.util.logging.Logger.getLogger(MyClass.class.getName());
Run Code Online (Sandbox Code Playgroud)
然后日志记录 API 用作: LOG.info("My Message");
我不明白为什么这些语句以不同的方式记录并且不再分组,但它必须与 Spring Boot 处理日志记录的方式有某种关系?
我正在尝试将2.2.6.RELEASE在 GCP 计算引擎中运行的spring boot( ) 应用程序的指标发布到 stackdriver。我添加了micrometer-registry-stackdriver:1.3.6and的依赖spring-boot-actuator。Stackdriver 指标客户端配置按照micrometer 链接中的说明完成。在 VM 中,我安装了此处提到的云监控代理。
运行应用程序时,我收到错误 io.grpc.StatusRuntimeException: INTERNAL: An internal error occurred.
如果我缺少任何其他配置,有人可以通知我吗?
2020-04-29 10:19:16.248 INFO 14905 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3608
ms
2020-04-29 10:19:18.085 INFO 14905 --- [ main] i.m.s.StackdriverMeterRegistry : publishing metrics to stackdriver every 1m
2020-04-29 10:19:20.058 INFO 14905 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-04-29 10:19:20.735 INFO 14905 --- [ main] o.s.b.a.e.web.EndpointLinksResolver …Run Code Online (Sandbox Code Playgroud) spring-boot-actuator stackdriver google-cloud-stackdriver micrometer spring-micrometer
stackdriver ×10
kubernetes ×2
logging ×2
fluentd ×1
java ×1
logback ×1
micrometer ×1
python-3.x ×1