Skip to content

feat: export metrics to CastAI#195

Merged
Trojan295 merged 13 commits intomainfrom
kube-1330/export-metrics
Aug 18, 2025
Merged

feat: export metrics to CastAI#195
Trojan295 merged 13 commits intomainfrom
kube-1330/export-metrics

Conversation

@Trojan295
Copy link
Copy Markdown
Contributor

@Trojan295 Trojan295 commented Aug 5, 2025

This PR adds metric export from cluster-controller to Cast AI. It uses the ComponentsAPI IngestMetric endpoint. It gathers metrics registered in the Prometheus client, but right now only Counter metrics and exported (we have just 1 Counter metrics now).

This functionally it disabled by default and can be enabled with METRICS_EXPORT_ENABLED=true environment variable.

image

@Trojan295 Trojan295 marked this pull request as ready for review August 5, 2025 12:58
@Trojan295 Trojan295 requested a review from a team as a code owner August 5, 2025 12:58
})
}

if metric.Counter != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this redundant, after line 202 you know it's not nil

log.Fatalf("failed to create castai client: %v", err)
}

client := castai.NewClient(logger, cl, cfg.ClusterID)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be empty locally, is it a problem?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pod_name label value will be empty, but it's not a problem.

}()

if cfg.Metrics.ExportEnabled {
metricExporter := metricexporter.New(log, client, cfg.Metrics.ExportInterval)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add a log that this is enabled so we know

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a log in metricExporter.Run():

me.log.Infof("starting metrics exporter with interval %v", me.exportInterval)

@Tsonov
Copy link
Copy Markdown
Contributor

Tsonov commented Aug 11, 2025

As long as we can HARD block a client on the server side (so we don't get ddos, even if it's a mistake), this LGTM

@Trojan295 Trojan295 merged commit 1042cdc into main Aug 18, 2025
5 of 6 checks passed
@Trojan295 Trojan295 deleted the kube-1330/export-metrics branch August 18, 2025 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants