Skip to content

Latest commit

 

History

History
 
 

logging

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Google Cloud Platform logo

Stackdriver Logging Node.js samples

Stackdriver Logging allows you to store, search, analyze, monitor, and alert on log data and events from Google Cloud Platform and Amazon Web Services.

Table of Contents

Setup

  1. Read Prerequisites and How to run a sample first.

  2. Install dependencies:

    With npm:

    npm install
    

    With yarn:

    yarn install
    

Samples

Logs

View the documentation or the source code.

Usage: node logs --help

Commands:
  list                             List log entries in the authenticated project.
  write <name> <resource> <entry>  Write a log entry.
  delete <name>                    Delete a Log.

Options:
  --help  Show help                                                                        [boolean]

Examples:
  node logs list                                      List all log entires.
  node logs list -f "severity = ERROR" -s             List up to 2 error entries, sorted by
  "timestamp" -l 2                                    timestamp ascending.
  node logs write my-log                              Write a log entry.
  '{"type":"gae_app","labels":{"module_id":"default"
  }}' '{"message":"Hello World!"}'
  node logs delete my-log                             Delete "my-log".

For more information, see https://cloud.google.com/logging/docs

Sinks

View the documentation or the source code.

Usage: node sinks --help

Commands:
  create <name> <destination>  Create a new sink with the given name and destination.
  get <name>                   Get the metadata for the specified sink.
  list                         List all sinks in the authenticated project.
  update <name> <metadata>     Update the metadata for the specified sink.
  delete <name>                Delete the specified sink.

Options:
  --help  Show help                                                                        [boolean]

Examples:
  node sinks create my-sink my-bucket --type bucket   Create a new sink named "my-sink" that exports
                                                      logs to a Cloud Storage bucket.
  node sinks create my-sink my-dataset --type         Create a new sink named "my-sink" that exports
  dataset                                             logs to a BigQuery dataset.
  node sinks create my-sink my-topic --type topic     Create a new sink named "my-sink" that exports
                                                      logs to a Cloud Pub/Sub topic.
  node sinks get my-sink                              Get the metadata for "my-sink".
  node sinks list                                     List all sinks in the authenticated project.
  node sinks update my-sink '{"filter":"severity >    Update the specified sink.
  ALERT"}'
  node sinks delete my-sink                           Delete "my-sink".

For more information, see https://cloud.google.com/logging/docs

Error Reporting on Compute Engine

View the documentation or the source code.

Running the tests

  1. Set the GCLOUD_PROJECT and GOOGLE_APPLICATION_CREDENTIALS environment variables.

  2. Run the tests:

    With npm:

    npm test
    

    With yarn:

    yarn test