mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: make agent stats' cardinality configurable (#12468)
Closes #12221
This commit is contained in:
+24
-4
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -14,6 +15,8 @@ import (
|
||||
"golang.org/x/mod/semver"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/coder/coder/v2/coderd/agentmetrics"
|
||||
|
||||
"github.com/coreos/go-oidc/v3/oidc"
|
||||
|
||||
"github.com/coder/coder/v2/buildinfo"
|
||||
@@ -255,10 +258,11 @@ type DERPConfig struct {
|
||||
}
|
||||
|
||||
type PrometheusConfig struct {
|
||||
Enable clibase.Bool `json:"enable" typescript:",notnull"`
|
||||
Address clibase.HostPort `json:"address" typescript:",notnull"`
|
||||
CollectAgentStats clibase.Bool `json:"collect_agent_stats" typescript:",notnull"`
|
||||
CollectDBMetrics clibase.Bool `json:"collect_db_metrics" typescript:",notnull"`
|
||||
Enable clibase.Bool `json:"enable" typescript:",notnull"`
|
||||
Address clibase.HostPort `json:"address" typescript:",notnull"`
|
||||
CollectAgentStats clibase.Bool `json:"collect_agent_stats" typescript:",notnull"`
|
||||
CollectDBMetrics clibase.Bool `json:"collect_db_metrics" typescript:",notnull"`
|
||||
AggregateAgentStatsBy clibase.StringArray `json:"aggregate_agent_stats_by" typescript:",notnull"`
|
||||
}
|
||||
|
||||
type PprofConfig struct {
|
||||
@@ -942,6 +946,22 @@ when required by your organization's security policy.`,
|
||||
Group: &deploymentGroupIntrospectionPrometheus,
|
||||
YAML: "collect_agent_stats",
|
||||
},
|
||||
{
|
||||
Name: "Prometheus Aggregate Agent Stats By",
|
||||
Description: fmt.Sprintf("When collecting agent stats, aggregate metrics by a given set of comma-separated labels to reduce cardinality. Accepted values are %s.", strings.Join(agentmetrics.LabelAll, ", ")),
|
||||
Flag: "prometheus-aggregate-agent-stats-by",
|
||||
Env: "CODER_PROMETHEUS_AGGREGATE_AGENT_STATS_BY",
|
||||
Value: clibase.Validate(&c.Prometheus.AggregateAgentStatsBy, func(value *clibase.StringArray) error {
|
||||
if value == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return agentmetrics.ValidateAggregationLabels(value.Value())
|
||||
}),
|
||||
Group: &deploymentGroupIntrospectionPrometheus,
|
||||
YAML: "aggregate_agent_stats_by",
|
||||
Default: strings.Join(agentmetrics.LabelAll, ","),
|
||||
},
|
||||
{
|
||||
Name: "Prometheus Collect Database Metrics",
|
||||
Description: "Collect database metrics (may increase charges for metrics storage).",
|
||||
|
||||
Reference in New Issue
Block a user