googleapis / googleapis/google-cloud-node

Stackdriver Monitoring v4.0.0 raising errors when try to write TimeSeries

Open
#5,348 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3.2k
Forks
712
Avg merge
2d 3h
Merged PRs (30d)
99

Description

#### Environment details

- which product (packages/*): Stackdriver Monitoring v4.0.0
- OS: Ubuntu 22.04 LTS
- Node.js version: v20.8.1
- npm version:
- google-cloud-node version: 4.0.0

#### Steps to reproduce

```
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.MetricServiceClient();

const jobBillableTimeInMinutes = (job.billable_time_ms / 1000) / 60;
const metricType = `custom.googleapis.com/workflow/${resource_name}/job-duration`;

const dataPoint = {
interval: {
endTime: {
seconds: Date.now() / 1000
},
},
value: {
doubleValue: jobBillableTimeInMinutes
},
};

const timeSeriesData = {
metric: {
type: metricType,
labels: {
run_id: run_id,
job_name: job.name
},
},
resource: {
type: 'global',
labels: {
project_id: project_id,
},
},
points: [dataPoint],
};

const request = {
name: client.projectPath(project_id),
timeSeries: [timeSeriesData],
};

console.log("Sending data to Google Cloud Monitoring")
await client.createTimeSeries(request);
```

The provided code snippet throws the following error:

```
Error: 3 INVALID_ARGUMENT: One or more TimeSeries could not be written: One or more points were written more frequently than the maximum sampling period configured for the metric.: global{} timeSeries[0]:
```

The same code works with @google-cloud/monitoring: 3.0.5.

Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.