Skip to content
This repository was archived by the owner on Jun 21, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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
73 changes: 32 additions & 41 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions models/agent_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (
MongoDBExporterType AgentType = "mongodb_exporter"
QANMySQLPerfSchemaAgentType AgentType = "qan-mysql-perfschema-agent"
PostgresExporterType AgentType = "postgres_exporter"
QANMongoDBProfilerAgentType AgentType = "qan-mongodb-profiler-agent"
)

// Agent represents Agent as stored in database.
Expand Down
32 changes: 23 additions & 9 deletions services/agents/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,28 @@ func mongodbExporterConfig(service *models.Service, exporter *models.Agent) *age

sort.Strings(args)

connString := mongoDSN(service, exporter)

return &agentpb.SetStateRequest_AgentProcess{
Type: agentpb.Type_MONGODB_EXPORTER,
TemplateLeftDelim: tdp.left,
TemplateRightDelim: tdp.right,
Args: args,
Env: []string{
fmt.Sprintf("MONGODB_URI=%s", connString),
},
}
}

// qanMongoDBProfilerAgentConfig returns desired configuration of qan-mongodb-profiler-agent built-in agent.
func qanMongoDBProfilerAgentConfig(service *models.Service, exporter *models.Agent) *agentpb.SetStateRequest_BuiltinAgent {
return &agentpb.SetStateRequest_BuiltinAgent{
Type: agentpb.Type_QAN_MONGODB_PROFILER_AGENT,
Dsn: mongoDSN(service, exporter),
}
}

func mongoDSN(service *models.Service, exporter *models.Agent) string {
host := pointer.GetString(service.Address)
port := pointer.GetUint16(service.Port)

Expand All @@ -64,13 +86,5 @@ func mongodbExporterConfig(service *models.Service, exporter *models.Agent) *age
connURL.User = url.UserPassword(username, password)
}

return &agentpb.SetStateRequest_AgentProcess{
Type: agentpb.Type_MONGODB_EXPORTER,
TemplateLeftDelim: tdp.left,
TemplateRightDelim: tdp.right,
Args: args,
Env: []string{
fmt.Sprintf("MONGODB_URI=%s", connURL.String()),
},
}
return connURL.String()
}
2 changes: 1 addition & 1 deletion services/agents/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func mysqldExporterConfig(service *models.Service, exporter *models.Agent) *agen
}
}

// qanMySQLPerfSchemaAgentConfig returns desired configuration of qan-mysql-perfschema internal agent.
// qanMySQLPerfSchemaAgentConfig returns desired configuration of qan-mysql-perfschema built-in agent.
func qanMySQLPerfSchemaAgentConfig(service *models.Service, exporter *models.Agent) *agentpb.SetStateRequest_BuiltinAgent {
return &agentpb.SetStateRequest_BuiltinAgent{
Type: agentpb.Type_QAN_MYSQL_PERFSCHEMA_AGENT,
Expand Down
12 changes: 12 additions & 0 deletions services/agents/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,18 @@ func (r *Registry) SendSetStateRequest(ctx context.Context, pmmAgentID string) {
}
agentProcesses[row.AgentID] = postgresExporterConfig(services[0], row)

case models.QANMongoDBProfilerAgentType:
services, err := models.ServicesForAgent(r.db.Querier, row.AgentID)
if err != nil {
l.Error(err)
return
}
if len(services) != 1 {
l.Errorf("Expected exactly one Services, got %d.", len(services))
return
}
builtinAgents[row.AgentID] = qanMongoDBProfilerAgentConfig(services[0], row)

default:
l.Panicf("unhandled Agent type %s", row.AgentType)
}
Expand Down
Loading