nodejs-logging-winston: Not showing `resource.labels.function_name` nor `labels."execution_id"`

Environment details

  • OS: Firebase
  • Node.js version: v6.14.0
  • npm version:
  • @google-cloud/logging-winston version: 0.9.0

Steps to reproduce

  1. Set up logging-winston as per the Google docs:
const winston = require('winston');
const Logger = winston.Logger;
const Console = winston.transports.Console;

const LoggingWinston = require('@google-cloud/logging-winston').LoggingWinston;

const loggingWinston = new LoggingWinston();

const logger = new Logger({
    level: 'info',
    transports: [
        new Console(),
        // for Stackdriver
        loggingWinston,
    ],
});

module.exports = logger
  1. Log a payload
logger.info('Audit', {foo: 'bar'})
  1. StackDriver console shows an Audit entry, but without resource.labels.function_name and labels."execution_id"

I’d like to see my Winston log entry have these attributes as if I used regular console.log:

screen shot 2018-06-14 at 11 00 55

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 4
  • Comments: 18 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Thus, you could just use console.log for logging and get the execution_id available in the Logs Viewer.

Thanks, but the reason I want to use this package was to get structured logging. Thanks for looking into it.

I would also like to use structured logging and not getting the execution_id with Winston.

Would be great to have this re-opened.

Still struggling to get the execution_id.

I’m going to close this issue since … the use of console.log should resolve the issues.

https://cloud.google.com/functions/docs/monitoring/logging#writing_logs

Cloud Functions includes simple logging by default. Logs written to stdout or stderr will appear automatically in the Cloud Console. For more advanced logging, use the Stackdriver Logging Client Library.

Given that the official documentation actually suggests using something other than console.log, can this issue get re-opened?

Thanks @DominicKramer , it’ll be especially nice to see execution_id on there.

Thanks for opening this issue. I agree with your assessment of the issue that you would need to supply the labels in question.

I have re-opened this issue as a feature request since it would be good to determine if these labels should be applied automatically if/when available.

However, it is good that, even if the labels are not applied automatically, they can still be applied manually to get the desired functionality.

@opyate were you ever able to find a solution to this ? I’ve resorted to using winston to be able to set severity, but have now lost the labels that were pushed by CF by default

@ofrobots That’s a great point. For express users we can automatically include the execution_id. 😃

Further, this would be hard to get because a log statement need not be invoked in an execution path that involves a request object.

We do have this capability through the request.log function added by the express middleware.