I'm trying to set up Stackdriver Winston logging in a node.js application (running on localhost, to be deployed to Docker containers in Kubernetes). When running normally, an "Invalid response from metadata service: incorrect Metadata-Flavor header" exception is thrown.
Debugging locally on http://localhost:8080. I'm using a service account in GCP with Log-Writer, Admin, and Log-Reader permissions. I've tried both setting the GOOGLE_APPLICATION_CREDENTIALS env variable and explicit auth when setting up the logger.
Package versions are "winston": "^3.2.1" and "@google-cloud/logging-winston": "^0.11.0".
const { createLogger, format, transports } = require('winston');
const { LoggingWinston } = require('@google-cloud/logging-winston');
const loggingWinston = new LoggingWinston({
projectId: 'projectid',
keyFilename: 'path_to_key"
});
module.exports = createLogger({
transports:[
new transports.Console({
format: format.combine(
format.timestamp(),
format.json()
)
}),
loggingWinston
]
})
log.info('Test our logging');
log.error('Test logging again');
No logged messages in GCP Stackdriver log viewer, winston_log not available in log type dropdown list, and "Invalid response from metadata service: incorrect Metadata-Flavor header" exception thrown at "node_modules\gcp-metadata\build\src\index.js:65:23" when trying to log messages.