Skip to content

feat: expose parameter insights as Prometheus metrics #10574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 9, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Parameters are exposed
  • Loading branch information
mtojek committed Nov 8, 2023
commit f83f31effcc08a1a317159eccaeddfad9b8ba7a7
8 changes: 6 additions & 2 deletions coderd/prometheusmetrics/insights/metricscollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
var (
templatesActiveUsersDesc = prometheus.NewDesc("coderd_insights_templates_active_users", "The number of active users of the template.", []string{"template_name"}, nil)
applicationsUsageSecondsDesc = prometheus.NewDesc("coderd_insights_applications_usage_seconds", "The application usage per template.", []string{"template_name", "application_name", "slug"}, nil)
parametersDesc = prometheus.NewDesc("coderd_insights_parameters", "The parameter usage per template.", []string{"template_name", "parameter_name", "parameter_value"}, nil)
parametersDesc = prometheus.NewDesc("coderd_insights_parameters", "The parameter usage per template.", []string{"template_name", "parameter_name", "parameter_type", "parameter_value"}, nil)
)

type MetricsCollector struct {
Expand All @@ -44,6 +44,7 @@ type insightsData struct {
type parameterRow struct {
templateID uuid.UUID
name string
aType string
value string

count int64
Expand Down Expand Up @@ -230,7 +231,7 @@ func (mc *MetricsCollector) Collect(metricsCh chan<- prometheus.Metric) {

// Parameters
for _, parameterRow := range data.params {
metricsCh <- prometheus.MustNewConstMetric(parametersDesc, prometheus.GaugeValue, float64(parameterRow.count), data.templateNames[parameterRow.templateID], parameterRow.name, parameterRow.value)
metricsCh <- prometheus.MustNewConstMetric(parametersDesc, prometheus.GaugeValue, float64(parameterRow.count), data.templateNames[parameterRow.templateID], parameterRow.name, parameterRow.aType, parameterRow.value)
}
}

Expand Down Expand Up @@ -269,6 +270,7 @@ func convertParameterInsights(rows []database.GetTemplateParameterInsightsRow) [
type uniqueKey struct {
templateID uuid.UUID
parameterName string
parameterType string
parameterValue string
}

Expand All @@ -278,6 +280,7 @@ func convertParameterInsights(rows []database.GetTemplateParameterInsightsRow) [
key := uniqueKey{
templateID: t,
parameterName: r.Name,
parameterType: r.Type,
parameterValue: r.Value,
}

Expand All @@ -294,6 +297,7 @@ func convertParameterInsights(rows []database.GetTemplateParameterInsightsRow) [
converted[i] = parameterRow{
templateID: k.templateID,
name: k.parameterName,
aType: k.parameterType,
value: k.parameterValue,
count: c,
}
Expand Down