mirror of
https://github.com/prometheus-community/postgres_exporter
synced 2025-04-20 14:05:24 +00:00
Merge 34fc37992b
into f8b7139174
This commit is contained in:
commit
b8e77e3224
@ -15,7 +15,7 @@ package collector
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"database/sql"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -66,19 +66,34 @@ func (c PGWALCollector) Update(ctx context.Context, instance *instance, ch chan<
|
|||||||
pgWALQuery,
|
pgWALQuery,
|
||||||
)
|
)
|
||||||
|
|
||||||
var segments uint64
|
var segments sql.NullInt64
|
||||||
var size uint64
|
var size sql.NullInt64
|
||||||
err := row.Scan(&segments, &size)
|
err := row.Scan(&segments, &size)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var segmentsValue float64
|
||||||
|
if segments.Valid {
|
||||||
|
segmentsValue = float64(segments.Int64)
|
||||||
|
} else {
|
||||||
|
segmentsValue = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
var sizeValue float64
|
||||||
|
if size.Valid {
|
||||||
|
sizeValue = float64(size.Int64)
|
||||||
|
} else {
|
||||||
|
sizeValue = 0
|
||||||
|
}
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
pgWALSegments,
|
pgWALSegments,
|
||||||
prometheus.GaugeValue, float64(segments),
|
prometheus.GaugeValue, segmentsValue,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
pgWALSize,
|
pgWALSize,
|
||||||
prometheus.GaugeValue, float64(size),
|
prometheus.GaugeValue, sizeValue,
|
||||||
)
|
)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user