Skip to content

Latest commit

 

History

History
129 lines (92 loc) · 5.03 KB

File metadata and controls

129 lines (92 loc) · 5.03 KB

Google Cloud Platform logo

Stackdriver Monitoring: Node.js Samples

Build

Stackdriver Monitoring collects metrics, events, and metadata from Google Cloud Platform, Amazon Web Services (AWS), hosted uptime probes, application instrumentation, and a variety of common application components including Cassandra, Nginx, Apache Web Server, Elasticsearch and many others.

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

Metrics

View the documentation or the source code.

Usage: node metrics.js --help

Commands:
  create [projectId]                       Creates an example 'custom.googleapis.com/stores/daily_sales' custom metric
                                           descriptor.
  list [projectId]                         Lists metric descriptors.
  get <metricId> [projectId]               Get a metric descriptor.
  delete <metricId> [projectId]            Deletes a custom metric descriptor.
  write [projectId]                        Writes example time series data to
                                           'custom.googleapis.com/stores/daily_sales'.
  read <filter> [projectId]                Reads time series data that matches the given filter.
  read-fields [projectId]                  Reads headers of time series data that matches
                                           'compute.googleapis.com/instance/cpu/utilization'.
  read-aggregate [projectId]               Aggregates time series data that matches
                                           'compute.googleapis.com/instance/cpu/utilization'.
  read-reduce [projectId]                  Reduces time series data that matches
                                           'compute.googleapis.com/instance/cpu/utilization'.
  list-resources [projectId]               Lists monitored resource descriptors.
  get-resource <resourceType> [projectId]  Get a monitored resource descriptor.

Options:
  --version        Show version number                                                                         [boolean]
  --help           Show help                                                                                   [boolean]
  --projectId, -p                                                                                               [string]

Examples:
  node metrics.js create
  node metrics.js list
  node metrics.js get logging.googleapis.com/log_entry_count
  node metrics.js delete custom.googleapis.com/stores/daily_sales
  node metrics.js list-resources
  node metrics.js get-resource cloudsql_database
  node metrics.js write
  node metrics.js read 'metric.type="compute.googleapis.com/instance/cpu/utilization"'
  node metrics.js read-fields
  node metrics.js read-aggregate
  node metrics.js read-reduce

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

Uptime Config

View the documentation or the source code.

Usage: node uptime.js --help

Commands:
  create <gceInstanceId> [projectId]        Creates an uptime check config.
  list [projectId]                          Lists uptime check configs.
  list-ips                                  Lists uptime check config IPs.
  get <uptimeCheckConfigId> [projectId]     Gets an uptime check config.
  delete <uptimeCheckConfigId> [projectId]  Deletes an uptime check config.

Options:
  --version        Show version number                                                                         [boolean]
  --help           Show help                                                                                   [boolean]
  --projectId, -p                                                                                               [string]

Examples:
  node uptime.js create my-instance                             Create an uptime check for a "my-instance" GCE instance.
  node uptime.js list                                           List all uptime check configs.
  node uptime.js list-ips
  node uptime.js get My-Uptime-Check
  node uptime.js delete My-Uptime-Check

For more information, see https://cloud.google.com/monitoring/uptime-checks/

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