Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix: get last 10 versions in getConfigHistory

nityanandagohaindfef41913f61
diff --git a/pkg/query-service/agentConf/db.go b/pkg/query-service/agentConf/db.go
index 591a7ee799..c3a84f6b3a 100644
--- a/pkg/query-service/agentConf/db.go
+++ b/pkg/query-service/agentConf/db.go
@@ -31,11 +31,11 @@ func (r *Repo) initDB(engine string) error {
}
}
-func (r *Repo) GetConfigHistory(ctx context.Context, typ ElementTypeDef) ([]ConfigVersion, error) {
+func (r *Repo) GetConfigHistory(ctx context.Context, typ ElementTypeDef, limit int) ([]ConfigVersion, error) {
var c []ConfigVersion
- err := r.db.SelectContext(ctx, &c, `SELECT
- id,
+ err := r.db.SelectContext(ctx, &c, fmt.Sprintf(`SELECT
version,
+ id,
element_type,
COALESCE(created_by, -1) as created_by,
created_at,
@@ -45,9 +45,14 @@ func (r *Repo) GetConfigHistory(ctx context.Context, typ ElementTypeDef) ([]Conf
is_valid,
disabled,
deploy_status,
- deploy_result
+ deploy_result,
+ last_hash,
+ last_config
FROM agent_config_versions AS v
- WHERE element_type = $1`, typ)
+ WHERE element_type = $1
+ ORDER BY created_at desc, version desc
+ limit %v`, limit),
+ typ)
return c, err
}
@@ -57,7 +62,7 @@ func (r *Repo) GetConfigVersion(ctx context.Context, typ ElementTypeDef, v int)
err := r.db.GetContext(ctx, &c, `SELECT
id,
version,
- element_type,
+ element_type,
COALESCE(created_by, -1) as created_by,
created_at,
COALESCE((SELECT NAME FROM users
diff --git a/pkg/query-service/agentConf/manager.go b/pkg/query-service/agentConf/manager.go
index 27478b332a..f189ba9756 100644
--- a/pkg/query-service/agentConf/manager.go
+++ b/pkg/query-service/agentConf/manager.go
@@ -51,8 +51,8 @@ func GetConfigVersion(ctx context.Context, elementType ElementTypeDef, version i
return m.GetConfigVersion(ctx, elementType, version)
}
-func GetConfigHistory(ctx context.Context, typ ElementTypeDef) ([]ConfigVersion, error) {
- return m.GetConfigHistory(ctx, typ)
+func GetConfigHistory(ctx context.Context, typ ElementTypeDef, limit int) ([]ConfigVersion, error) {
+ return m.GetConfigHistory(ctx, typ, limit)
}
// StartNewVersion launches a new config version for given set of elements