-
Notifications
You must be signed in to change notification settings - Fork 66
Closed
Labels
api: loggingIssues related to the googleapis/nodejs-logging API.Issues related to the googleapis/nodejs-logging API.priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Description
So I have the following function here:
const functions = require('@google-cloud/functions-framework');
const { Storage } = require('@google-cloud/storage');
const readline = require('readline');
const { Logging } = require('@google-cloud/logging');
const storage = new Storage();
const logging = new Logging();
async function searchLogs(date, timeStart, timeEnd, user) {
const logFilter = `logName="timestamp>="2023-03-01T11:55:00Z" AND timestamp<="2023-03-03T11:55:51Z"`;
const resourceNames = ['projects/production-logs'];
const [entries] = await logging.getEntries({ resourceNames, filter: logFilter });
console.log(`Searching logs with filter: ${logFilter}`);
console.log(`Found ${entries.length} entries.`);
for (const entry of entries) {
const message = entry.data.jsonPayload.message;
const ipAddress = message.match(/Ip Address:\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/);
if (ipAddress) {
return ipAddress[1];
}
}
console.log(`----`);
return null;
}
//... rest of code
What I'm having an issue is I have my production logs stored in a logging bucket called "prod", however the above code only works on the project scope rather than on a per-bucket scope, so it basically can't find the logs, because it can't see the logging bucket.
Is there a way to direct it so that it sends the request to a specific logging bucket? I can't find much online, and I have found a function in the source code for the loggin API about retreiving a list of logging buckets in the project, which works, but how do I set it to use that bucket now?
Btw, I hardcoded the timestamp for now to keep it simple.
pepf and Colt45s
Metadata
Metadata
Assignees
Labels
api: loggingIssues related to the googleapis/nodejs-logging API.Issues related to the googleapis/nodejs-logging API.priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.