Skip to content

Example is incorrect in the compute docs #1494

Description

@Shobhit29

The example given in the document [1] is incorrect. The resource name in the example showing

var entry = log.entry('compute.googleapis.com', {
  user: 'my_username'
});

But it should be like below:

var entry = log.entry('gce_instance', {
  instance: 'instance1' 
});

Environment details

  • OS: Chrome OS
  • Node.js version: 4.3
  • gcloud-node version: 0.38.3

Steps to reproduce

Use the example as below according to the document [1], which gives the error "{ [Error: Resource Type not supported: compute.googleapis.com]"

'use strict';
var express = require('express');
var gcloud = require('google-cloud')({
    projectId:'bold-vial-100721'
    })
var app = express();
var logging = gcloud.logging();
var log = logging.log('syslog');
var entry = log.entry('compute.googleapis.com', {
  user: 'my_username'
});
app.get('/', function (req, res) {
  log.alert(entry, function(err, apiResponse){console.log(err,apiResponse)});
  res.status(200).send('Hello, world!');
});
// Start the server
var server = app.listen(process.env.PORT || '8080', function () {
  console.log('App listening on port %s', server.address().port);
  console.log('Press Ctrl+C to quit.');
});

Basically you need to use the resource type as mentioned in the document [2] for logging API v2. Please correct the example accordingly as it is causing confusion.

Thanks!

[1] https://googlecloudplatform.github.io/gcloud-node/#/docs/google-cloud/0.38.3/logging/log?method=alert
[2] https://cloud.google.com/logging/docs/api/v2/resource-list

Activity

  1. stephenplusplus commented on Aug 16, 2016

    @stephenplusplus
    Contributor

    Thanks for the report @Shobhit29! Any interest in sending a PR?

  2. changed the title [-]Example is incorrect in the [/-] [+]Example is incorrect in the compute docs[/+] on Aug 16, 2016
  3. added a commit that references this issue on Feb 3, 2026
  4. added a commit that references this issue on Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api: computeIssues related to the Compute Engine API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions