Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does the Logging client support logs and Entries for Folders and Organizations #1398

Open
smilinazzo opened this issue Jan 4, 2023 · 2 comments
Labels
api: logging Issues related to the googleapis/nodejs-logging API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@smilinazzo
Copy link

smilinazzo commented Jan 4, 2023

Hey,

I'm looking for some clarification and direction. I currently have some resources setup as follows:

─ my-organization
    └── my-folder
          └── my-project

I can write logs to a project with the sample code:

async write(): {
  const logging = new Logging();
  const log = logging.log('folder-log-1');

  // A json log entry with additional context
  const metadata = {
    severity: 'WARNING',
    resource: {
      type: 'global'
    }
  };

  const message = {
    "message": "Some message for some log",
  };

  const json_Entry = log.entry(metadata, message);
  await log.write(json_Entry);
}

But, I would also like to write/retrieve logs/entries from the organization and folder levels. The service account for the project has Logging Admin and Logs Viewer access for the Folder and organization.

Is this client only able to write/view logs and entries for a Project?

@smilinazzo smilinazzo added priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue. labels Jan 4, 2023
@product-auto-label product-auto-label bot added the api: logging Issues related to the googleapis/nodejs-logging API. label Jan 4, 2023
@losalex
Copy link
Contributor

losalex commented Jan 5, 2023

Thanks @smilinazzo for opening this issue. Looking into formatLogName, it seems we do not support folder/organizations as defined in logName. I will turn this issue into a feature as well.

@losalex losalex added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed type: question Request for information or clarification. Not an issue. labels Jan 5, 2023
@smilinazzo
Copy link
Author

Thank @losalex.

I was able to get what I needed by doing:

  async getLogs(resource: 'projects' | 'folders' | 'organizations'): Promise<string[]> {
    const response = await this._client.auth.request({
      url: `https://logging.googleapis.com/v2/${resource}/logs`,
      method: 'GET'
    });

    return response.data;
  }

But being able to use the client directly would be great.

@losalex losalex removed their assignment Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the googleapis/nodejs-logging API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

2 participants