google-cloudmonitoring
Version:
Simple interface for Google Cloud Monitoring
41 lines (27 loc) • 1.16 kB
Markdown
A simple node.js wrapper arround the [Google Cloud Monitoring API](https://cloud.google.com/monitoring/api/v3/)
```bash
npm install google-cloudmonitoring
```
1. Enable *Google Cloud Monitoring API* in your Google Developer Console.
2. The library will autodetect an existing [GCloud](https://cloud.google.com/sdk/downloads)
installation or tries to pull the service account from the
[](https://cloud.google.com/compute/docs/storing-retrieving-metadata).
3. Include it into your app!
```javascript
const GLM = require('google-cloudmonitoring')('v3');
// resource is optional, if not GLM will try to detect the
// resource information using GCE instance metadata
const resource = { 'type': 'gce_instance',
'labels': { 'instance_id': 'your-instance-id',
'zone': 'us-central1-a' }};
const glm = new GLM({ resource });
const value = 42;
glm.on('error', function (err) {
console.log('Something bad happened:', err.message);
})
glm.setValue('/your/metric/name', value, { '/your/label': 'glm' });
```