Detalhes do pacote

@google-cloud/monitoring

googleapis527.1kApache-2.05.2.0

Stackdriver Monitoring API client for Node.js

google apis client, google api client, google apis, google api

readme (leia-me)

Google Cloud Platform logo

Stackdriver Monitoring: Node.js Client

release level npm version

Stackdriver Monitoring API client for Node.js

A comprehensive list of changes in each version may be found in the CHANGELOG.

Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.

Table of contents:

Quickstart

Before you begin

  1. Select or create a Cloud Platform project.
  2. Enable billing for your project.
  3. Enable the Stackdriver Monitoring API.
  4. Set up authentication so you can access the API from your local workstation.

Installing the client library

npm install @google-cloud/monitoring

Using the client library

// Imports the Google Cloud client library
const monitoring = require('@google-cloud/monitoring');

async function quickstart() {
  // Creates a client
  const client = new monitoring.MetricServiceClient();

  // TODO(developer): Uncomment and set the following variables
  // const projectId = "PROJECT_ID"

  // 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
  const [result] = await client.createTimeSeries(request);
  console.log('Done writing time series data.', result);
}
quickstart();

Samples

Samples are in the samples/ directory. Each sample's README.md has instructions for running its sample.

Sample Source Code Try it
Alert_policy_service.create_alert_policy source code Open in Cloud Shell
Alert_policy_service.delete_alert_policy source code Open in Cloud Shell
Alert_policy_service.get_alert_policy source code Open in Cloud Shell
Alert_policy_service.list_alert_policies source code Open in Cloud Shell
Alert_policy_service.update_alert_policy source code Open in Cloud Shell
Group_service.create_group source code Open in Cloud Shell
Group_service.delete_group source code Open in Cloud Shell
Group_service.get_group source code Open in Cloud Shell
Group_service.list_group_members source code Open in Cloud Shell
Group_service.list_groups source code Open in Cloud Shell
Group_service.update_group source code Open in Cloud Shell
Metric_service.create_metric_descriptor source code Open in Cloud Shell
Metric_service.create_service_time_series source code Open in Cloud Shell
Metric_service.create_time_series source code Open in Cloud Shell
Metric_service.delete_metric_descriptor source code Open in Cloud Shell
Metric_service.get_metric_descriptor source code Open in Cloud Shell
Metric_service.get_monitored_resource_descriptor source code Open in Cloud Shell
Metric_service.list_metric_descriptors source code Open in Cloud Shell
Metric_service.list_monitored_resource_descriptors source code Open in Cloud Shell
Metric_service.list_time_series source code Open in Cloud Shell
Notification_channel_service.create_notification_channel source code Open in Cloud Shell
Notification_channel_service.delete_notification_channel source code Open in Cloud Shell
Notification_channel_service.get_notification_channel source code Open in Cloud Shell
Notification_channel_service.get_notification_channel_descriptor source code Open in Cloud Shell
Notification_channel_service.get_notification_channel_verification_code source code Open in Cloud Shell
Notification_channel_service.list_notification_channel_descriptors source code Open in Cloud Shell
Notification_channel_service.list_notification_channels source code Open in Cloud Shell
Notification_channel_service.send_notification_channel_verification_code source code Open in Cloud Shell
Notification_channel_service.update_notification_channel source code Open in Cloud Shell
Notification_channel_service.verify_notification_channel source code Open in Cloud Shell
Query_service.query_time_series source code Open in Cloud Shell
Service_monitoring_service.create_service source code Open in Cloud Shell
Service_monitoring_service.create_service_level_objective source code Open in Cloud Shell
Service_monitoring_service.delete_service source code Open in Cloud Shell
Service_monitoring_service.delete_service_level_objective source code Open in Cloud Shell
Service_monitoring_service.get_service source code Open in Cloud Shell
Service_monitoring_service.get_service_level_objective source code Open in Cloud Shell
Service_monitoring_service.list_service_level_objectives source code Open in Cloud Shell
Service_monitoring_service.list_services source code Open in Cloud Shell
Service_monitoring_service.update_service source code Open in Cloud Shell
Service_monitoring_service.update_service_level_objective source code Open in Cloud Shell
Snooze_service.create_snooze source code Open in Cloud Shell
Snooze_service.get_snooze source code Open in Cloud Shell
Snooze_service.list_snoozes source code Open in Cloud Shell
Snooze_service.update_snooze source code Open in Cloud Shell
Uptime_check_service.create_uptime_check_config source code Open in Cloud Shell
Uptime_check_service.delete_uptime_check_config source code Open in Cloud Shell
Uptime_check_service.get_uptime_check_config source code Open in Cloud Shell
Uptime_check_service.list_uptime_check_configs source code Open in Cloud Shell
Uptime_check_service.list_uptime_check_ips source code Open in Cloud Shell
Uptime_check_service.update_uptime_check_config source code Open in Cloud Shell
Quickstart source code Open in Cloud Shell

