从 OVH VPS 将 nginx 日志发送到 google 云日志记录
我有一个 OVH VPS,上面设置了 nginx 服务器。我正在寻找一种将 nginx 访问和错误日志发送到 Google Cloud Logging 服务的方法,但我能找到的所有信息都是关于从 Google Cloud VM 发送日志的。此时此刻还有可能吗?我也尝试过寻找有关将系统日志发送到 GCP 的解决方法,但也没有成功。由于我的 dotnet 服务成功将日志发送到 GCP,我认为这应该是可能的。有什么建议吗?
I have an OVH VPS with nginx server setup on it. I'm looking for a way to send nginx access and error logs to Google Cloud Logging service, but all info I could find was about sending logs from Google Cloud VMs. Is it even possible at this moment? I've tried also to find anything about sending syslog to GCP as a workaround but no luck too. Since my dotnet services succesfully send logs to GCP I suppose it should be possible. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 GCP 中,与 NGINX 集成以收集连接指标和访问日志。在开始从 NGINX 收集日志之前,您需要满足一些先决条件。
您必须在您的实例中安装 Ops Agent。 Ops Agent 收集 Compute Engine 实例上的日志和指标,将您的日志发送到 Cloud Logging,将指标发送到 Cloud Monitoring。如果您在 Linux SO 上使用单个 VM,则可以使用以下命令安装代理:
curl -sSO
https://dl.google.com/cloudagents/add-google-cloud-ops-agent-repo.sh
sudo bash add-google-cloud-ops-agent-repo.sh
--also-install
你可以请参阅有关 Ops Agent 安装的详细信息链接
您需要配置您的NGINX实例启用nginx配置文件中的stub_status模块来设置本地可访问的URL,如下例所示:
<前><代码> http://www.example.com/status
如果您没有启用 Stub_status 模块,则可以运行以下命令来启用它:
请注意:127.0.0.1可以替换为真实的服务器名称,例如server_name mynginx.domain.com。
以下链接,它是在开始从 NGINX 部署收集日志之前设置所有先决条件的指南。另外,还有一个配置部署的示例
In GCP there is an integration with NGINX to collect connection metrics and access logs. There are some prerequisites that you need to accomplish before you start collecting logs from NGINX.
You must install Ops Agent in your instance . The Ops Agent collects logs and metrics on Compute Engine instances, sending your logs to Cloud Logging and your metrics to Cloud Monitoring. If you are using a single VM on a Linux SO, you can install the agent with the following command:
curl -sSO
https://dl.google.com/cloudagents/add-google-cloud-ops-agent-repo.sh
sudo bash add-google-cloud-ops-agent-repo.sh
--also-install
You can consult the details about the Ops Agent installation on this link
You will need to configure your NGINX instance enabling the stub_status module in the nginx configuration file to set up a locally reachable URL, like the following example:
If you don't have the stub_status module enabled, you can run the following command to enable it:
Please note that: 127.0.0.1 can be replaced with the real server name, for example, server_name mynginx.domain.com.
All these steps are detailed in the following link, it is a guide to setup all the prerequisites before you start collecting logs from your NGINX deployment. Also, there is an example to configure your deployment