crowdsecurity/crowdsec · error
no machineID or bouncerName set
Error message
no machineID or bouncerName set
What it means
UsageMetrics ingestion must attribute metrics either to a log processor machine or a remediation component (bouncer). updateBaseMetrics dispatches on machineID or the bouncer object; if neither is present in the request/auth context, metrics cannot be attributed and it returns this error.
Source
Thrown at pkg/apiserver/controllers/v1/usagemetrics.go:27
"github.com/gin-gonic/gin"
"github.com/go-openapi/strfmt"
log "github.com/sirupsen/logrus"
"github.com/crowdsecurity/crowdsec/pkg/database/ent"
"github.com/crowdsecurity/crowdsec/pkg/database/ent/metric"
"github.com/crowdsecurity/crowdsec/pkg/models"
)
// updateBaseMetrics updates the base metrics for a machine or bouncer
func (c *Controller) updateBaseMetrics(ctx context.Context, machineID string, bouncer *ent.Bouncer, baseMetrics models.BaseMetrics, hubItems models.HubItems, datasources map[string]int64) error {
switch {
case machineID != "":
return c.DBClient.MachineUpdateBaseMetrics(ctx, machineID, baseMetrics, hubItems, datasources)
case bouncer != nil:
return c.DBClient.BouncerUpdateBaseMetrics(ctx, bouncer.Name, bouncer.Type, baseMetrics)
default:
return errors.New("no machineID or bouncerName set")
}
}
// UsageMetrics receives metrics from log processors and remediation components
func (c *Controller) UsageMetrics(gctx *gin.Context) {
var input models.AllMetrics
logger := log.WithField("func", "UsageMetrics")
// parse the payload
if err := gctx.ShouldBindJSON(&input); err != nil {
logger.Errorf("Failed to bind json: %s", err)
gctx.JSON(http.StatusBadRequest, gin.H{"message": err.Error()})
return
}
View on GitHub (pinned to 909b515798)
Solutions
- Upgrade the sending component (crowdsec agent or bouncer) so it includes its machine/bouncer identity in metrics payloads.
- Verify the client authenticates with a machine or bouncer token known to the LAPI (re-register if the DB entry is gone).
- Check the metrics request payload includes the identifier fields expected by the endpoint.
Example fix
// before (custom metrics client)
req, _ := http.NewRequest("POST", url+"/usage-metrics", body) // no auth/identity
// after
req, _ := http.NewRequest("POST", url+"/usage-metrics", body)
req.Header.Set("Authorization", "Bearer <machine-or-bouncer-token>") Defensive patterns
Strategy: validation
Validate before calling
if metrics.MachineID == "" && metrics.BouncerName == "" {
return errors.New("metrics payload must identify a machine or bouncer")
} Try / catch
resp, err := client.Post(ctx, "/usage-metrics", payload)
if err != nil {
log.Warnf("usage metrics rejected: %v", err) // non-fatal for the component
} Prevention
- Keep agents and bouncers up to date so identity fields are sent.
- Authenticate metrics submissions with valid machine/bouncer tokens.
- Skip metrics reporting gracefully — it must never block the main workflow.
When it happens
Trigger: POST to the usage-metrics endpoint where the payload/metadata contains no machine identifier and no bouncer identity — e.g. an unauthenticated or malformed metrics submission, or a client (old crowdsec/bouncer version) that doesn't send its identity fields.
Common situations: Custom scripts hitting the metrics endpoint without identifying headers; outdated bouncers predating usage-metrics identity fields; metrics posted via LAPI tokens that don't resolve to a machine or bouncer record in the DB.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- appsec datasource requires a hub. this is a bug, please repo
- appsec datasource requires a lapi client configuration. this
- missing lapi client credentials
- client not initialized
- missing TLS key file
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/bddbb53507682c6c.
Report an issue: GitHub.