The Stackdriver Monitoring Node.js Client API Reference documentation also contains samples.

Supported Node.js Versions

Our client libraries follow the Node.js release schedule. Libraries are compatible with all current active and maintenance versions of Node.js. If you are using an end-of-life version of Node.js, we recommend that you update as soon as possible to an actively supported LTS version.

Google's client libraries support legacy versions of Node.js runtimes on a best-efforts basis with the following warnings:

  • Legacy versions are not tested in continuous integration.
  • Some security patches and features cannot be backported.
  • Dependencies cannot be kept up-to-date.

Client libraries targeting some end-of-life versions of Node.js are available, and can be installed through npm dist-tags. The dist-tags follow the naming convention legacy-(version). For example, npm install @google-cloud/monitoring@legacy-8 installs client libraries for versions compatible with Node.js 8.

Versioning

This library follows Semantic Versioning.

This library is considered to be stable. The code surface will not change in backwards-incompatible ways unless absolutely necessary (e.g. because of critical security issues) or with an extensive deprecation period. Issues and requests against stable libraries are addressed with the highest priority.

More Information: Google Cloud Platform Launch Stages

Contributing

Contributions welcome! See the Contributing Guide.

Please note that this README.md, the samples/README.md, and a variety of configuration files in this repository (including .nycrc and tsconfig.json) are generated from a central template. To edit one of these files, make an edit to its templates in directory.

License

Apache Version 2.0

See LICENSE

changelog (log de mudanças)

Changelog

npm history

5.2.0 (2025-06-03)

Features

5.1.0 (2025-05-09)

Features

  • Multiple ai-platform updates (0b8b1a7)

5.0.1 (2025-03-19)

