Skip to content

Unexpected behaviur when trying to extract logs from log storage #7582

Open

Description

@carlosbloqhouse

Environment details

  • OS: Linux
  • Node.js version: v20.9.0
  • npm version: 10.1.0
  • @google-cloud/logging version:11.2.0

Steps to reproduce

In this issue i specify the line of codes that need to be modified to fix the issue.

  1. Have a view for a custom log storage
  2. Try to access it with getEntries or getEntriesStream, example of code snippet doing it:
const PROJECT_ID = 'exampleProjectId'; 
 const LOCATION = 'global';
const BUCKET_NAME = 'exampleBucketName';
const VIEW_NAME = '_AllLogs';

const logView = `projects/${PROJECT_ID}/locations/${LOCATION}/buckets/${BUCKET_NAME}/views/${VIEW_NAME}`;

console.log(`Searching log entries in bucket: ${LOG_BUCKET_NAME}`);

// Retrieve entries in pages
logging.getEntriesStream({
  maxResults: 10,
  filter: FILTER,
  resourceNames: [logView],
}).on('data', (data) => {
  console.log(data);
});
}

This scripts returns entries both for the project logs, and the current project. This is unexpected behavior, as expected behavior would be only to return logs specified by the call to getEntriesStream(). This makes it so you cant access only the logs for a concrete view without a lot of noise from the default bucket. In the code, we can see that the project default bucket is added to the query without your input, regardless you want it or not. It should be conditional, if resourceNames is provided, do not add the the default logs.

Error in getEntries:
https://github.com/googleapis/nodejs-logging/blob/9d1d480406c4d1526c8a7fafd9b18379c0c7fcea/src/index.ts#L593C18-L598C6

Error in getEntriesStream:
https://github.com/googleapis/nodejs-logging/blob/9d1d480406c4d1526c8a7fafd9b18379c0c7fcea/src/index.ts#L694C2-L695C66

Thanks!

Activity

  1. added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Dec 23, 2024
  2. carlosbloqhouse commented on Dec 23, 2024

    @carlosbloqhouse
    Author

    Ive realised there is another pr that tackles this issue, although it doesnt fully tackle it as only solves one of the 2 functions, and i think that solution probably doesnt work:

    googleapis/nodejs-logging#1482

  3. added
    priority: p3Desirable enhancement or fix. May not be included in next release.
    and removed
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on Mar 25, 2025
  4. cindy-peng commented on Mar 25, 2025

    @cindy-peng
    Contributor

    Hi @carlosbloqhouse, sorry for the late response! I will take a look at this.

  5. carlosbloqhouse commented on Mar 26, 2025

    @carlosbloqhouse
    Author

    Hi @cindy-peng, thanks for looking into it. I think the priority should be higher. Right now it is next to issues like typos in comments, when this issue actually breaks the utility of a couple functions in certain use cases (although is true that these use cases may be niche). We had to bypass the nodejs sdk and directly call the google api to achieve the utility of those functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: loggingIssues related to the Cloud Logging API.priority: p3Desirable enhancement or fix. May not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions