简体   繁体   中英

LogDNA and cloud foundry nodejs apps

I run a couple of nodejs APPS in cloud foundry on IBM cloud. I wanted to integrate all this in logDNA so I setup a logDNA instance.

1 - I did NOT configure any source as is described in the help (adding agents etc). Still logs started to appear from my cloudant services and my nodejs Apps. System logs apparently. Wondering why... Is the agent by default in the buildpack or something like this?

2 - Now I also wanted to add nodejs APP logs. So I followed: https://github.com/logdna/nodejs and added the following code in my app:

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. 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. You use the regular Cloud Foundry app logging. With the app in place, you would configure " syslog drain ". Follow the instructions how to configure Log Analysis with LogDNA for Cloud Foundry apps . There are roughly 3 steps involved, including setting up a user-provided service, binding it to the app and restaging the app:

 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. - I did not add a CUPS instance. 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. Not too sure what this is for.

--> I am getting the platform logs, and I also see any console.log entries.

I then also finally got logDNA nodejs package to work. The culprit was the lodDNA URL as @Milan pointed out. 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 "

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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