Skip to content

Commit 208151e

Browse files
committed
timeseries used;
1 parent a9827f1 commit 208151e

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

.github/workflows/dump_ci_stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ jobs:
2626
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2727
GCP_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS }}
2828
run: |
29-
node source/dump-ci-stats-to-gcp-logs.js ${{ github.event.workflow_run.id }} && node source/dump-ci-stats-to-gcp-metrics.js ${{ github.event.workflow_run.id }}
29+
node source/dump-ci-stats-to-gcp-metrics.js ${{ github.event.workflow_run.id }}

source/dump-ci-stats-to-gcp-metrics.js

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,33 @@ async function sendMetricsToGCP(metricType, metricValue, labels) {
1919

2020
const request = {
2121
name: monitoring.projectPath(projectId),
22-
resource: {
23-
type: 'global',
24-
labels: {
25-
project_id: projectId
26-
}
27-
},
28-
metric: {
29-
type: `custom.googleapis.com/${metricType}`,
30-
labels: labels
31-
},
32-
points: [
22+
timeSeries: [ // Ensure this field is present
3323
{
34-
interval: {
35-
endTime: {
36-
seconds: Math.floor(Date.now() / 1000)
24+
metric: {
25+
type: `custom.googleapis.com/${metricType}`,
26+
labels: labels
27+
},
28+
resource: {
29+
type: 'global', // or you can specify more appropriate types like gce_instance, k8s_container, etc.
30+
labels: {
31+
project_id: projectId
3732
}
3833
},
39-
value: {
40-
doubleValue: metricValue
41-
}
34+
points: [
35+
{
36+
interval: {
37+
endTime: {
38+
seconds: Math.floor(Date.now() / 1000),
39+
}
40+
},
41+
value: {
42+
doubleValue: metricValue
43+
}
44+
}
45+
]
4246
}
4347
]
4448
};
45-
4649
try {
4750
await monitoring.createTimeSeries(request);
4851
console.log(`Metric ${metricType} sent successfully.`);

0 commit comments

Comments
 (0)