diff --git a/README.md b/README.md
index 366cb3c6c2..0435e0ddd2 100644
--- a/README.md
+++ b/README.md
@@ -253,7 +253,7 @@ View the [Cloud Datastore Node.js samples][datastore_samples].
[Cloud Storage][storage_docs] allows world-wide storage and retrieval of any
amount of data at any time.
-View the [Cloud Storage Node.js samples][storage_samples].
+View the [Cloud Storage JSON API Node.js Client samples][storage_samples].
[storage_docs]: https://cloud.google.com/storage/docs/
[storage_samples]: https://github.com/googleapis/nodejs-storage/tree/master/samples
@@ -299,7 +299,7 @@ understanding technologies to developers, including sentiment analysis, entity
recognition, and syntax analysis. This API is part of the larger Cloud Machine
Learning API.
-View the [Cloud Natural Language API Node.js samples][language_samples].
+View the [Cloud Natural Language API Node.js Client samples][language_samples].
[language_docs]: https://cloud.google.com/natural-language/docs/
[language_samples]: language
@@ -364,10 +364,10 @@ View the [Stackdriver Debugger Node.js sample][debugger_sample].
monitor, and alert on log data and events from Google Cloud Platform and Amazon
Web Services.
-View the [Stackdriver Logging Node.js samples][logging_samples].
+View the [Stackdriver Logging API Node.js Client samples][logging_samples].
[logging_docs]: https://cloud.google.com/logging/docs/
-[logging_samples]: logging
+[logging_samples]: https://github.com/googleapis/nodejs-logging/tree/master/samples
#### Stackdriver Monitoring
@@ -376,10 +376,10 @@ 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.
-View the [Stackdriver Monitoring Node.js samples][monitoring_samples].
+View the [Stackdriver Monitoring API Node.js Client samples][monitoring_samples].
[monitoring_docs]: https://cloud.google.com/monitoring/docs/
-[monitoring_samples]: monitoring
+[monitoring_samples]: https://github.com/googleapis/nodejs-monitoring/tree/master/samples
#### Stackdriver Trace
@@ -403,10 +403,10 @@ anywhere in the world. Read more about [Google Cloud DNS][dns_docs].
[dns_docs]: https://cloud.google.com/dns/docs
-View the [Google Cloud DNS Node.js sample][dns_sample].
+View the [Google Cloud DNS API Node.js Client samples][dns_samples].
[dns_docs]: https://cloud.google.com/dns/docs/
-[dns_sample]: dns
+[dns_samples]: https://github.com/googleapis/nodejs-dns/tree/master/samples
### Identity and Security
diff --git a/circle.yml b/circle.yml
index 2126453080..e04fddfc2e 100644
--- a/circle.yml
+++ b/circle.yml
@@ -93,7 +93,6 @@ deployment:
- node scripts/build "datastore"
- node scripts/build "debugger"
- node scripts/build "dlp"
- - node scripts/build "dns"
- node scripts/build "endpoints/getting-started"
# TODO(ace-n): Get this working again
# - node scripts/build "endpoints/getting-started-grpc"
@@ -101,8 +100,6 @@ deployment:
- node scripts/build "iot/manager"
- node scripts/build "kms"
- node scripts/build "language/slackbot"
- - node scripts/build "logging"
- - node scripts/build "monitoring"
- node scripts/build "prediction"
- node scripts/build "pubsub"
- node scripts/build "resource"
diff --git a/dns/README.md b/dns/README.md
index edd76b5865..a5c233ed58 100644
--- a/dns/README.md
+++ b/dns/README.md
@@ -1,68 +1,5 @@
-
+Samples for the [Google Cloud DNS API Node.js Client][client] have moved
+to [github.com/googleapis/nodejs-dns/tree/master/samples/][samples].
-# Google Cloud DNS Node.js Samples
-
-[]()
-
-[Cloud DNS](https://cloud.google.com/dns/docs/) allows you to publish your domain names using Google's infrastructure for production-quality, high-volume DNS services. Google's global network of anycast name servers provide reliable, low-latency authoritative name lookups for your domains from anywhere in the world.
-
-## Table of Contents
-
-* [Setup](#setup)
-* [Samples](#samples)
- * [Zones](#zones)
-* [Running the tests](#running-the-tests)
-
-## Setup
-
-1. Read [Prerequisites][prereq] and [How to run a sample][run] first.
-1. Install dependencies:
-
- With **npm**:
-
- npm install
-
- With **yarn**:
-
- yarn install
-
-[prereq]: ../README.md#prerequisites
-[run]: ../README.md#how-to-run-a-sample
-
-## Samples
-
-### Zones
-
-View the [documentation][zones_0_docs] or the [source code][zones_0_code].
-
-__Usage:__ `node zones.js --help`
-
-```
-Commands:
- list Lists all zones in the current project.
-
-Options:
- --help Show help [boolean]
-
-Examples:
- node zones.js list Lists all zones in the current project.
-
-For more information, see https://cloud.google.com/dns/docs
-```
-
-[zones_0_docs]: https://cloud.google.com/dns/docs
-[zones_0_code]: zones.js
-
-## Running the tests
-
-1. Set the **GCLOUD_PROJECT** and **GOOGLE_APPLICATION_CREDENTIALS** environment variables.
-
-1. Run the tests:
-
- With **npm**:
-
- npm test
-
- With **yarn**:
-
- yarn test
+[client]: https://github.com/googleapis/nodejs-dns
+[samples]: https://github.com/googleapis/nodejs-dns/tree/master/samples
diff --git a/dns/package.json b/dns/package.json
deleted file mode 100644
index 2ccca35ab8..0000000000
--- a/dns/package.json
+++ /dev/null
@@ -1,43 +0,0 @@
-{
- "name": "nodejs-docs-samples-dns",
- "version": "0.0.1",
- "private": true,
- "license": "Apache-2.0",
- "author": "Google Inc.",
- "repository": {
- "type": "git",
- "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
- },
- "engines": {
- "node": ">=4.3.2"
- },
- "scripts": {
- "lint": "samples lint",
- "pretest": "npm run lint",
- "test": "samples test run --cmd ava -- -T 1m --verbose system-test/*.test.js"
- },
- "dependencies": {
- "@google-cloud/dns": "0.6.2",
- "yargs": "8.0.2"
- },
- "devDependencies": {
- "@google-cloud/nodejs-repo-tools": "1.4.17",
- "ava": "0.21.0",
- "proxyquire": "1.8.0",
- "sinon": "3.2.0"
- },
- "cloud-repo-tools": {
- "requiresKeyFile": true,
- "requiresProjectId": true,
- "product": "dns",
- "samples": [
- {
- "id": "zones",
- "name": "Zones",
- "file": "zones.js",
- "docs_link": "https://cloud.google.com/dns/docs",
- "usage": "node zones.js --help"
- }
- ]
- }
-}
diff --git a/dns/quickstart.js b/dns/quickstart.js
deleted file mode 100644
index f686c389dd..0000000000
--- a/dns/quickstart.js
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Copyright 2016, Google, Inc.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-// [START dns_quickstart]
-// Imports the Google Cloud client library
-const DNS = require('@google-cloud/dns');
-
-// Your Google Cloud Platform project ID
-const projectId = 'YOUR_PROJECT_ID';
-
-// Instantiates a client
-const dnsClient = DNS({
- projectId: projectId
-});
-
-// Lists all zones in the current project
-dnsClient.getZones()
- .then((results) => {
- const zones = results[0];
-
- console.log('Zones:');
- zones.forEach((zone) => console.log(zone.name));
- });
-// [END dns_quickstart]
diff --git a/dns/system-test/quickstart.test.js b/dns/system-test/quickstart.test.js
deleted file mode 100644
index 8bf482672e..0000000000
--- a/dns/system-test/quickstart.test.js
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const proxyquire = require(`proxyquire`).noPreserveCache();
-const sinon = require(`sinon`);
-const test = require(`ava`);
-const tools = require(`@google-cloud/nodejs-repo-tools`);
-
-const dns = proxyquire(`@google-cloud/dns`, {})();
-
-const uuid = require(`uuid`);
-const zoneName = `test-${uuid().substring(0, 13)}`;
-
-test.before(async () => {
- await dns.createZone(zoneName, {
- dnsName: `${process.env.GCLOUD_PROJECT}.appspot.com.`
- });
-});
-
-test.after.always(async () => {
- try {
- await dns.zone(zoneName).delete();
- } catch (err) {} // ignore error
-});
-
-test.beforeEach(tools.stubConsole);
-test.afterEach.always(tools.restoreConsole);
-
-test.cb(`should list zones`, (t) => {
- const dnsMock = {
- getZones: () => {
- return dns.getZones()
- .then(([zones]) => {
- t.true(Array.isArray(zones));
-
- // Listing is eventually consistent, give the indexes time to update
- setTimeout(() => {
- try {
- t.true(console.log.called);
- t.deepEqual(console.log.getCall(0).args, [`Zones:`]);
- zones.forEach((zone, i) => {
- t.deepEqual(console.log.getCall(i + 1).args, [zone.name]);
- });
- t.end();
- } catch (err) {
- t.end(err);
- }
- }, 200);
-
- return [zones];
- });
- }
- };
-
- setTimeout(() => {
- proxyquire(`../quickstart`, {
- '@google-cloud/dns': sinon.stub().returns(dnsMock)
- });
- }, 5000);
-});
diff --git a/dns/system-test/zones.test.js b/dns/system-test/zones.test.js
deleted file mode 100644
index cf1bef1359..0000000000
--- a/dns/system-test/zones.test.js
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const dns = require(`@google-cloud/dns`)();
-const path = require(`path`);
-const test = require(`ava`);
-const tools = require(`@google-cloud/nodejs-repo-tools`);
-const uuid = require(`uuid`);
-
-const zoneName = `test-${uuid().substr(0, 13)}`;
-const cwd = path.join(__dirname, `..`);
-const cmd = `node zones.js`;
-
-test.before(tools.checkCredentials);
-test.before(async () => {
- await dns.createZone(zoneName, {
- dnsName: `${process.env.GCLOUD_PROJECT}.appspot.com.`
- });
-});
-
-test.after.always(async () => {
- try {
- await dns.zone(zoneName).delete();
- } catch (err) {} // ignore error
-});
-
-test(`should list zones`, async (t) => {
- t.plan(0);
- await tools.tryTest(async (assert) => {
- const output = await tools.runAsync(`${cmd} list`, cwd);
- assert(output.includes(`Zones:`));
- assert(output.includes(zoneName));
- }).start();
-});
diff --git a/dns/zones.js b/dns/zones.js
deleted file mode 100644
index b9d240e1cf..0000000000
--- a/dns/zones.js
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-function listZones () {
- // [START dns_list_zones]
- // Imports the Google Cloud client library
- const DNS = require('@google-cloud/dns');
-
- // Instantiates a client
- const dns = DNS();
-
- // Lists all zones in the current project
- dns.getZones()
- .then((results) => {
- const zones = results[0];
- console.log('Zones:');
- zones.forEach((zone) => console.log(zone.name));
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END dns_list_zones]
-}
-
-require(`yargs`) // eslint-disable-line
- .demand(1)
- .command(`list`, `Lists all zones in the current project.`, {}, listZones)
- .example(`node $0 list`, `Lists all zones in the current project.`)
- .wrap(120)
- .recommendCommands()
- .epilogue(`For more information, see https://cloud.google.com/dns/docs`)
- .help()
- .strict()
- .argv;
diff --git a/language/README.md b/language/README.md
index 2ce46d36f7..c904ef79dc 100644
--- a/language/README.md
+++ b/language/README.md
@@ -1,5 +1,5 @@
Most samples for the [Google Cloud Natural Language API Node.js Client][client]
-have moved to [github.com/googleapis/nodejs-language: samples/][samples].
+have moved to [github.com/googleapis/nodejs-language/tree/master/samples/][samples].
[client]: https://github.com/googleapis/nodejs-language
[samples]: https://github.com/googleapis/nodejs-language/tree/master/samples
diff --git a/logging/README.md b/logging/README.md
index b22d6dbace..7d183db46c 100644
--- a/logging/README.md
+++ b/logging/README.md
@@ -1,125 +1,5 @@
-
+Samples for the [Stackdriver Logging API Node.js Client][client] have moved
+to [github.com/googleapis/nodejs-logging/tree/master/samples/][samples].
-# Stackdriver Logging Node.js samples
-
-[Stackdriver Logging][logging_docs] allows you to store, search, analyze,
-monitor, and alert on log data and events from Google Cloud Platform and Amazon
-Web Services.
-
-[logging_docs]: https://cloud.google.com/logging/docs/
-
-## Table of Contents
-
-* [Setup](#setup)
-* [Samples](#samples)
- * [Logs](#logs)
- * [Sinks](#sinks)
- * [Error Reporting on Compute Engine](#error-reporting-on-compute-engine)
- * [Logging to Google Cloud with Winston](https://github.com/GoogleCloudPlatform/winston-gae)
-* [Running the tests](#running-the-tests)
-
-## Setup
-
-1. Read [Prerequisites][prereq] and [How to run a sample][run] first.
-1. Install dependencies:
-
- With `npm`:
-
- npm install
-
- With `yarn`:
-
- yarn install
-
-[prereq]: ../README.md#prerequisities
-[run]: ../README.md#how-to-run-a-sample
-
-## Samples
-
-### Logs
-
-View the [documentation][logs_docs] or the [source code][logs_code].
-
-__Usage:__ `node logs --help`
-
-```
-Commands:
- list List log entries in the authenticated project.
- write Write a log entry.
- delete 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
-```
-
-[logs_docs]: https://cloud.google.com/logging/docs
-[logs_code]: logs.js
-
-### Sinks
-
-View the [documentation][sinks_docs] or the [source code][sinks_code].
-
-__Usage:__ `node sinks --help`
-
-```
-Commands:
- create Create a new sink with the given name and destination.
- get Get the metadata for the specified sink.
- list List all sinks in the authenticated project.
- update Update the metadata for the specified sink.
- delete 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
-```
-
-[sinks_docs]: https://cloud.google.com/logging/docs
-[sinks_code]: sinks.js
-
-### Error Reporting on Compute Engine
-
-View the [documentation][error_docs] or the [source code][error_code].
-
-[error_docs]: https://cloud.google.com/error-reporting/docs/setup/compute-engine
-[error_code]: fluent.js
-
-## Running the tests
-
-1. Set the `GCLOUD_PROJECT` and `GOOGLE_APPLICATION_CREDENTIALS` environment
- variables.
-
-1. Run the tests:
-
- With `npm`:
-
- npm test
-
- With `yarn`:
-
- yarn test
+[client]: https://github.com/googleapis/nodejs-logging
+[samples]: https://github.com/googleapis/nodejs-logging/tree/master/samples
diff --git a/logging/fluent.js b/logging/fluent.js
deleted file mode 100644
index 91f15ba870..0000000000
--- a/logging/fluent.js
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-var express = require('express');
-var app = express();
-
-app.get('*', function (req, res, next) {
- return next('oops');
-});
-
-// [START fluent]
-var structuredLogger = require('fluent-logger').createFluentSender('myapp', {
- host: 'localhost',
- port: 24224,
- timeout: 3.0
-});
-
-var report = function (err, req) {
- var payload = {
- serviceContext: {
- service: 'myapp'
- },
- message: err.stack,
- context: {
- httpRequest: {
- url: req.originalUrl,
- method: req.method,
- referrer: req.header('Referer'),
- userAgent: req.header('User-Agent'),
- remoteIp: req.ip,
- responseStatusCode: 500
- }
- }
- };
- structuredLogger.emit('errors', payload);
-};
-
-// Handle errors (the following uses the Express framework)
-app.use(function (err, req, res, next) {
- report(err, req);
- res.status(500).send(err.response || 'Something broke!');
-});
-// [END fluent]
-
-module.exports = app;
diff --git a/logging/logs.js b/logging/logs.js
deleted file mode 100644
index 13aa958513..0000000000
--- a/logging/logs.js
+++ /dev/null
@@ -1,345 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-function writeLogEntry (logName) {
- // [START logging_write_log_entry]
- // Imports the Google Cloud client library
- const Logging = require('@google-cloud/logging');
-
- // Instantiates a client
- const logging = Logging();
-
- // The log to write to, e.g. "my-log"
- // const logName = "my-log";
-
- const log = logging.log(logName);
-
- // Modify this resource to match a resource in your project
- // See https://cloud.google.com/logging/docs/api/ref_v2beta1/rest/v2beta1/MonitoredResource
- const resource = {
- // This example targets the "global" resource for simplicity
- type: 'global'
- };
-
- // A text log entry
- const entry = log.entry({ resource: resource }, 'Hello, world!');
-
- // A structured log entry
- const secondEntry = log.entry({ resource: resource }, {
- name: 'King Arthur',
- quest: 'Find the Holy Grail',
- favorite_color: 'Blue'
- });
-
- // Save the two log entries. You can write entries one at a time, but it is
- // best to write multiple entires together in a batch.
- log.write([entry, secondEntry])
- .then(() => {
- console.log(`Wrote to ${logName}`);
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END logging_write_log_entry]
-}
-
-function loggingBunyan () {
- // [START logging_bunyan]
- const bunyan = require('bunyan');
-
- // Imports the Google Cloud client library for Bunyan
- const LoggingBunyan = require('@google-cloud/logging-bunyan');
-
- // Instantiates a Bunyan Stackdriver Logging client
- const loggingBunyan = LoggingBunyan();
-
- // Create a Bunyan logger that streams to Stackdriver Logging
- // Logs will be written to: "projects/YOUR_PROJECT_ID/logs/bunyan_log"
- const logger = bunyan.createLogger({
- // The JSON payload of the log as it appears in Stackdriver Logging
- // will contain "name": "my-service"
- name: 'my-service',
- // log at 'info' and above
- level: 'info',
- streams: [
- // Log to the console
- { stream: process.stdout },
- // And log to Stackdriver Logging
- loggingBunyan.stream()
- ]
- });
-
- // Writes some log entries
- logger.error('warp nacelles offline');
- logger.info('shields at 99%');
- // [END logging_bunyan]
-}
-
-function loggingWinston () {
- // [START logging_winston]
- const winston = require('winston');
- const Logger = winston.Logger;
- const Console = winston.transports.Console;
-
- // Imports the Google Cloud client library for Winston
- const LoggingWinston = require('@google-cloud/logging-winston');
-
- // Instantiates a Winston Stackdriver Logging client
- const loggingWinston = LoggingWinston();
-
- // Create a Winston logger that streams to Stackdriver Logging
- // Logs will be written to: "projects/YOUR_PROJECT_ID/logs/winston_log"
- const logger = new Logger({
- level: 'info', // log at 'info' and above
- transports: [
- // Log to the console
- new Console(),
- // And log to Stackdriver Logging
- loggingWinston
- ]
- });
-
- // Writes some log entries
- logger.error('warp nacelles offline');
- logger.info('shields at 99%');
- // [END logging_winston]
-}
-
-function bunyanSetupExplicit () {
- // [START logging_bunyan_setup_explicit]
- // Imports the Google Cloud client library for Bunyan
- const LoggingBunyan = require('@google-cloud/logging-bunyan');
-
- // Instantiates a client
- const loggingBunyan = LoggingBunyan({
- projectId: 'your-project-id',
- keyFilename: '/path/to/key.json'
- });
- // [END logging_bunyan_setup_explicit]
- console.log(loggingBunyan);
-}
-
-function winstonSetupExplicit () {
- // [START logging_winston_setup_explicit]
- // Imports the Google Cloud client library for Winston
- const LoggingWinston = require('@google-cloud/logging-winston');
-
- // Instantiates a client
- const loggingWinston = LoggingWinston({
- projectId: 'your-project-id',
- keyFilename: '/path/to/key.json'
- });
-
- // [END logging_winston_setup_explicit]
- console.log(loggingWinston);
-}
-
-function writeLogEntryAdvanced (logName, options) {
- // [START logging_write_log_entry_advanced]
- // Imports the Google Cloud client library
- const Logging = require('@google-cloud/logging');
-
- // Instantiates a client
- const logging = Logging();
-
- // The log to write to, e.g. "my-log"
- // const logName = "my-log";
-
- // The request options
- // const options = {
- // resource: {...},
- // entry: 'Hello, world!'
- // };
-
- const log = logging.log(logName);
-
- // Prepare the entry
- const entry = log.entry({ resource: options.resource }, options.entry);
-
- // See https://googlecloudplatform.github.io/google-cloud-node/#/docs/logging/latest/logging/log?method=write
- log.write(entry)
- .then(() => {
- console.log(`Wrote to ${logName}`);
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END logging_write_log_entry_advanced]
-}
-
-function listLogEntries (logName) {
- // [START logging_list_log_entries]
- // Imports the Google Cloud client library
- const Logging = require('@google-cloud/logging');
-
- // Instantiates a client
- const logging = Logging();
-
- // The log from which to list entries, e.g. "my-log"
- // const logName = "my-log";
-
- const log = logging.log(logName);
-
- // List the most recent entries for a given log
- // See https://googlecloudplatform.github.io/google-cloud-node/#/docs/logging/latest/logging?method=getEntries
- log.getEntries()
- .then((results) => {
- const entries = results[0];
-
- console.log('Logs:');
- entries.forEach((entry) => {
- const metadata = entry.metadata;
- console.log(`${metadata.timestamp}:`, metadata[metadata.payload]);
- });
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END logging_list_log_entries]
-}
-
-function listLogEntriesAdvanced (filter, pageSize, orderBy) {
- // [START logging_list_log_entries_advanced]
- // Imports the Google Cloud client library
- const Logging = require('@google-cloud/logging');
-
- // Instantiates a client
- const logging = Logging();
-
- // Filter results, e.g. "severity=ERROR"
- // See https://cloud.google.com/logging/docs/view/advanced_filters for more filter information.
- // const filter = 'severity=ERROR';
-
- // const pageSize = 5;
-
- // Sort results
- // const orderBy = 'timestamp';
-
- const options = {
- filter: filter,
- pageSize: pageSize,
- orderBy: orderBy
- };
-
- // See https://googlecloudplatform.github.io/google-cloud-node/#/docs/logging/latest/logging?method=getEntries
- logging.getEntries(options)
- .then((results) => {
- const entries = results[0];
-
- console.log('Logs:');
- entries.forEach((entry) => {
- const metadata = entry.metadata;
- console.log(`${metadata.timestamp}:`, metadata[metadata.payload]);
- });
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [START logging_list_log_entries_advanced]
-}
-
-function deleteLog (logName) {
- // [START logging_delete_log]
- // Imports the Google Cloud client library
- const Logging = require('@google-cloud/logging');
-
- // Instantiates a client
- const logging = Logging();
-
- // The log to delete, e.g. "my-log"
- // const logName = "my-log";
-
- const log = logging.log(logName);
-
- // Deletes a logger and all its entries.
- // Note that a deletion can take several minutes to take effect.
- // See https://googlecloudplatform.github.io/google-cloud-node/#/docs/logging/latest/logging/log?method=delete
- log.delete()
- .then(() => {
- console.log(`Deleted log: ${logName}`);
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END logging_delete_log]
-}
-
-// The command-line program
-const cli = require(`yargs`)
- .demand(1)
- .command('list', 'Lists log entries, optionally filtering, limiting, and sorting results.', {
- filter: {
- alias: 'f',
- type: 'string',
- requiresArg: true,
- description: 'Only log entries matching the filter are written.'
- },
- limit: {
- alias: 'l',
- type: 'number',
- requiresArg: true,
- description: 'Maximum number of results to return.'
- },
- sort: {
- alias: 's',
- type: 'string',
- requiresArg: true,
- description: 'Sort results.'
- }
- }, (opts) => {
- listLogEntriesAdvanced(opts.filter, opts.limit, opts.sort);
- })
- .command('list-simple ', 'Lists log entries.', {}, (opts) => listLogEntries(opts.logName))
- .command('write ', 'Writes a log entry to the specified log.', {}, (opts) => {
- try {
- opts.resource = JSON.parse(opts.resource);
- } catch (err) {
- console.error('"resource" must be a valid JSON string!');
- return;
- }
-
- try {
- opts.entry = JSON.parse(opts.entry);
- } catch (err) {}
-
- writeLogEntryAdvanced(opts.logName, opts);
- })
- .command('write-simple ', 'Writes a basic log entry to the specified log.', {}, (opts) => {
- writeLogEntry(opts.logName);
- })
- .command('bunyan', 'Writes some logs entries to Stackdriver Logging via Winston.', {}, loggingBunyan)
- .command('bunyan-setup', 'Setup up the Bunyan logger with explicit credentianls.', {}, bunyanSetupExplicit)
- .command('winston', 'Writes some logs entries to Stackdriver Logging via Winston.', {}, loggingWinston)
- .command('winston-setup', 'Setup up the Winston logger with explicit credentianls.', {}, winstonSetupExplicit)
- .command('delete ', 'Deletes the specified Log.', {}, (opts) => {
- deleteLog(opts.logName);
- })
- .example('node $0 list', 'List all log entries.')
- .example('node $0 list -f "severity=ERROR" -s "timestamp" -l 2', 'List up to 2 error entries, sorted by timestamp ascending.')
- .example(`node $0 list -f 'logName="my-log"' -l 2`, 'List up to 2 log entries from the "my-log" log.')
- .example('node $0 write my-log \'{"type":"gae_app","labels":{"module_id":"default"}}\' \'"Hello World!"\'', 'Write a string log entry.')
- .example('node $0 write my-log \'{"type":"global"}\' \'{"message":"Hello World!"}\'', 'Write a JSON log entry.')
- .example('node $0 delete my-log', 'Delete "my-log".')
- .wrap(120)
- .recommendCommands()
- .epilogue(`For more information, see https://cloud.google.com/logging/docs`)
- .help()
- .strict();
-
-if (module === require.main) {
- cli.parse(process.argv.slice(2));
-}
diff --git a/logging/package.json b/logging/package.json
deleted file mode 100644
index be8c2e055d..0000000000
--- a/logging/package.json
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- "name": "nodejs-docs-samples-logging",
- "version": "0.0.1",
- "private": true,
- "license": "Apache-2.0",
- "author": "Google Inc.",
- "repository": {
- "type": "git",
- "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
- },
- "engines": {
- "node": ">=4.3.2"
- },
- "scripts": {
- "lint": "samples lint",
- "pretest": "npm run lint",
- "unit-test": "ava -T 20s --verbose test/*.test.js",
- "system-test": "ava -T 1m --verbose system-test/*.test.js",
- "all-test": "npm run unit-test && npm run system-test",
- "test": "samples test run --cmd npm -- run all-test"
- },
- "dependencies": {
- "@google-cloud/logging": "1.0.5",
- "@google-cloud/logging-bunyan": "0.5.0",
- "@google-cloud/logging-winston": "0.5.0",
- "@google-cloud/storage": "1.2.1",
- "bunyan": "1.8.12",
- "express": "4.15.4",
- "fluent-logger": "2.4.1",
- "winston": "2.3.1",
- "yargs": "8.0.2"
- },
- "devDependencies": {
- "@google-cloud/nodejs-repo-tools": "1.4.17",
- "ava": "0.21.0",
- "proxyquire": "1.8.0",
- "sinon": "3.2.0",
- "supertest": "3.0.0",
- "uuid": "3.1.0"
- },
- "cloud-repo-tools": {
- "requiresKeyFile": true,
- "requiresProjectId": true
- }
-}
diff --git a/logging/quickstart.js b/logging/quickstart.js
deleted file mode 100644
index 99d91c038b..0000000000
--- a/logging/quickstart.js
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-// [START logging_quickstart]
-// Imports the Google Cloud client library
-const Logging = require('@google-cloud/logging');
-
-// Your Google Cloud Platform project ID
-const projectId = 'YOUR_PROJECT_ID';
-
-// Instantiates a client
-const logging = Logging({
- projectId: projectId
-});
-
-// The name of the log to write to
-const logName = 'my-log';
-// Selects the log to write to
-const log = logging.log(logName);
-
-// The data to write to the log
-const text = 'Hello, world!';
-// The metadata associated with the entry
-const metadata = { resource: { type: 'global' } };
-// Prepares a log entry
-const entry = log.entry(metadata, text);
-
-// Writes the log entry
-log.write(entry)
- .then(() => {
- console.log(`Logged: ${text}`);
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
-// [END logging_quickstart]
diff --git a/logging/sinks.js b/logging/sinks.js
deleted file mode 100644
index 965657a299..0000000000
--- a/logging/sinks.js
+++ /dev/null
@@ -1,212 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-function createSink (sinkName, bucketName, filter) {
- // [START logging_create_sink]
- // Imports the Google Cloud client libraries
- const Logging = require('@google-cloud/logging');
- const Storage = require('@google-cloud/storage');
-
- // Instantiates clients
- const logging = Logging();
- const storage = Storage();
-
- // The name of the sink, e.g. "my-sink"
- // const sinkName = "my-sink";
-
- // The destination bucket, e.g. "my-bucket"
- // const bucketName = "my-bucket";
-
- // An option log filter, e.g. "severity=ERROR"
- // const filter = "severity=ERROR";
-
- // The destination can be a Cloud Storage bucket, a Cloud Pub/Sub topic,
- // or a BigQuery dataset. In this case, it is a Cloud Storage Bucket.
- // See https://cloud.google.com/logging/docs/api/tasks/exporting-logs for
- // information on the destination format.
- const destination = storage.bucket(bucketName);
- const sink = logging.sink(sinkName);
-
- /**
- * The filter determines which logs this sink matches and will be exported
- * to the destination. For example a filter of 'severity>=INFO' will send
- * all logs that have a severity of INFO or greater to the destination.
- * See https://cloud.google.com/logging/docs/view/advanced_filters for more
- * filter information.
- */
- const config = {
- destination: destination,
- filter: filter
- };
-
- // See https://googlecloudplatform.github.io/google-cloud-node/#/docs/logging/latest/logging/sink?method=create
- sink.create(config)
- .then(() => {
- console.log(`Created sink ${sinkName} to ${bucketName}`);
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END logging_create_sink]
-}
-
-function getSinkMetadata (sinkName) {
- // [START logging_get_sink]
- // Imports the Google Cloud client library
- const Logging = require('@google-cloud/logging');
-
- // Instantiates a client
- const logging = Logging();
-
- // The sink to retrieve, e.g. "my-sink"
- // const sinkName = "my-sink";
-
- const sink = logging.sink(sinkName);
-
- // See https://googlecloudplatform.github.io/google-cloud-node/#/docs/logging/latest/logging/sink?method=getMetadata
- sink.getMetadata()
- .then((results) => {
- const metadata = results[0];
-
- console.log(`Name: ${metadata.name}`);
- console.log(`Destination: ${metadata.destination}`);
- console.log(`Filter: ${metadata.filter}`);
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END logging_get_sink]
-}
-
-function listSinks () {
- // [START logging_list_sinks]
- // Imports the Google Cloud client library
- const Logging = require('@google-cloud/logging');
-
- // Instantiates a client
- const logging = Logging();
-
- // See https://googlecloudplatform.github.io/google-cloud-node/#/docs/logging/latest/logging?method=getSinks
- logging.getSinks()
- .then((results) => {
- const sinks = results[0];
-
- console.log('Sinks:');
- sinks.forEach((sink) => {
- console.log(sink.name);
- console.log(` Destination: ${sink.metadata.destination}`);
- console.log(` Filter: ${sink.metadata.filter}`);
- });
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END logging_list_sinks]
-}
-
-function updateSink (sinkName, filter) {
- // [START logging_update_sink]
- // Imports the Google Cloud client library
- const Logging = require('@google-cloud/logging');
-
- // Instantiates a client
- const logging = Logging();
-
- // The sink to update, e.g. "my-sink"
- // const sinkName = "my-sink";
-
- // The the filter for the sink, e.g. "severity >= WARNING"
- // const filter = "severity >= WARNING";
-
- const sink = logging.sink(sinkName);
-
- /**
- * The filter determines which logs this sink matches and will be exported
- * to the destination. For example a filter of 'severity>=INFO' will send
- * all logs that have a severity of INFO or greater to the destination.
- * See https://cloud.google.com/logging/docs/view/advanced_filters for more
- * filter information.
- */
- const metadata = {
- filter: filter
- };
-
- // See https://googlecloudplatform.github.io/google-cloud-node/#/docs/logging/latest/logging/sink?method=setMetadata
- sink.setMetadata(metadata)
- .then((results) => {
- console.log(`Sink ${sinkName} updated.`);
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END logging_update_sink]
-}
-
-function deleteSink (sinkName) {
- // [START logging_delete_sink]
- // Imports the Google Cloud client library
- const Logging = require('@google-cloud/logging');
-
- // Instantiates a client
- const logging = Logging();
-
- // The sink to delete, e.g. "my-sink"
- // const sinkName = "my-sink";
-
- const sink = logging.sink(sinkName);
-
- // See https://googlecloudplatform.github.io/google-cloud-node/#/docs/logging/latest/logging/sink?method=delete
- sink.delete()
- .then((results) => {
- console.log(`Sink ${sinkName} deleted.`);
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END logging_delete_sink]
-}
-
-// The command-line program
-const cli = require(`yargs`)
- .demand(1)
- .command('create [filter]', 'Creates a new sink with the given name to the specified bucket with an optional filter.', {}, (opts) => {
- createSink(opts.sinkName, opts.bucketName, opts.filter);
- })
- .command('get ', 'Gets the metadata for the specified sink.', {}, (opts) => {
- getSinkMetadata(opts.sinkName);
- })
- .command('list', 'Lists all sinks.', {}, listSinks)
- .command('update ', 'Updates the filter for the specified sink.', {}, (opts) => {
- updateSink(opts.sinkName, opts.filter);
- })
- .command('delete ', 'Deletes the specified sink.', {}, (opts) => {
- deleteSink(opts.sinkName);
- })
- .example('node $0 create export-errors app-error-logs', 'Create a new sink named "export-errors" that exports logs to a bucket named "app-error-logs".')
- .example('node $0 get export-errors', 'Get the metadata for a sink name "export-errors".')
- .example('node $0 list', 'List all sinks.')
- .example('node $0 update export-errors "severity >= WARNING"', 'Update the filter for a sink named "export-errors".')
- .example('node $0 delete export-errors', 'Delete a sink named "export-errors".')
- .wrap(120)
- .recommendCommands()
- .epilogue(`For more information, see https://cloud.google.com/logging/docs`)
- .help()
- .strict();
-
-if (module === require.main) {
- cli.parse(process.argv.slice(2));
-}
diff --git a/logging/system-test/logs.test.js b/logging/system-test/logs.test.js
deleted file mode 100644
index 746f1de7bd..0000000000
--- a/logging/system-test/logs.test.js
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const path = require(`path`);
-const test = require(`ava`);
-const tools = require(`@google-cloud/nodejs-repo-tools`);
-const uuid = require(`uuid`);
-
-const cwd = path.join(__dirname, `..`);
-const cmd = `node logs.js`;
-
-const logName = `nodejs-docs-samples-test-${uuid.v4()}`;
-const message = `Hello world!`;
-
-test.before(tools.checkCredentials);
-
-test.serial(`should write a log entry`, async (t) => {
- const output = await tools.runAsync(`${cmd} write ${logName} '{"type":"global"}' '{"message":"${message}"}'`, cwd);
- t.is(output, `Wrote to ${logName}`);
-});
-
-test.serial(`should write a simple log entry`, async (t) => {
- const output = await tools.runAsync(`${cmd} write-simple ${logName}`, cwd);
- t.is(output, `Wrote to ${logName}`);
-});
-
-test.serial(`should write using winston`, async (t) => {
- const output = await tools.runAsync(`${cmd} winston`, cwd);
- t.is(output.includes('99%'), true);
-});
-
-test.serial(`should write using bunyan`, async (t) => {
- const output = await tools.runAsync(`${cmd} bunyan`, cwd);
- t.is(output.includes('99%'), true);
-});
diff --git a/logging/system-test/quickstart.test.js b/logging/system-test/quickstart.test.js
deleted file mode 100644
index f8107001b4..0000000000
--- a/logging/system-test/quickstart.test.js
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const proxyquire = require(`proxyquire`).noPreserveCache();
-const sinon = require(`sinon`);
-const test = require(`ava`);
-const tools = require(`@google-cloud/nodejs-repo-tools`);
-const uuid = require(`uuid`);
-
-const logging = proxyquire(`@google-cloud/logging`, {})();
-
-const logName = `nodejs-docs-samples-test-${uuid.v4()}`;
-
-test.after.always(async () => {
- try {
- await logging.log(logName).delete();
- } catch (err) {} // ignore error
-});
-
-test.beforeEach(tools.stubConsole);
-test.afterEach.always(tools.restoreConsole);
-
-test.cb(`should log an entry`, (t) => {
- const expectedlogName = `my-log`;
-
- const logMock = {
- entry: sinon.stub().returns({}),
- write: (_entry) => {
- t.deepEqual(_entry, {});
-
- const log = logging.log(logName);
- const text = `Hello, world!`;
- const entry = log.entry({ resource: { type: `global` } }, text);
-
- return log.write(entry)
- .then((results) => {
- setTimeout(() => {
- try {
- t.true(console.log.calledOnce);
- t.deepEqual(console.log.firstCall.args, [`Logged: ${text}`]);
- t.end();
- } catch (err) {
- t.end(err);
- }
- }, 200);
-
- return results;
- });
- }
- };
- const loggingMock = {
- log: (_logName) => {
- t.is(_logName, expectedlogName);
- return logMock;
- }
- };
-
- proxyquire(`../quickstart`, {
- '@google-cloud/logging': sinon.stub().returns(loggingMock)
- });
-});
diff --git a/logging/system-test/sinks.test.js b/logging/system-test/sinks.test.js
deleted file mode 100644
index 3b91eee1d5..0000000000
--- a/logging/system-test/sinks.test.js
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const logging = require('@google-cloud/logging')();
-const path = require(`path`);
-const storage = require('@google-cloud/storage')();
-const test = require(`ava`);
-const tools = require(`@google-cloud/nodejs-repo-tools`);
-const uuid = require(`uuid`);
-
-const cwd = path.join(__dirname, `..`);
-const cmd = `node sinks.js`;
-
-const bucketName = `nodejs-docs-samples-test-${uuid.v4()}`;
-const sinkName = `nodejs-docs-samples-test-${uuid.v4()}`;
-const filter = `severity > WARNING`;
-
-test.before(tools.checkCredentials);
-test.before(async (t) => {
- await storage.createBucket(bucketName);
-});
-
-test.after.always(async (t) => {
- try {
- await logging.sink(sinkName).delete();
- } catch (err) {} // ignore error
- try {
- await storage.bucket(bucketName).delete();
- } catch (err) {} // ignore error
-});
-
-test.serial(`should create a sink`, async (t) => {
- const output = await tools.runAsync(`${cmd} create ${sinkName} ${bucketName} "${filter}"`, cwd);
- t.is(output, `Created sink ${sinkName} to ${bucketName}`);
- const [metadata] = await logging.sink(sinkName).getMetadata();
- t.is(metadata.name, sinkName);
- t.is(metadata.destination.includes(bucketName), true);
- t.is(metadata.filter, filter);
-});
-
-test.serial(`should get a sink`, async (t) => {
- const output = await tools.runAsync(`${cmd} get ${sinkName}`, cwd);
- t.is(output.includes(sinkName), true);
-});
-
-test.serial(`should list sinks`, async (t) => {
- t.plan(0);
- await tools.tryTest(async (assert) => {
- const output = await tools.runAsync(`${cmd} list`, cwd);
- assert(output.includes(`Sinks:`));
- assert(output.includes(sinkName));
- }).start();
-});
-
-test.serial(`should update a sink`, async (t) => {
- const newFilter = 'severity >= WARNING';
- const output = await tools.runAsync(`${cmd} update ${sinkName} "${newFilter}"`, cwd);
- t.is(output, `Sink ${sinkName} updated.`);
- const [metadata] = await logging.sink(sinkName).getMetadata();
- t.is(metadata.name, sinkName);
- t.is(metadata.destination.includes(bucketName), true);
- t.is(metadata.filter, newFilter);
-});
-
-test.serial(`should delete a sink`, async (t) => {
- const output = await tools.runAsync(`${cmd} delete ${sinkName}`, cwd);
- t.is(output, `Sink ${sinkName} deleted.`);
- await t.throws(logging.sink(sinkName).getMetadata());
-});
diff --git a/logging/test/fluent.test.js b/logging/test/fluent.test.js
deleted file mode 100644
index 60fb62c1e3..0000000000
--- a/logging/test/fluent.test.js
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const proxyquire = require(`proxyquire`).noPreserveCache();
-const request = require(`supertest`);
-const test = require(`ava`);
-
-test.cb(`should log error`, (t) => {
- let loggerCalled = false;
-
- const structuredLogger = {
- emit: (name) => {
- loggerCalled = true;
- t.is(name, `errors`);
- }
- };
-
- const app = proxyquire(`../fluent`, {
- 'fluent-logger': {
- createFluentSender: (name, options) => {
- t.is(name, `myapp`);
- t.deepEqual(options, {
- host: `localhost`,
- port: 24224,
- timeout: 3.0
- });
- return structuredLogger;
- }
- }
- });
-
- request(app)
- .get(`/`)
- .expect(500)
- .expect(() => {
- t.true(loggerCalled, `structuredLogger.emit should have been called`);
- })
- .end(t.end);
-});
diff --git a/monitoring/README.md b/monitoring/README.md
index 520c781ead..e7c77167e3 100644
--- a/monitoring/README.md
+++ b/monitoring/README.md
@@ -1,128 +1,5 @@
-
+Samples for the [Stackdriver Monitoring API Node.js Client][client] have moved
+to [github.com/googleapis/nodejs-monitoring/tree/master/samples/][samples].
-# Stackdriver Monitoring Node.js Samples
-
-[]()
-
-[Stackdriver Monitoring](https://cloud.google.com/monitoring/docs) 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](#setup)
-* [Samples](#samples)
- * [Metrics](#metrics)
- * [Listing resources](#listing-resources)
- * [Custom metrics](#custom-metrics)
-* [Running the tests](#running-the-tests)
-
-## Setup
-
-1. Read [Prerequisites][prereq] and [How to run a sample][run] first.
-1. Install dependencies:
-
- With **npm**:
-
- npm install
-
- With **yarn**:
-
- yarn install
-
-[prereq]: ../README.md#prerequisites
-[run]: ../README.md#how-to-run-a-sample
-
-## Samples
-
-### Metrics
-
-View the [documentation][metrics_0_docs] or the [source code][metrics_0_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 [projectId] Get a metric descriptor.
- delete [projectId] Deletes a custom metric descriptor.
- write [projectId] Writes example time series data to
- 'custom.googleapis.com/stores/daily_sales'.
- read [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 [projectId] Get a monitored resource descriptor.
-
-Options:
- --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
-```
-
-[metrics_0_docs]: https://cloud.google.com/monitoring/docs
-[metrics_0_code]: metrics.js
-
-### Listing resources
-
-View the [documentation][list_1_docs] or the [source code][list_1_code].
-
-`list_resources.js` is a command-line program to demonstrate connecting to the
-Google Monitoring API to retrieve API data.
-
-__Usage:__ `node list_resources `
-
-```
-node list_resources my-cool-project
-```
-
-[list_1_docs]: https://cloud.google.com/monitoring/demos/#hello-world
-[list_1_code]: list_resources.js
-
-### Custom metrics
-
-View the [documentation][metrics_2_docs] or the [source code][metrics_2_code].
-
-`create_custom_metric.js` demonstrates how to create a custom metric, write a
-timeseries value to it, and read it back.
-
-__Usage:__ `node create_custom_metric `
-
-```
-node create_custom_metric my-cool-project
-```
-
-[metrics_2_docs]: https://cloud.google.com/monitoring/demos/#custom_metrics
-[metrics_2_code]: create_custom_metric.js
-
-## Running the tests
-
-1. Set the **GCLOUD_PROJECT** and **GOOGLE_APPLICATION_CREDENTIALS** environment variables.
-
-1. Run the tests:
-
- With **npm**:
-
- npm test
-
- With **yarn**:
-
- yarn test
+[client]: https://github.com/googleapis/nodejs-monitoring
+[samples]: https://github.com/googleapis/nodejs-monitoring/tree/master/samples
diff --git a/monitoring/metrics.js b/monitoring/metrics.js
deleted file mode 100644
index ee3a5c0c25..0000000000
--- a/monitoring/metrics.js
+++ /dev/null
@@ -1,583 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * This application demonstrates how to perform basic operations on metrics with
- * the Google Stackdriver Monitoring API.
- *
- * For more information, see the README.md under /monitoring and the
- * documentation at https://cloud.google.com/monitoring/docs.
- */
-
-'use strict';
-
-function createMetricDescriptor (projectId) {
- // [START monitoring_create_metric]
- // Imports the Google Cloud client library
- const Monitoring = require('@google-cloud/monitoring');
-
- // Creates a client
- const client = Monitoring.v3.metric();
-
- // The Google Cloud Platform project on which to execute the request
- // const projectId = 'YOUR_PROJECT_ID';
-
- const request = {
- name: client.projectPath(projectId),
- metricDescriptor: {
- description: 'Daily sales records from all branch stores.',
- displayName: 'Daily Sales',
- type: 'custom.googleapis.com/stores/daily_sales',
- metricKind: 'GAUGE',
- valueType: 'DOUBLE',
- unit: '{USD}',
- labels: [
- {
- key: 'store_id',
- valueType: 'STRING',
- description: 'The ID of the store.'
- }
- ]
- }
- };
-
- // Creates a custom metric descriptor
- client.createMetricDescriptor(request)
- .then((results) => {
- const descriptor = results[0];
-
- console.log('Created custom Metric:\n');
- console.log(`Name: ${descriptor.displayName}`);
- console.log(`Description: ${descriptor.description}`);
- console.log(`Type: ${descriptor.type}`);
- console.log(`Kind: ${descriptor.metricKind}`);
- console.log(`Value Type: ${descriptor.valueType}`);
- console.log(`Unit: ${descriptor.unit}`);
- console.log('Labels:');
- descriptor.labels.forEach((label) => {
- console.log(` ${label.key} (${label.valueType}) - ${label.description}`);
- });
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END monitoring_create_metric]
-}
-
-function listMetricDescriptors (projectId) {
- // [START monitoring_list_descriptors]
- // Imports the Google Cloud client library
- const Monitoring = require('@google-cloud/monitoring');
-
- // Creates a client
- const client = Monitoring.v3.metric();
-
- // The Google Cloud Platform project on which to execute the request
- // const projectId = 'YOUR_PROJECT_ID';
-
- const request = {
- name: client.projectPath(projectId)
- };
-
- // Lists metric descriptors
- client.listMetricDescriptors(request)
- .then((results) => {
- const descriptors = results[0];
-
- console.log('Metric Descriptors:');
- descriptors.forEach((descriptor) => console.log(descriptor.name));
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END monitoring_list_descriptors]
-}
-
-function getMetricDescriptor (projectId, metricId) {
- // [START monitoring_get_descriptor]
- // Imports the Google Cloud client library
- const Monitoring = require('@google-cloud/monitoring');
-
- // Creates a client
- const client = Monitoring.v3.metric();
-
- // The Google Cloud Platform project on which to execute the request
- // const projectId = 'YOUR_PROJECT_ID';
-
- // An example of "metricId" is "logging.googleapis.com/log_entry_count"
- // const metricId = 'some/metric/id';
-
- const request = {
- name: client.metricDescriptorPath(projectId, metricId)
- };
-
- // Retrieves a metric descriptor
- client.getMetricDescriptor(request)
- .then((results) => {
- const descriptor = results[0];
-
- console.log(`Name: ${descriptor.displayName}`);
- console.log(`Description: ${descriptor.description}`);
- console.log(`Type: ${descriptor.type}`);
- console.log(`Kind: ${descriptor.metricKind}`);
- console.log(`Value Type: ${descriptor.valueType}`);
- console.log(`Unit: ${descriptor.unit}`);
- console.log('Labels:');
- descriptor.labels.forEach((label) => {
- console.log(` ${label.key} (${label.valueType}) - ${label.description}`);
- });
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END monitoring_get_descriptor]
-}
-
-function deleteMetricDescriptor (projectId, metricId) {
- // [START monitoring_delete_metric]
- // Imports the Google Cloud client library
- const Monitoring = require('@google-cloud/monitoring');
-
- // Creates a client
- const client = Monitoring.v3.metric();
-
- // The Google Cloud Platform project on which to execute the request
- // const projectId = 'YOUR_PROJECT_ID';
-
- // The ID of the Metric Descriptor to delete, e.g.
- // const metricId = 'custom.googleapis.com/stores/daily_sales';
-
- const request = {
- name: client.metricDescriptorPath(projectId, metricId)
- };
-
- // Deletes a metric descriptor
- client.deleteMetricDescriptor(request)
- .then((results) => {
- console.log(`Deleted ${metricId}`);
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END monitoring_delete_metric]
-}
-
-function writeTimeSeriesData (projectId, metricId) {
- // [START monitoring_write_timeseries]
- // Imports the Google Cloud client library
- const Monitoring = require('@google-cloud/monitoring');
-
- // Creates a client
- const client = Monitoring.v3.metric();
-
- // The Google Cloud Platform project on which to execute the request
- // const projectId = 'YOUR_PROJECT_ID';
-
- const dataPoint = {
- interval: {
- endTime: {
- seconds: Date.now() / 1000
- }
- },
- value: {
- doubleValue: 123.45
- }
- };
-
- const timeSeriesData = {
- metric: {
- type: 'custom.googleapis.com/stores/daily_sales',
- labels: {
- store_id: 'Pittsburgh'
- }
- },
- resource: {
- type: 'global',
- labels: {
- project_id: projectId
- }
- },
- points: [
- dataPoint
- ]
- };
-
- const request = {
- name: client.projectPath(projectId),
- timeSeries: [
- timeSeriesData
- ]
- };
-
- // Writes time series data
- client.createTimeSeries(request)
- .then((results) => {
- console.log(`Done writing time series data.`);
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END monitoring_write_timeseries]
-}
-
-function readTimeSeriesData (projectId, filter) {
- // [START monitoring_read_timeseries_simple]
- // Imports the Google Cloud client library
- const Monitoring = require('@google-cloud/monitoring');
-
- // Creates a client
- const client = Monitoring.v3.metric();
-
- // The Google Cloud Platform project on which to execute the request
- // const projectId = 'YOUR_PROJECT_ID';
-
- // An example "filter" is 'metric.type="compute.googleapis.com/instance/cpu/utilization"'
- // const filter = 'metric.type="compute.googleapis.com/instance/cpu/utilization"';
-
- const request = {
- name: client.projectPath(projectId),
- filter: filter,
- interval: {
- startTime: {
- // Limit results to the last 20 minutes
- seconds: (Date.now() / 1000) - (60 * 20)
- },
- endTime: {
- seconds: Date.now() / 1000
- }
- }
- };
-
- // Writes time series data
- client.listTimeSeries(request)
- .then((results) => {
- const timeSeries = results[0];
-
- timeSeries.forEach((data) => {
- console.log(`${data.metric.labels.instance_name}:`);
- data.points.forEach((point) => {
- console.log(JSON.stringify(point.value));
- });
- });
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END monitoring_read_timeseries_simple]
-}
-
-function readTimeSeriesFields (projectId) {
- // [START monitoring_read_timeseries_fields]
- // Imports the Google Cloud client library
- const Monitoring = require('@google-cloud/monitoring');
-
- // Creates a client
- const client = Monitoring.v3.metric();
-
- // The Google Cloud Platform project on which to execute the request
- // const projectId = 'YOUR_PROJECT_ID';
-
- const request = {
- name: client.projectPath(projectId),
- filter: 'metric.type="compute.googleapis.com/instance/cpu/utilization"',
- interval: {
- startTime: {
- // Limit results to the last 20 minutes
- seconds: (Date.now() / 1000) - (60 * 20)
- },
- endTime: {
- seconds: Date.now() / 1000
- }
- },
- // Don't return time series data, instead just return information about
- // the metrics that match the filter
- view: 'HEADERS'
- };
-
- // Writes time series data
- client.listTimeSeries(request)
- .then((results) => {
- const timeSeries = results[0];
-
- console.log('Found data points for the following instances:');
- timeSeries.forEach((data) => {
- console.log(data.metric.labels.instance_name);
- });
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END monitoring_read_timeseries_fields]
-}
-
-function readTimeSeriesAggregate (projectId) {
- // [START monitoring_read_timeseries_align]
- // Imports the Google Cloud client library
- const Monitoring = require('@google-cloud/monitoring');
-
- // Creates a client
- const client = Monitoring.v3.metric();
-
- // The Google Cloud Platform project on which to execute the request
- // const projectId = 'YOUR_PROJECT_ID';
-
- const request = {
- name: client.projectPath(projectId),
- filter: 'metric.type="compute.googleapis.com/instance/cpu/utilization"',
- interval: {
- startTime: {
- // Limit results to the last 20 minutes
- seconds: (Date.now() / 1000) - (60 * 20)
- },
- endTime: {
- seconds: Date.now() / 1000
- }
- },
- // Aggregate results per matching instance
- aggregation: {
- alignmentPeriod: {
- seconds: 600
- },
- perSeriesAligner: 'ALIGN_MEAN'
- }
- };
-
- // Writes time series data
- client.listTimeSeries(request)
- .then((results) => {
- const timeSeries = results[0];
-
- console.log('CPU utilization:');
- timeSeries.forEach((data) => {
- console.log(data.metric.labels.instance_name);
- console.log(` Now: ${data.points[0].value.doubleValue}`);
- console.log(` 10 min ago: ${data.points[1].value.doubleValue}`);
- });
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END monitoring_read_timeseries_align]
-}
-
-function readTimeSeriesReduce (projectId) {
- // [START monitoring_read_timeseries_reduce]
- // Imports the Google Cloud client library
- const Monitoring = require('@google-cloud/monitoring');
-
- // Creates a client
- const client = Monitoring.v3.metric();
-
- // The Google Cloud Platform project on which to execute the request
- // const projectId = 'YOUR_PROJECT_ID';
-
- const request = {
- name: client.projectPath(projectId),
- filter: 'metric.type="compute.googleapis.com/instance/cpu/utilization"',
- interval: {
- startTime: {
- // Limit results to the last 20 minutes
- seconds: (Date.now() / 1000) - (60 * 20)
- },
- endTime: {
- seconds: Date.now() / 1000
- }
- },
- // Aggregate results per matching instance
- aggregation: {
- alignmentPeriod: {
- seconds: 600
- },
- crossSeriesReducer: 'REDUCE_MEAN',
- perSeriesAligner: 'ALIGN_MEAN'
- }
- };
-
- // Writes time series data
- client.listTimeSeries(request)
- .then((results) => {
- const reductions = results[0][0].points;
-
- console.log('Average CPU utilization across all GCE instances:');
- console.log(` Last 10 min: ${reductions[0].value.doubleValue}`);
- console.log(` 10-20 min ago: ${reductions[0].value.doubleValue}`);
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END monitoring_read_timeseries_reduce]
-}
-
-function listMonitoredResourceDescriptors (projectId) {
- // [START monitoring_list_resources]
- // Imports the Google Cloud client library
- const Monitoring = require('@google-cloud/monitoring');
-
- // Creates a client
- const client = Monitoring.v3.metric();
-
- // The Google Cloud Platform project on which to execute the request
- // const projectId = 'YOUR_PROJECT_ID';
-
- const request = {
- name: client.projectPath(projectId)
- };
-
- // Lists monitored resource descriptors
- client.listMonitoredResourceDescriptors(request)
- .then((results) => {
- const descriptors = results[0];
-
- console.log('Monitored Resource Descriptors:');
- descriptors.forEach((descriptor) => console.log(descriptor.name));
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END monitoring_list_resources]
-}
-
-function getMonitoredResourceDescriptor (projectId, resourceType) {
- // [START monitoring_get_resource]
- // Imports the Google Cloud client library
- const Monitoring = require('@google-cloud/monitoring');
-
- // Creates a client
- const client = Monitoring.v3.metric();
-
- // The Google Cloud Platform project on which to execute the request
- // const projectId = 'YOUR_PROJECT_ID';
-
- // "resourceType" should be a predefined type, such as "cloudsql_database"
- // const resourceType = 'some_resource_type';
-
- const request = {
- name: client.monitoredResourceDescriptorPath(projectId, resourceType)
- };
-
- // Lists monitored resource descriptors
- client.getMonitoredResourceDescriptor(request)
- .then((results) => {
- const descriptor = results[0];
-
- console.log(`Name: ${descriptor.displayName}`);
- console.log(`Description: ${descriptor.description}`);
- console.log(`Type: ${descriptor.type}`);
- console.log('Labels:');
- descriptor.labels.forEach((label) => {
- console.log(` ${label.key} (${label.valueType}) - ${label.description}`);
- });
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
- // [END monitoring_get_resource]
-}
-
-const cli = require(`yargs`)
- .demand(1)
- .command(
- `create [projectId]`,
- `Creates an example 'custom.googleapis.com/stores/daily_sales' custom metric descriptor.`,
- {},
- (opts) => createMetricDescriptor(opts.projectId)
- )
- .command(
- `list [projectId]`,
- `Lists metric descriptors.`,
- {},
- (opts) => listMetricDescriptors(opts.projectId)
- )
- .command(
- `get [projectId]`,
- `Get a metric descriptor.`,
- {},
- (opts) => getMetricDescriptor(opts.projectId, opts.metricId)
- )
- .command(
- `delete [projectId]`,
- `Deletes a custom metric descriptor.`,
- {},
- (opts) => deleteMetricDescriptor(opts.projectId, opts.metricId)
- )
- .command(
- `write [projectId]`,
- `Writes example time series data to 'custom.googleapis.com/stores/daily_sales'.`,
- {},
- (opts) => writeTimeSeriesData(opts.projectId)
- )
- .command(
- `read [projectId]`,
- `Reads time series data that matches the given filter.`,
- {},
- (opts) => readTimeSeriesData(opts.projectId, opts.filter)
- )
- .command(
- `read-fields [projectId]`,
- `Reads headers of time series data that matches 'compute.googleapis.com/instance/cpu/utilization'.`,
- {},
- (opts) => readTimeSeriesFields(opts.projectId)
- )
- .command(
- `read-aggregate [projectId]`,
- `Aggregates time series data that matches 'compute.googleapis.com/instance/cpu/utilization'.`,
- {},
- (opts) => readTimeSeriesAggregate(opts.projectId)
- )
- .command(
- `read-reduce [projectId]`,
- `Reduces time series data that matches 'compute.googleapis.com/instance/cpu/utilization'.`,
- {},
- (opts) => readTimeSeriesReduce(opts.projectId)
- )
- .command(
- `list-resources [projectId]`,
- `Lists monitored resource descriptors.`,
- {},
- (opts) => listMonitoredResourceDescriptors(opts.projectId)
- )
- .command(
- `get-resource [projectId]`,
- `Get a monitored resource descriptor.`,
- {},
- (opts) => getMonitoredResourceDescriptor(opts.projectId, opts.resourceType)
- )
- .options({
- projectId: {
- alias: 'p',
- default: process.env.GCLOUD_PROJECT,
- global: true,
- requiresArg: true,
- type: 'string'
- }
- })
- .example(`node $0 create`)
- .example(`node $0 list`)
- .example(`node $0 get logging.googleapis.com/log_entry_count`)
- .example(`node $0 delete custom.googleapis.com/stores/daily_sales`)
- .example(`node $0 list-resources`)
- .example(`node $0 get-resource cloudsql_database`)
- .example(`node $0 write`)
- .example(`node $0 read 'metric.type="compute.googleapis.com/instance/cpu/utilization"'`)
- .example(`node $0 read-fields`)
- .example(`node $0 read-aggregate`)
- .example(`node $0 read-reduce`)
- .wrap(120)
- .recommendCommands()
- .epilogue(`For more information, see https://cloud.google.com/monitoring/docs`);
-
-if (module === require.main) {
- cli.help().strict().argv; // eslint-disable-line
-}
diff --git a/monitoring/package.json b/monitoring/package.json
deleted file mode 100644
index a69f0dd5b6..0000000000
--- a/monitoring/package.json
+++ /dev/null
@@ -1,43 +0,0 @@
-{
- "name": "nodejs-docs-samples-monitoring",
- "version": "0.0.1",
- "private": true,
- "license": "Apache-2.0",
- "author": "Google Inc.",
- "repository": {
- "type": "git",
- "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
- },
- "engines": {
- "node": ">=4.3.2"
- },
- "scripts": {
- "lint": "repo-tools lint",
- "pretest": "npm run lint",
- "test": "repo-tools test run --cmd ava -- -T 3m --verbose system-test/*.test.js"
- },
- "dependencies": {
- "@google-cloud/monitoring": "0.3.0",
- "yargs": "9.0.1"
- },
- "devDependencies": {
- "@google-cloud/nodejs-repo-tools": "2.0.4",
- "ava": "0.22.0",
- "proxyquire": "1.8.0",
- "sinon": "4.0.0"
- },
- "cloud-repo-tools": {
- "requiresKeyFile": true,
- "requiresProjectId": true,
- "product": "monitoring",
- "samples": [
- {
- "id": "metrics",
- "name": "Metrics",
- "file": "metrics.js",
- "docs_link": "https://cloud.google.com/monitoring/docs",
- "usage": "node metrics.js --help"
- }
- ]
- }
-}
diff --git a/monitoring/quickstart.js b/monitoring/quickstart.js
deleted file mode 100644
index ca66561fbb..0000000000
--- a/monitoring/quickstart.js
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-// [START monitoring_quickstart]
-// Imports the Google Cloud client library
-const Monitoring = require('@google-cloud/monitoring');
-
-// Your Google Cloud Platform project ID
-const projectId = 'YOUR_PROJECT_ID';
-
-// Creates a client
-const client = Monitoring.v3.metric();
-
-// Prepares an individual data point
-const dataPoint = {
- interval: {
- endTime: {
- seconds: Date.now() / 1000
- }
- },
- value: {
- // The amount of sales
- doubleValue: 123.45
- }
-};
-
-// Prepares the time series request
-const request = {
- name: client.projectPath(projectId),
- timeSeries: [
- {
- // Ties the data point to a custom metric
- metric: {
- type: 'custom.googleapis.com/stores/daily_sales',
- labels: {
- store_id: 'Pittsburgh'
- }
- },
- resource: {
- type: 'global',
- labels: {
- project_id: projectId
- }
- },
- points: [
- dataPoint
- ]
- }
- ]
-};
-
-// Writes time series data
-client.createTimeSeries(request)
- .then((results) => {
- console.log(`Done writing time series data.`);
- })
- .catch((err) => {
- console.error('ERROR:', err);
- });
-// [END monitoring_quickstart]
diff --git a/monitoring/system-test/metrics.test.js b/monitoring/system-test/metrics.test.js
deleted file mode 100644
index 5b534209a9..0000000000
--- a/monitoring/system-test/metrics.test.js
+++ /dev/null
@@ -1,185 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const client = require(`@google-cloud/monitoring`).v3.metric();
-const path = require(`path`);
-const test = require(`ava`);
-const tools = require(`@google-cloud/nodejs-repo-tools`);
-
-const cmd = `node metrics.js`;
-const cwd = path.join(__dirname, `..`);
-const customMetricId = `custom.googleapis.com/stores/daily_sales`;
-const computeMetricId = `compute.googleapis.com/instance/cpu/utilization`;
-const filter = `metric.type="${computeMetricId}"`;
-const projectId = process.env.GCLOUD_PROJECT;
-const resourceId = `cloudsql_database`;
-
-test.before(tools.checkCredentials);
-
-test.serial(`should create a metric descriptors`, async (t) => {
- const output = await tools.runAsync(`${cmd} create`, cwd);
- t.true(output.includes(`Created custom Metric`));
- t.true(output.includes(`Type: ${customMetricId}`));
-});
-
-test.serial(`should list metric descriptors, including the new custom one`, async (t) => {
- t.plan(0);
- const attempt = tools.tryTest(async (assert) => {
- const output = await tools.runAsync(`${cmd} list`, cwd);
- assert(output.includes(customMetricId));
- assert(output.includes(computeMetricId));
- });
- attempt.tries(30);
- attempt.timeout(120000);
- await attempt.start();
-});
-
-test.serial(`should get a metric descriptor`, async (t) => {
- t.plan(0);
- const attempt = tools.tryTest(async (assert) => {
- const output = await tools.runAsync(`${cmd} get ${customMetricId}`, cwd);
- assert(output.includes(`Type: ${customMetricId}`));
- });
- attempt.tries(30);
- attempt.timeout(120000);
- await attempt.start();
-});
-
-test.serial(`should write time series data`, async (t) => {
- const output = await tools.runAsync(`${cmd} write`, cwd);
- t.true(output.includes(`Done writing time series data.`));
-});
-
-test.serial(`should delete a metric descriptor`, async (t) => {
- const output = await tools.runAsync(`${cmd} delete ${customMetricId}`, cwd);
- t.true(output.includes(`Deleted ${customMetricId}`));
-});
-
-test(`should list monitored resource descriptors`, async (t) => {
- const output = await tools.runAsync(`${cmd} list-resources`, cwd);
- t.true(output.includes(`projects/${projectId}/monitoredResourceDescriptors/${resourceId}`));
-});
-
-test(`should get a monitored resource descriptor`, async (t) => {
- const output = await tools.runAsync(`${cmd} get-resource ${resourceId}`, cwd);
- t.true(output.includes(`Type: ${resourceId}`));
-});
-
-test(`should read time series data`, async (t) => {
- const [timeSeries] = await client.listTimeSeries({
- name: client.projectPath(projectId),
- filter: filter,
- interval: {
- startTime: {
- // Limit results to the last 20 minutes
- seconds: (Date.now() / 1000) - (60 * 20)
- },
- endTime: {
- seconds: Date.now() / 1000
- }
- }
- });
- const output = await tools.runAsync(`${cmd} read '${filter}'`, cwd);
- timeSeries.forEach((data) => {
- t.true(output.includes(`${data.metric.labels.instance_name}:`));
- data.points.forEach((point) => {
- t.true(output.includes(JSON.stringify(point.value)));
- });
- });
-});
-
-test(`should read time series data fields`, async (t) => {
- const [timeSeries] = await client.listTimeSeries({
- name: client.projectPath(projectId),
- filter: filter,
- interval: {
- startTime: {
- // Limit results to the last 20 minutes
- seconds: (Date.now() / 1000) - (60 * 20)
- },
- endTime: {
- seconds: Date.now() / 1000
- }
- },
- // Don't return time series data, instead just return information about
- // the metrics that match the filter
- view: `HEADERS`
- });
- const output = await tools.runAsync(`${cmd} read-fields`, cwd);
- t.true(output.includes(`Found data points for the following instances:`));
- timeSeries.forEach((data) => {
- t.true(output.includes(data.metric.labels.instance_name));
- });
-});
-
-test(`should read time series data aggregated`, async (t) => {
- const [timeSeries] = await client.listTimeSeries({
- name: client.projectPath(projectId),
- filter: filter,
- interval: {
- startTime: {
- // Limit results to the last 20 minutes
- seconds: (Date.now() / 1000) - (60 * 20)
- },
- endTime: {
- seconds: Date.now() / 1000
- }
- },
- // Aggregate results per matching instance
- aggregation: {
- alignmentPeriod: {
- seconds: 600
- },
- perSeriesAligner: `ALIGN_MEAN`
- }
- });
- const output = await tools.runAsync(`${cmd} read-aggregate`, cwd);
- t.true(output.includes(`CPU utilization:`));
- timeSeries.forEach((data) => {
- t.true(output.includes(data.metric.labels.instance_name));
- t.true(output.includes(` Now: ${data.points[0].value.doubleValue}`));
- t.true(output.includes(` 10 min ago: ${data.points[1].value.doubleValue}`));
- });
-});
-
-test(`should read time series data reduced`, async (t) => {
- await client.listTimeSeries({
- name: client.projectPath(projectId),
- filter: filter,
- interval: {
- startTime: {
- // Limit results to the last 20 minutes
- seconds: (Date.now() / 1000) - (60 * 20)
- },
- endTime: {
- seconds: Date.now() / 1000
- }
- },
- // Aggregate results per matching instance
- aggregation: {
- alignmentPeriod: {
- seconds: 600
- },
- crossSeriesReducer: `REDUCE_MEAN`,
- perSeriesAligner: `ALIGN_MEAN`
- }
- });
- const output = await tools.runAsync(`${cmd} read-reduce`, cwd);
- t.true(output.includes(`Average CPU utilization across all GCE instances:`));
- t.true(output.includes(` Last 10 min`));
- t.true(output.includes(` 10-20 min ago`));
-});
diff --git a/monitoring/system-test/quickstart.test.js b/monitoring/system-test/quickstart.test.js
deleted file mode 100644
index 4386d412e7..0000000000
--- a/monitoring/system-test/quickstart.test.js
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright 2017, Google, Inc.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-const proxyquire = require(`proxyquire`).noPreserveCache();
-const sinon = require(`sinon`);
-const test = require(`ava`);
-const tools = require(`@google-cloud/nodejs-repo-tools`);
-
-const client = proxyquire(`@google-cloud/monitoring`, {}).v3.metric();
-
-test.beforeEach(tools.stubConsole);
-test.afterEach.always(tools.restoreConsole);
-
-test.cb(`should list time series`, (t) => {
- const clientMock = {
- projectPath: (projectId) => client.projectPath(projectId),
- createTimeSeries: (_request) => {
- _request.name = client.projectPath(process.env.GCLOUD_PROJECT);
- _request.timeSeries[0].resource.labels.project_id = process.env.GCLOUD_PROJECT;
-
- return client.createTimeSeries(_request)
- .then((result) => {
- setTimeout(() => {
- try {
- t.is(console.log.callCount, 1);
- t.deepEqual(console.log.getCall(0).args, [`Done writing time series data.`]);
- t.end();
- } catch (err) {
- t.end(err);
- }
- }, 200);
-
- return result;
- });
- }
- };
-
- proxyquire(`../quickstart`, {
- '@google-cloud/monitoring': {
- v3: {
- metric: sinon.stub().returns(clientMock)
- }
- }
- });
-});
diff --git a/storage/README.md b/storage/README.md
index d4bc05b823..50986adb60 100644
--- a/storage/README.md
+++ b/storage/README.md
@@ -1,5 +1,5 @@
Samples for the [Google Cloud Storage Node.js Client][client] have moved to
-[github.com/googleapis/nodejs-storage: samples/][samples].
+[github.com/googleapis/nodejs-storage/tree/master/samples/][samples].
[client]: https://github.com/googleapis/nodejs-storage
[samples]: https://github.com/googleapis/nodejs-storage/tree/master/samples