Bug Fixes

  • [Many APIs] await/catch promises, and update listOperationsAsync return type (#6186) (dcfc7b4)

5.0.0 (2025-03-18)

⚠ BREAKING CHANGES

  • upgrade to Node 18 (#6096)

Miscellaneous Chores

4.1.0 (2024-05-21)

Features

  • [Many APIs] update Nodejs generator to send API versions in headers for GAPICs (#5351) (01f48fc)
  • [Many APIs] update Nodejs generator to send API versions in headers for GAPICs (#5354) (a9784ed)

4.0.0 (2023-08-06)

⚠ BREAKING CHANGES

  • migrate to Node 14 (#4443)

Miscellaneous Chores

3.0.5 (2023-06-28)

Bug Fixes

3.0.4 (2023-04-13)

Bug Fixes

3.0.3 (2022-11-11)

Bug Fixes

3.0.2 (2022-09-09)

Bug Fixes

3.0.1 (2022-08-23)

Bug Fixes

3.0.0 (2022-05-20)

⚠ BREAKING CHANGES

  • update library to use Node 12 (#617)

Build System

2.3.5 (2021-09-08)

Bug Fixes

2.3.4 (2021-08-17)

Bug Fixes

2.3.3 (2021-07-16)

Bug Fixes

2.3.3 (2021-07-16)

Bug Fixes

2.3.2 (2021-06-29)

Bug Fixes

2.3.1 (2021-05-12)

Bug Fixes

2.3.0 (2021-03-24)

Features

  • Added support for Monitoring Query Language: https://cloud.google.com/monitoring/mql feat: Added support for units in the MetricService feat: Added total_size to the response of ListAlertPolicies. fix: Un-deprecated cluster_istio for service monitoring. feat: Added IstioCanonicalService for service monitoring. feat: Added creation and mutation records to notification channels. feat: Added support for querying metrics for folders and organizations. fix: Extended the default deadline for UpdateGroup to 180s. feat: Added support for secondary aggregation when querying metrics. (#523) (cab3fdb)

2.2.0 (2021-01-09)

Features

2.1.5 (2021-01-07)

Bug Fixes

  • update alert policies one at a time because (concurrent updates are not supported) (#507) (2bf75a2)

2.1.4 (2020-11-25)

Bug Fixes

2.1.3 (2020-11-07)

Bug Fixes

  • do not modify options object, use defaultScopes (#497) (447cfce)

2.1.2 (2020-09-12)

Bug Fixes

  • deps: update dependency yargs to v16 (#480) (188c55a)

2.1.1 (2020-07-24)

Bug Fixes

  • move gitattributes files to node templates (#464) (db2d19d)

2.1.0 (2020-06-18)

Features

  • move ts target to es2018 from es2016 (#440) (f57200d)

Bug Fixes

2.0.0 (2020-05-08)

⚠ BREAKING CHANGES

  • Drop support for TimeSeriesQueryLanguageCondition as an alert condition type
  • The library now supports Node.js v10+. The last version to support Node.js v8 is tagged legacy-8 on NPM.
  • monitoring convert to typescript (#360)

Features

  • deferred client initialization (#378) (61eca6a)
  • drop node8 support, support for async iterators (#396) (d65e8fb)
  • export protos in src/index.ts (#369) (b0af4b1)
  • monitoring convert to typescript (#360) (5bbd963)
  • refresh monitoring client libraries (#401) (efd6e6f)
  • Update public client library for Cloud Monitoring to introduce new Uptime check feature. Uptime HTTP(S) checks can now be GET or POST (#425) (103afde)

Bug Fixes

  • regen protos and tests, formatting (#429) (9e6afc8)
  • remove eslint, update gax, fix generated protos, run the generator (#415) (ed8d95e)
  • synth.py clean up for multiple version (#431) (4e0e5bb)
  • updated proto files with new proto annotations (cf8cc77)

Code Refactoring

  • Drop support for TimeSeriesQueryLanguageCondition as an alert condition type (866c028)

1.7.0 (2019-12-31)

Features

1.6.1 (2019-12-05)

Bug Fixes

  • deps: TypeScript 3.7.0 causes breaking change in typings (#339) (3616df7)
  • deps: update dependency yargs to v15 (#333) (dd3ba97)
  • docs: bump release level to GA (#335) (839a25b)

1.6.0 (2019-11-15)

Features

  • add service api support (#325) (dbc3680)
  • Introduced detailed status message for CreateTimeSeries: CreateTimeSeriesSummary replaces CreateTimeSeriesError, which is now deprecated and unused (46e0661)

Bug Fixes

  • docs: snippets are now replaced in jsdoc comments (#324) (6d81605)

1.5.0 (2019-10-22)

Features

Bug Fixes

1.4.0 (2019-10-12)

Features

Bug Fixes

  • update sample for enabling or disabling a policy (#305) (fd84c71)
  • use compatible version of google-gax (c210d32)

1.3.0 (2019-09-16)

Bug Fixes

  • deps: update dependency yargs to v14 (68a0867)
  • include the correct version of node in a header (#286) (0c758f9)

Features

  • load protos from JSON, grpc-fallback support (435c5d0)
  • GroupServiceClient: support recursive option when deleting group (#294) (f7749af)

1.2.3 (2019-08-03)

Bug Fixes

  • allow calls with no request, add JSON proto (3a8a89b)

1.2.2 (2019-06-26)

Bug Fixes

  • docs: link to reference docs section on googleapis.dev (#273) (d4056d6)

1.2.1 (2019-06-14)

Bug Fixes

1.2.0 (2019-06-06)

Features

  • add .repo-metadata for README generation (#263) (d966bd6)

1.1.0 (2019-06-05)

Features

  • support apiEndpoint override in client constructor (#265) (8a413bc)

1.0.0 (2019-05-20)

⚠ BREAKING CHANGES

  • upgrade engines field to >=8.10.0 (#241)

Bug Fixes

  • include 'x-goog-request-params' header in requests (#233) (54733ef)
  • deps: update dependency google-gax to ^0.26.0 (#240) (da50ee8)
  • deps: update dependency google-gax to v1 (#249) (896141a)

Build System

v0.7.1

03-13-2019 15:05 PDT

Bug Fixes

  • fix: throw on invalid credentials (#216)

Dependencies

  • fix(deps): update dependency google-gax to ^0.25.0 (#204)

Documentation

  • docs: update links in contrib guide (#215)
  • docs: update contributing path in README (#210)
  • docs: move CONTRIBUTING.md to root (#209)
  • docs: add lint/fix example to contributing guide (#206)

Internal / Testing Changes

  • refactor: update json import paths (#224)
  • chore(deps): update dependency p-retry to v4 (#223)
  • build: Add docuploader credentials to node publish jobs (#221)
  • build: use node10 to run samples-test, system-test etc (#220)
  • build: update release configuration
  • chore: update proto docs and code style
  • chore(deps): update dependency mocha to v6 (#217)
  • refactor: update the generated code style (#208)
  • build: use linkinator for docs test (#214)
  • fix(deps): update dependency yargs to v13 (#213)
  • build: create docs test npm scripts (#212)
  • build: test using @grpc/grpc-js in CI (#211)
  • chore(deps): update dependency eslint-config-prettier to v4 (#203)
  • build: ignore googleapis.com in doc link check (#201)
  • chore: update year in the license headers. (#200)

v0.7.0

01-15-2019 09:35 PST

Dependencies

  • fix(deps): update dependency google-gax to ^0.23.0 (#196)
  • refactor: remove unused deps

Documentation

  • doc: remove unused gRPC types
  • docs: add samples for channel notification (#185)
  • docs: update readme badges (#171)
  • docs(samples): convert samples to async/await, and use mocha for tests (#146)
  • docs: update proto comments (#159)
  • docs: fix link in changelog (#132)

Internal / Testing Changes

  • build: check broken links in generated docs (#194)
  • refactor: modernize and fix the sample tests (#193)
  • chore: fix name of region tag (#188)
  • chore: fix region tags (#187)
  • chore(build): inject yoshi automation key (#186)
  • chore: update nyc and eslint configs (#184)
  • chore: fix publish.sh permission +x (#182)
  • fix(build): fix Kokoro release script (#181)
  • build: add Kokoro configs for autorelease (#180)
  • chore: always nyc report before calling codecov (#177)
  • chore: nyc ignore build/test by default (#175)
  • chore: update license file (#173)
  • fix(build): fix system key decryption (#169)
  • chore: add a synth.metadata
  • test: fix failing tests due to leaks (#163)
  • chore: update eslintignore config (#160)
  • chore(deps): update dependency @google-cloud/nodejs-repo-tools to v3 (#158)
  • chore: drop contributors from multiple places (#156)
  • chore: use latest npm on Windows (#154)
  • chore: update CircleCI config (#151)
  • chore: include build in eslintignore (#148)
  • chore(deps): update dependency eslint-plugin-node to v8 (#143)
  • feat: run the generator
  • chore: update new issue templates
  • chore(build): fix the synth file and generation
  • chore: remove old issue template (#140)
  • build: run tests on node11 (#139)
  • chores(build): do not collect sponge.xml from windows builds (#138)
  • chores(build): run codecov on continuous builds (#137)
  • build: fix codecov uploading on Kokoro (#134)
  • chore(deps): update dependency sinon to v7 (#133)
  • chore(deps): update dependency eslint-plugin-prettier to v3 (#131)
  • test: remove appveyor config (#127)
  • Fix failing sample tests (#126)
  • Enable prefer-const in the eslint config (#124)
  • Fix the linter (#123)
  • Enable no-var in eslint (#122)
  • run synth.py to fix system-test (#117)
  • Retry npm install in CI (#115)
  • Update CircleCI and Kokoro config (#113)
  • chore(deps): update dependency nyc to v13 (#111)
  • Update the CI config (#109)
  • chore: make the CircleCI config consistent
  • fix(deps): update dependency @google-cloud/monitoring to ^0.6.0 (#104)
  • chore(build): make the CircleCI config consistent
  • build: node templates (#101)

v0.6.0

01-14-2019 14:34 PST

Dependencies

  • fix(deps): update dependency google-gax to ^0.23.0 (#196)
  • refactor: remove unused deps

Documentation

  • docs: remove unused gRPC types
  • docs(samples): add samples for channel notification (#185)
  • docs: update readme badges (#171)
  • docs(samples): convert samples to async/await, and use mocha for tests (#146)
  • docs: update proto comments (#159)
  • docs: fix link in changelog (#132)

Internal / Testing Changes

  • refactor: modernize and fix the sample tests (#193)
  • chore: fix name of region tag (#188)
  • chore: fix region tags (#187)
  • chore(build): inject yoshi automation key (#186)
  • chore: update nyc and eslint configs (#184)
  • chore: fix publish.sh permission +x (#182)
  • fix(build): fix Kokoro release script (#181)
  • build: add Kokoro configs for autorelease (#180)
  • chore: always nyc report before calling codecov (#177)
  • chore: nyc ignore build/test by default (#175)
  • chore: update license file (#173)
  • fix(build): fix system key decryption (#169)
  • chore: add a synth.metadata
  • test: fix failing tests due to leaks (#163)
  • chore: update eslintignore config (#160)
  • chore(deps): update dependency @google-cloud/nodejs-repo-tools to v3 (#158)
  • chore: drop contributors from multiple places (#156)
  • chore: use latest npm on Windows (#154)
  • chore: update CircleCI config (#151)
  • chore: include build in eslintignore (#148)
  • chore(deps): update dependency eslint-plugin-node to v8 (#143)
  • chore: update new issue templates
  • chore(build): fix the synth file and generation
  • chore: remove old issue template (#140)
  • build: run tests on node11 (#139)
  • chores(build): do not collect sponge.xml from windows builds (#138)
  • chores(build): run codecov on continuous builds (#137)
  • build: fix codecov uploading on Kokoro (#134)
  • chore(deps): update dependency sinon to v7 (#133)
  • chore(deps): update dependency eslint-plugin-prettier to v3 (#131)
  • test: remove appveyor config (#127)
  • Fix failing sample tests (#126)
  • Enable prefer-const in the eslint config (#124)
  • Fix the linter (#123)
  • Enable no-var in eslint (#122)
  • run synth.py to fix system-test (#117)
  • Retry npm install in CI (#115)
  • Update CircleCI and Kokoro config (#113)
  • chore(deps): update dependency nyc to v13 (#111)
  • Update the CI config (#109)
  • chore: make the CircleCI config consistent
  • fix(deps): update dependency @google-cloud/monitoring to ^0.6.0 (#104)
  • chore(build): make the CircleCI config consistent
  • build: node templates (#101)

v0.6.0

Implementation Changes

BREAKING CHANGE

  • fix: drop support for node.js 4.x and 9.x (#72)

New Features

Bring in some documentation changes inside protos (see #96)

Dependencies

  • chore(deps): update dependency eslint-config-prettier to v3 (#97)
  • fix(deps): update dependency google-gax to ^0.18.0 (#88)
  • chore(deps): update dependency eslint-plugin-node to v7 (#80)
  • chore(deps): update dependency sinon to v6 (#64)
  • fix(deps): update dependency yargs to v12 (#65)
  • chore: check in synth script and update gax dependency (#62)
  • chore(package): update eslint to version 5.0.0 (#57)
  • chore(package): update nyc to version 12.0.2 (#53)

Documentation

  • doc: Fix namespace causing 404s (#99)

Internal / Testing Changes

  • chore: ignore package-lock.json (#93)
  • test: add sample for updating an uptime check (#95)
  • chore: update renovate config (#90)
  • chore: move mocha options to mocha.opts (#85)
  • chore: require node 8 for samples (#86)
  • test: use strictEqual in tests (#81)
  • chore: really delete node4 and node9 (#73)
  • Configure Renovate (#56)
  • refactor: drop repo-tool as an exec wrapper (#61)
  • fix: update linking for samples (#58)
  • chore: the ultimate fix for repo-tools EPERM (#50)
  • test: fix uptime sample test (#48)
  • chore: timeout for system test (#49)
  • test: add resource type filter to alerts test (#46)
  • Fixes #43. (#44)
  • Fix region tags. (#42)
  • Add Alerting samples. (#41)
  • chore: test on node10 (#40)