Skip to content

Commit

Permalink
PMM-508612634 Helpers push metrics fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriCtvrtka committed Dec 2, 2024
1 parent e72961b commit b420d9b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions managed/models/agent_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ import (
"github.com/percona/pmm/version"
)

const (
// TODO figure out why it is included as PushMetrics not push_metrics
pushMetricsTrue = "((exporter_options ? 'PushMetrics') AND (exporter_options->>'PushMetrics')::boolean = true)"
pushMetricsFalse = "(NOT (exporter_options ? 'PushMetrics') OR (exporter_options->>'PushMetrics')::boolean = false)"
)

// MySQLOptionsParams contains methods to create MySQLOptions object.
type MySQLOptionsParams interface {
GetTlsCa() string
Expand Down Expand Up @@ -473,9 +479,9 @@ func FindAgentsForScrapeConfig(q *reform.Querier, pmmAgentID *string, pushMetric
}

if pushMetrics {
conditions = append(conditions, "push_metrics")
conditions = append(conditions, pushMetricsTrue)
} else {
conditions = append(conditions, "NOT push_metrics")
conditions = append(conditions, pushMetricsFalse)
}

conditions = append(conditions, "NOT disabled", "listen_port IS NOT NULL")
Expand All @@ -495,7 +501,7 @@ func FindAgentsForScrapeConfig(q *reform.Querier, pmmAgentID *string, pushMetric

// FindPMMAgentsIDsWithPushMetrics returns pmm-agents-ids with agent, that use push_metrics mode.
func FindPMMAgentsIDsWithPushMetrics(q *reform.Querier) ([]string, error) {
structs, err := q.SelectAllFrom(AgentTable, "WHERE NOT disabled AND pmm_agent_id IS NOT NULL AND push_metrics ORDER BY agent_id")
structs, err := q.SelectAllFrom(AgentTable, fmt.Sprintf("WHERE NOT disabled AND pmm_agent_id IS NOT NULL AND %s ORDER BY agent_id", pushMetricsTrue))
if err != nil {
return nil, status.Error(codes.FailedPrecondition, "Couldn't get agents")
}
Expand Down

0 comments on commit b420d9b

Please sign in to comment.