Skip to content

Commit

Permalink
go.d postgres index name replace space (netdata#17968)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyam8 committed Jun 20, 2024
1 parent ffe87dc commit 55b2fe8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/go/collectors/go.d.plugin/modules/postgres/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"context"
"database/sql"
"fmt"
"regexp"
"strconv"
"time"

Expand Down Expand Up @@ -264,3 +265,9 @@ func calcPercentage(value, total int64) (v int64) {
func calcDeltaPercentage(a, b incDelta) int64 {
return calcPercentage(a.delta(), a.delta()+b.delta())
}

func removeSpaces(s string) string {
return reSpace.ReplaceAllString(s, "_")
}

var reSpace = regexp.MustCompile(`\s+`)
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (p *Postgres) doDBQueryBloat(db *sql.DB) error {
case "wastedbytes":
tableWasted = parseFloat(value)
case "iname":
iname = value
iname = removeSpaces(value)
case "wastedibytes":
idxWasted = parseFloat(value)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (p *Postgres) doDBQueryStatUserIndexes(db *sql.DB) error {
case "relname":
table = value
case "indexrelname":
name = value
name = removeSpaces(value)
p.getIndexMetrics(name, table, dbname, schema).updated = true
case "parent_relname":
p.getIndexMetrics(name, table, dbname, schema).parentTable = value
Expand Down

0 comments on commit 55b2fe8

Please sign in to comment.