Uploaded image for project: 'Percona Monitoring and Management'
  1. Percona Monitoring and Management
  2. PMM-10331

Conversion function to turn PG result into float64 utilization

Details

    • Improvement
    • Status: Open
    • Low
    • Resolution: Unresolved
    • None
    • None
    • Postgres_exporter
    • None
    • Yes
    • Yes
    • No

    Description

      Hello there,

      I might be wrong in here as I am no expert.
      I was trying to add replay_lag metric, so I have added a custom ColumnUsage and a conversion function to output a float64.

      case CUSTOMCOLUMNUSAGE:
      	thisMap[columnName] = MetricMap{
      		vtype: prometheus.GaugeValue,
      		desc:  ...,
      		conversion: func(in interface{}) (float64, bool) {
      			// my conversion here
      		},
            }
      
      

      However I was receiving this error Unexpected error parsing column: ... and I have noticed that dbToFloat64 is used no matter the type of column :

      https://github.com/percona/postgres_exporter/blob/7b2ff2c41dbca454209e4d40697a7fcd9e3c8c0a/cmd/postgres_exporter/postgres_exporter.go#L1369

      Shouldn't be instead:

      value, ok := metricMapping.conversion(columnData[idx])
      

      After I changed it my metric was converted correctly and I could query it on Grafana. Is this correct or am I missing something?

      If needed I can make a pull request.

      On a side note, if you are interested I can open another issue for adding replication lag to the metrics.

      Thanks

      Attachments

        Activity

          People

            Unassigned Unassigned
            Matteo Matteo Gioioso
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Smart Checklist