should add connection time cost
in new versions , we can find the prometheus targets like collector="bgwriter" ,collector="bgwriter" collector="database", but no collector="connection", we should add a connection target to tell us if this is a connection issue, second one , [0.13.0] versions extend.query-path features was deprecated , but we really need this features , is the PG_EXPORTER_EXTEND_QUERY_PATH still working?
I'm not sure exactly what you are asking about. The collector="bgwriter" you reference is only part of our logging as far as I can see which has nothing to do with prometheus or its targets. Are you asking for logging around connections? If so, what about them would you want to have logged?
As for your second question, correct, extend.query-path as a feature has been deprecated. This includes the PG_EXPORTER_EXTEND_QUERY_PATH environment variable. If you need custom queries, you can use the sql_exporter as referenced in our README
a target grab the cost of get a connection to the postgresql ,this is a import , it can help tell us to know weather there is a connection issues between applications and databases system, or how long a short connection take in a heavy working database system. so there should be a target named collector="connection" , we really need this feature as extend.query-path, as you see, i want to get the database age , or some other self-definition target , you must deploy pg_exporter,sql_exporter...it is not convenient to a DBA enginer. the first question like this :
func (e *Exporter) scrape(ctx context.Context, ch chan<- prometheus.Metric) float64 { var err error scrapeTime := time.Now() db, err := sql.Open("mysql", e.dsn) if err != nil { level.Error(e.logger).Log("msg", "Error opening connection to database", "err", err) return 0.0 } defer db.Close()
// By design exporter should use maximum one connection per request.
db.SetMaxOpenConns(1)
db.SetMaxIdleConns(1)
// Set max lifetime for a connection.
db.SetConnMaxLifetime(1 * time.Minute)
if err := db.PingContext(ctx); err != nil {
level.Error(e.logger).Log("msg", "Error pinging mysqld", "err", err)
return 0.0
}
ch <- prometheus.MustNewConstMetric(mysqlScrapeDurationSeconds, prometheus.GaugeValue, time.Since(scrapeTime).Seconds(), "connection")