简体   繁体   English

LogDNA 和云代工 nodejs 应用程序

[英]LogDNA and cloud foundry nodejs apps

I run a couple of nodejs APPS in cloud foundry on IBM cloud.我在 IBM 云上的 Cloud Foundry 中运行了几个 nodejs 应用程序。 I wanted to integrate all this in logDNA so I setup a logDNA instance.我想将所有这些都集成到 logDNA 中,所以我设置了一个 logDNA 实例。

1 - I did NOT configure any source as is described in the help (adding agents etc). 1 - 我没有按照帮助中的描述配置任何源(添加代理等)。 Still logs started to appear from my cloudant services and my nodejs Apps.我的 cloudant 服务和我的 nodejs 应用程序仍然开始出现日志。 System logs apparently.显然是系统日志。 Wondering why... Is the agent by default in the buildpack or something like this?想知道为什么......默认情况下代理是在 buildpack 中还是类似的东西?

2 - Now I also wanted to add nodejs APP logs. 2 - 现在我还想添加nodejs APP日志。 So I followed: https://github.com/logdna/nodejs and added the following code in my app:所以我跟着: https://github.com/logdna/nodejs并在我的应用程序中添加了以下代码:

var Logger = require('logdna');
var options = {
    //hostname: ,
    //logdna_url: "https://logs.eu-de.logging.cloud.ibm.com",
    //mac: macAddress,
    //env: "Development"

};
const apikey = "MY KEY"; //my REAL key ;-)
var logger = Logger.createLogger(apikey, options);
logger.log('Starting APP');

But I never got any APP logs in the logdna instance.但是我从来没有在 logdna 实例中得到任何 APP 日志。 Only the platform logs.只有平台日志。 I tried many different options, never got it to work.我尝试了许多不同的选择,但从未成功过。

Any idea anyone?有人知道吗?

My understanding is that you don't need any LogDNA-specific in your code.我的理解是您的代码中不需要任何特定于 LogDNA 的内容。 You use the regular Cloud Foundry app logging.您使用常规的 Cloud Foundry 应用程序日志记录。 With the app in place, you would configure " syslog drain ".应用程序就位后,您将配置“ syslog drain ”。 Follow the instructions how to configure Log Analysis with LogDNA for Cloud Foundry apps .按照说明如何使用 LogDNA 为 Cloud Foundry 应用程序配置 Log Analysis There are roughly 3 steps involved, including setting up a user-provided service, binding it to the app and restaging the app:大约涉及 3 个步骤,包括设置用户提供的服务、将其绑定到应用程序和重新部署应用程序:

 ibmcloud cf cups SVC_INSTANCE_NAME -l syslog-tls://SYSLOG_ENDPOINT_URL:PORT_NUMBER

 ibmcloud cf bind-service CF_APP_NAME SVC_INSTANCE_NAME

 ibmcloud cf restage CF_APP_NAME

So this is how it works now: - I only configured the "configure platform logs" in the GUI.所以这就是它现在的工作方式: - 我只在 GUI 中配置了“配置平台日志”。 - I did not add a CUPS instance. - 我没有添加 CUPS 实例。 I tried it (as described in the docs by provisionning a syslog port) but it did not bring anything new, I actually started to get a log of rubbish logs.... SO I removed that CUPS instance.我试过了(如文档中描述的那样,通过配置系统日志端口),但它没有带来任何新东西,我实际上开始获取垃圾日志的日志......所以我删除了那个 CUPS 实例。 Not too sure what this is for.不太清楚这是干什么用的。

--> I am getting the platform logs, and I also see any console.log entries. --> 我正在获取平台日志,并且我还看到了任何 console.log 条目。

I then also finally got logDNA nodejs package to work.然后我也终于让 logDNA nodejs package 工作了。 The culprit was the lodDNA URL as @Milan pointed out.正如@Milan 指出的那样,罪魁祸首是 lodDNA URL。 I had tried several, but the one that worked in the end was: logdna_url: " https://logs.eu-de.logging.cloud.ibm.com/logs/ingest "我尝试了几个,但最终有效的是: logdna_url: " https://logs.eu-de.logging.cloud.ibm.com/logs/ingest "

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM