GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Logging Winston Monitored Resource · Issue #2484 · googleapis/google-cloud-node

Logging Winston Monitored Resource #2484

New issue
Copy link
New issue
Copy link
Closed
Closed
Logging Winston Monitored Resource#2484
Copy link
Assignees
ofrobots
Labels
api: logging-winstonpriority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Description

@jwgoh
jwgoh
opened on Jul 24, 2017
Issue body actions

Environment details

  • OS: Ubuntu 16.04
  • Node.js version: v4.8.4
  • npm version: 2.15.11
  • google-cloud/logging-winston: 0.5.0

Hi there. 2 things that I noticed when trying out the Stackdriver transport for winston.

  1. The auto detection of monitored resource is not accurate. My node app is running on Google Compute Engine (GCE), but my logs appear in Google Container Engine (GKE). I am using PM2 to manage my node applications, could this be the cause?
  2. Since the auto detection above wasn't working accurately, I tried specifying the monitored resource manually. The keys for labels seems to only take snake_case i.e. project_id and NOT camelCase projectId.
// Works
resource: {
  type: 'gce_instance',
  labels: {
    project_id: projectId,
    instance_id: instanceId,
    zone: zone,
  },
},

// Does not work. Nothing gets logged
resource: {
  type: 'gce_instance',
  labels: {
    projectId: projectId,
    instanceId: instanceId,
    zone: zone,
  },
},

I referred to the documentations here and here when specifying the key-value.

Activity

  1. stephenplusplus
    added
    api: logging-winston
    on Jul 24, 2017
  2. stephenplusplus
    assigned
    ofrobots
    on Jul 24, 2017
  3. ofrobots
    added
    status: acknowledged
    on Jul 27, 2017
  4. ofrobots commented on Jul 27, 2017

    @ofrobots
    ofrobots
    on Jul 27, 2017
    Contributor
    More actions

    Hi @jwgoh. Thanks for the detailed bug report. I have split the snake_case issue into a separate one (#2494) and we can keep this issue for diagnosing the incorrect resource identification of GCE as GKE.

    Is there any chance you might be setting the cluster_name as a metadata attribute on your GCE instance?

    We detect the environment using the logic here. We check for container engine before checking for GCE. If I am reading the logic correctly, It seems that the only way we identify the environment to be container engine is if the cluster-name attribute is set.

  5. jwgoh commented on Aug 7, 2017

    @jwgoh
    jwgoh
    on Aug 7, 2017
    Author
    More actions

    @ofrobots Hey there, sorry for the late reply. Thanks for splitting up the snake_case issue into a separate one.

    No, I am not setting any metadata attribute, just adding the winston transport directly.

    logger.add(Stackdriver, {
      level: options.level,
      logName: options.logName,
    });
    

    This can be confirmed from an example log entry that has the following resource JSON content. Only project_id is present.

    screen shot 2017-08-07 at 11 25 21 am

  6. landrito
    added
    priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Aug 7, 2017
  7. ofrobots commented on Aug 7, 2017

    @ofrobots
    ofrobots
    on Aug 7, 2017
    Contributor
    More actions

    Thanks. I suspect this will be fixed by #2483. @stephenplusplus could we get a release for the base logging module followed by a dep-bump + release of logging-{winston,bunyan}?

    Reacted by Stephen
  8. jwgoh commented on Aug 8, 2017

    @jwgoh
    jwgoh
    on Aug 8, 2017
    Author
    More actions

    @ofrobots Thanks, will check if this change fixes the bug once there is a new release 👍

  9. stephenplusplus commented on Aug 8, 2017

    @stephenplusplus
    stephenplusplus
    on Aug 8, 2017
    Contributor
    More actions

    @google-cloud/[email protected] released. New installs as well as un- and re-installing logging-winston and logging-bunyan will pick up the change.

  10. ofrobots commented on Aug 9, 2017

    @ofrobots
    ofrobots
    on Aug 9, 2017
    Contributor
    More actions

    @jwgoh Please let us know when you've tried out the fix. If there are still issues, I would like to understand them further.

  11. jwgoh commented on Aug 10, 2017

    @jwgoh
    jwgoh
    on Aug 10, 2017
    Author
    More actions

    @ofrobots Hey I tried the new release and this is what I get in my log output

    resource: {
      labels: {
       cluster_name:  "<!DOCTYPE html>
    <html lang=en>
      <meta charset=utf-8>
      <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
      <title>Error 404 (Not Found)!!1</title>
      <style>
        *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
      </style>
      <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
      <p><b>404.</b> <ins>That’s an error.</ins>
      <p>The requested URL <code>/computeMetadata/v1/instance/attributes/clusterName</code> was not found on this server.  <ins>That’s all we know.</ins>
    "     
       container_name:  ""     
       instance_id:  ""     
       namespace_id:  ""     
       pod_id:  ""     
       project_id: <REDACTED>
       zone:  ""     
      }
      type:  "container"    
     }
    

    It seems like it is still detecting my node app as coming from GKE and attempting to query the metadata server for clusterName which clearly is not defined for GCE.

  12. ofrobots commented on Aug 10, 2017

    @ofrobots
    ofrobots
    on Aug 10, 2017
    Contributor
    More actions

    Ooops. This is embarrassing. I did a typo in the fix. It seems that kubernetes uses kebab-case in the attribute names.

    On a GKE machine:

    ofrobots@gke-cloudcats-default-pool-9562f1XX-XXXXX ~ $ curl "http://metadata.google.internal/computeMetadata/v1/inst
    ance/attributes/" -H "Metadata-Flavor: Google"
    cluster-name
    configure-sh
    created-by
    gci-ensure-gke-docker
    gci-update-strategy
    instance-template
    kube-env
    user-data

    Let me fix this.

  13. ofrobots commented on Sep 1, 2017

    @ofrobots
    ofrobots
    on Sep 1, 2017
    Contributor
    More actions

    Hi @jwgoh. I believe this should be fixed now. Please give this a shot, and let us know if there are still issues.

  14. jwgoh commented on Sep 5, 2017

    @jwgoh
    jwgoh
    on Sep 5, 2017
    Author
    More actions

    @ofrobots Thanks it's working now! 👍

    Minor nit, the zone is an empty string (instance_id and project_id are correct)

  15. ofrobots commented on Sep 11, 2017

    @ofrobots
    ofrobots
    on Sep 11, 2017
    Contributor
    More actions

    Thanks for verifying. I have opened #2601 to deal with the zone label.

    Reacted by JWG
  16. ofrobots
    closed this as completedon Sep 11, 2017
  17. JustinBeckwith
    unassigned
    ofrobots
    on Sep 19, 2018
  18. JustinBeckwith
    assigned
    ofrobots
    on Feb 1, 2021
  19. sofisl
    added a commit that references this issue on Feb 24, 2026

    chore: add autogenerated api-report files to `.gitignore` (#2484)

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

Metadata

Metadata

Assignees

  • @ofrobots
    ofrobots

Labels

api: logging-winstonpriority: p1Important issue which blocks shipping the next release. Will be fixed prior to 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

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.