Skip to content

Commit

Permalink
timeseries used;
Browse files Browse the repository at this point in the history
  • Loading branch information
Muneeb147 committed Oct 24, 2024
1 parent a9827f1 commit 208151e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dump_ci_stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GCP_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS }}
run: |
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 }}
node source/dump-ci-stats-to-gcp-metrics.js ${{ github.event.workflow_run.id }}
39 changes: 21 additions & 18 deletions source/dump-ci-stats-to-gcp-metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,33 @@ async function sendMetricsToGCP(metricType, metricValue, labels) {

const request = {
name: monitoring.projectPath(projectId),
resource: {
type: 'global',
labels: {
project_id: projectId
}
},
metric: {
type: `custom.googleapis.com/${metricType}`,
labels: labels
},
points: [
timeSeries: [ // Ensure this field is present
{
interval: {
endTime: {
seconds: Math.floor(Date.now() / 1000)
metric: {
type: `custom.googleapis.com/${metricType}`,
labels: labels
},
resource: {
type: 'global', // or you can specify more appropriate types like gce_instance, k8s_container, etc.
labels: {
project_id: projectId
}
},
value: {
doubleValue: metricValue
}
points: [
{
interval: {
endTime: {
seconds: Math.floor(Date.now() / 1000),
}
},
value: {
doubleValue: metricValue
}
}
]
}
]
};

try {
await monitoring.createTimeSeries(request);
console.log(`Metric ${metricType} sent successfully.`);
Expand Down

0 comments on commit 208151e

Please sign in to comment.