Skip to content

Example is incorrect in the compute docs #1494

@Shobhit29

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

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