Postgres_Exporter Issue with Prometheus

438 views
Skip to first unread message

vinay jaiswal

unread,
Apr 16, 2020, 6:03:00 PM4/16/20
to Prometheus Users
Hi , 

I have installed postgres_exporter on a standalone host ( Prometheus + Postgres_Exporter +Postgresql DB) , it collect the metrics from postgresql db and publish the same metrics over postgreslq_exporter exposed end point but unable to see the same metrics data over prometheus dashboard while node_exporter is working fine with prometheus .

Debug logs : DEBU[0383] collect query: [custom_query.lr]              source="postgres_exporter.go:1527"

curl -sv http://x.x.x.x:9187/metrics

pg_exporter_scrapes_total 3

# HELP pg_locks_count Number of locks

# TYPE pg_locks_count gauge

pg_locks_count{datname="postgres",mode="accessexclusivelock",server="localhost:5432"} 0

pg_locks_count{datname="postgres",mode="accesssharelock",server="localhost:5432"} 1

pg_locks_count{datname="postgres",mode="exclusivelock",server="localhost:5432"} 0



Any inputs are greatly appreciated . 

Brian Candler

unread,
Apr 17, 2020, 3:12:53 AM4/17/20
to Prometheus Users
Probably you're not scraping the exporter.  Show you prometheus.yml.

vinay jaiswal

unread,
Apr 17, 2020, 5:12:38 AM4/17/20
to Brian Candler, Prometheus Users
Hi Brian , 

Thanks for your inputs . 

Prometheus.yaml file for postgresql exporter job . 

- job_name: postgres_exporter_agent_id_21c040c5-614e-4b17-998f-4b59cdf698c_lr-1m0s

#  honor_timestamps: false

  params:

    collect[]:

    - custom_query.lr

  scrape_interval: 10s

  scrape_timeout: 10s

  metrics_path: /metrics

  static_configs:

  - targets:

    - x.x.x.x:9187

    labels:

      agent_id: /agent_id/21c040c5-614e-4b17-998f-4b59cdf698cc

      agent_type: postgres_exporter

      instance: /agent_id/21c040c5-614e-4b17-998f-4b59cdf698cc

      machine_id: /machine_id/34d94f29d2014e109ce67debbd39d9f5

      node_id:  /node_id/d4a79274-d151-44a2-9c15-a0f0535b729f

      node_name: ip-x-x-x-x

      node_type: generic

      region: sgp1


  • Checked the endpoints status and it's showing up over prometheus UI under target section . 

Postgres Exporter Debug logs : 

root@ip-x-x-x-x:/usr/local/bin# /usr/local/bin/postgres_exporter --web.listen-address=x.x.x.x:9187 --log.level=debug --web.telemetry-path=/metrics

INFO[0000] Starting postgres_exporter (version=, branch=, revision=)  source="postgres_exporter.go:1457"

INFO[0000] Build context (go=go1.13.8, user=, date=)     source="postgres_exporter.go:1458"

INFO[0000] Established new database connection to "localhost:5432".  source="postgres_exporter.go:798"

DEBU[0000] Querying Postgres Version on "localhost:5432"  source="postgres_exporter.go:1241"

INFO[0000] Semantic Version Changed on "localhost:5432": 0.0.0 -> 10.12.0  source="postgres_exporter.go:1258"

DEBU[0000] pg_xlog_location_diff is being forced to discard due to version incompatibility.  source="postgres_exporter.go:525"

DEBU[0000] procpid is being forced to discard due to version incompatibility.  source="postgres_exporter.go:525"

DEBU[0000] write_location is being forced to discard due to version incompatibility.  source="postgres_exporter.go:525"

DEBU[0000] sent_location is being forced to discard due to version incompatibility.  source="postgres_exporter.go:525"

DEBU[0000] flush_location is being forced to discard due to version incompatibility.  source="postgres_exporter.go:525"

DEBU[0000] replay_location is being forced to discard due to version incompatibility.  source="postgres_exporter.go:525"

DEBU[0000] Querying pg_setting view on "localhost:5432"  source="pg_setting.go:15"

DEBU[0000] Querying namespace:  pg_stat_bgwriter         source="postgres_exporter.go:1221"

DEBU[0000] Querying namespace:  pg_stat_database         source="postgres_exporter.go:1221"

DEBU[0000] Querying namespace:  pg_stat_database_conflicts  source="postgres_exporter.go:1221"

DEBU[0000] Querying namespace:  pg_locks                 source="postgres_exporter.go:1221"

DEBU[0000] Querying namespace:  pg_stat_replication      source="postgres_exporter.go:1221"

DEBU[0000] Querying namespace:  pg_stat_activity         source="postgres_exporter.go:1221"

DEBU[0000] Collector "exporter" was registered           source="postgres_exporter.go:1554"

DEBU[0000] Collector "standard.process" was registered   source="postgres_exporter.go:1554"

DEBU[0000] Collector "standard.go" was registered        source="postgres_exporter.go:1554"

INFO[0000] Starting HTTP server for http://x.x.x.x:9187/metrics ...  source="server.go:140"


Fetched end points details : 


curl -is http://x.x.x.x:9187/metrics


# HELP pg_exporter_last_scrape_duration_seconds Duration of the last scrape of metrics from PostgresSQL.

# TYPE pg_exporter_last_scrape_duration_seconds gauge

pg_exporter_last_scrape_duration_seconds 0.015799825

# HELP pg_exporter_last_scrape_error Whether the last scrape of metrics from PostgreSQL resulted in an error (1 for error, 0 for success).

# TYPE pg_exporter_last_scrape_error gauge

pg_exporter_last_scrape_error 0

# HELP pg_exporter_scrapes_total Total number of times PostgresSQL was scraped for metrics.

# TYPE pg_exporter_scrapes_total counter

pg_exporter_scrapes_total 4

# HELP pg_locks_count Number of locks

# TYPE pg_locks_count gauge

pg_locks_count{datname="postgres",mode="accessexclusivelock",server="localhost:5432"} 0

pg_locks_count{datname="postgres",mode="accesssharelock",server="localhost:5432"} 1

pg_locks_count{datname="postgres",mode="exclusivelock",server="localhost:5432"} 0

On Fri, Apr 17, 2020 at 12:43 PM Brian Candler <b.ca...@pobox.com> wrote:
Probably you're not scraping the exporter.  Show you prometheus.yml.

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/db264609-c77c-4744-bd91-3a272a7c6bef%40googlegroups.com.


--

Thanks
Vinay kumar Jaiswal
Mobile No:9650526003
Skype:vinayjaiswal1989

Travel & Devops

unread,
Apr 17, 2020, 5:46:29 AM4/17/20
to vinay jaiswal, Brian Candler, Prometheus Users
also please check your service monitor configuration .
Thanks & Regards
 Konda Reddy L 
 +91-7893208160
  LIinkedIn



Brian Candler

unread,
Apr 17, 2020, 6:44:48 AM4/17/20
to Prometheus Users
On Friday, 17 April 2020 10:12:38 UTC+1, vinay jaiswal wrote:

  params:

    collect[]:

    - custom_query.lr


You're not using that parameter in your "curl" command.  What happens if you do?

vinay jaiswal

unread,
Apr 17, 2020, 2:37:01 PM4/17/20
to Brian Candler, Prometheus Users
Hi Brian , 

Thanks for your help and time . It's working fine , after removing the custom_query.lr from prometheus config file . 




--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages