# Metricset 'postgresql/bgwriter' is not registered, module not found

**URL:** <https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020>\
**Category:** Beats\
**Created:** [September 20, 2016, 1:55pm UTC](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020 "2016-09-20T13:55:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![agonzalez](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@agonzalez](https://discuss.elastic.co/u/agonzalez)\
**Post date:** [September 20, 2016, 1:55pm UTC](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020/1 "2016-09-20T13:55:54Z")

</div>

I have configure metricbeat to send postgresql metric but get this error when starting filebeat:

2016/09/20 13:54:29.102566 metricbeat.go:26: INFO Register [ModuleFactory:[], MetricSetFactory:[apache/status, mongodb/status, mysql/status, nginx/stubstatus, redis/info, redis/keyspace, system/core, system/cpu, system/diskio, system/filesystem, system/fsstat, system/load, system/memory, system/network, system/process, zookeeper/mntr]]  
2016/09/20 13:54:29.201255 beat.go:284: CRIT Exiting: 1 error: metricset 'postgresql/bgwriter' is not registered, module not found  
Exiting: 1 error: metricset 'postgresql/bgwriter' is not registered, module not found

config

```
- module: postgresql
  metricsets:
    # Stats about every PostgreSQL database
# - database

    # Stats about the background writer process's activity
    - bgwriter

    # Stats about every PostgreSQL process
# - activity

# enabled: true
  period: 60s

  # The host must be passed as PostgreSQL DSN. Example:
  # postgres://pqgotest:password@localhost:5432?sslmode=disable
  # The available parameters are documented here:
  # https://godoc.org/github.com/lib/pq#hdr-Connection_String_Parameters
  hosts: ["postgres://postgres@localhost:5432"]
```

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [September 20, 2016, 6:09pm UTC](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020/2 "2016-09-20T18:09:12Z")

</div>

Which version of metricbeat are you using?

---

<div class="post-metadata">

**Author:** ![agonzalez](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@agonzalez](https://discuss.elastic.co/u/agonzalez)\
**Post date:** [September 20, 2016, 7:25pm UTC](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020/3 "2016-09-20T19:25:59Z")

</div>

5.0-alpha5

---

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [September 20, 2016, 7:56pm UTC](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020/4 "2016-09-20T19:56:49Z")

</div>

The postgresql module wasn't part of Metricbeat 5.0-alpha5. It will be part of the next release.

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [September 21, 2016, 6:44am UTC](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020/5 "2016-09-21T06:44:38Z")

</div>

If you like to test the postgres module you can find here the snapshot builds: [https://beats-nightlies.s3.amazonaws.com/index.html?prefix=metricbeat/](https://beats-nightlies.s3.amazonaws.com/index.html?prefix=metricbeat/)

---

<div class="post-metadata">

**Author:** ![agonzalez](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@agonzalez](https://discuss.elastic.co/u/agonzalez)\
**Post date:** [September 21, 2016, 2:55pm UTC](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020/6 "2016-09-21T14:55:09Z")

</div>

I just see there 6.0-alpha1, no 5.0-alpha6. Is 6.0-alpha1 the right one and compatible with ES 5.0-alpha5?

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [September 21, 2016, 9:38pm UTC](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020/7 "2016-09-21T21:38:02Z")

</div>

6.0-alpha1 is currently the right one. We had to do some branch renaming in preparation for beta1. You are fine with this snapshot for the moment to test postgres.

---

<div class="post-metadata">

**Author:** ![agonzalez](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@agonzalez](https://discuss.elastic.co/u/agonzalez)\
**Post date:** [September 22, 2016, 12:44pm UTC](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020/8 "2016-09-22T12:44:22Z")

</div>

I installed the 6.0-alpha1 but there is no import\_dashboards script on /usr/share/metricbeat/kibana

I am using the old dsahboard from old 5.0-alpha5 ... is there a dashboard for postgresql?

---

<div class="post-metadata">

**Author:** ![agonzalez](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@agonzalez](https://discuss.elastic.co/u/agonzalez)\
**Post date:** [September 22, 2016, 1:00pm UTC](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020/9 "2016-09-22T13:00:40Z")

</div>

Also getting this error on documents:

error QueryStats: pq: unexpected error: "setting PGSERVICEFILE not supported"

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [September 23, 2016, 6:34am UTC](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020/10 "2016-09-23T06:34:44Z")

</div>

- The import\_dashboards script should be under `metricbeat/scripts/*`
- There are currently no pre-built dashboards for postgresql. We are more then happy to get external contributions here 😉

Where exactly do you get this error?

---

<div class="post-metadata">

**Author:** ![agonzalez](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@agonzalez](https://discuss.elastic.co/u/agonzalez)\
**Post date:** [September 23, 2016, 7:12pm UTC](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020/11 "2016-09-23T19:12:53Z")

</div>

I get the error in Kibana while exploring the documents created by the postgres module

---

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [September 23, 2016, 7:24pm UTC](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020/12 "2016-09-23T19:24:49Z")

</div>

Could you please provide the JSON document as an example. What version of Postgres are you running?

---

<div class="post-metadata">

**Author:** ![agonzalez](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@agonzalez](https://discuss.elastic.co/u/agonzalez)\
**Post date:** [September 23, 2016, 7:56pm UTC](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020/13 "2016-09-23T19:56:42Z")

</div>

I am running postgresql 9.2.5 on Centos 6. We cant upgrade it. We have same version on thousends of appliances.

JSON document:

```auto
{
  "_index": "metricbeat-2016.09.23",
  "_type": "metricsets",
  "_id": "AVdZCXMREu-Rb_NMhp9v",
  "_score": null,
  "_source": {
    "@timestamp": "2016-09-23T19:52:55.122Z",
    "beat": {
      "hostname": "rc02",
      "name": "rc02"
    },
    "error": "QueryStats: pq: unexpected error: \"setting PGSERVICEFILE not supported\"",
    "fields": {
      "asset_tag": "822-101-50240"
    },
    "metricset": {
      "host": "postgres://postgres@localhost:5432",
      "module": "postgresql",
      "name": "database",
      "rtt": 83
    },
    "postgresql": {
      "database": {}
    },
    "type": "metricsets"
  },
  "fields": {
    "@timestamp": [
      1474660375122
    ],
    "system.network.total.bytes": [
      0
    ]
  },
  "highlight": {
    "metricset.module": [
      "@kibana-highlighted-field@postgresql@/kibana-highlighted-field@"
    ]
  },
  "sort": [
    1474660375122
  ]
}

```

---

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [September 23, 2016, 8:14pm UTC](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020/14 "2016-09-23T20:14:10Z")

</div>

Does your environment have `PGSERVICEFILE` set?

From: [pq package - github.com/lib/pq - Go Packages](https://godoc.org/github.com/lib/pq)

> Most environment variables as specified at [PostgreSQL: Documentation: 16: 34.15.&nbsp;Environment Variables](http://www.postgresql.org/docs/current/static/libpq-envars.html) supported by libpq are also supported by pq. If any of the environment variables not supported by pq are set, pq will panic during connection establishment. Environment variables have a lower precedence than explicitly provided connection parameters.

---

<div class="post-metadata">

**Author:** ![agonzalez](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@agonzalez](https://discuss.elastic.co/u/agonzalez)\
**Post date:** [September 23, 2016, 8:34pm UTC](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020/15 "2016-09-23T20:34:22Z")

</div>

it is set:

[root@rc02 ~]# echo $PGSERVICEFILE  
/etc/sysconfig/pgsql/pg\_service.conf

---

<div class="post-metadata">

**Author:** ![agonzalez](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@agonzalez](https://discuss.elastic.co/u/agonzalez)\
**Post date:** [September 26, 2016, 6:34pm UTC](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020/16 "2016-09-26T18:34:41Z")

</div>

any update on this?

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [October 3, 2016, 5:48pm UTC](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020/17 "2016-10-03T17:48:10Z")

</div>

@agonzalez As we use the [https://godoc.org/github.com/lib/pq](https://godoc.org/github.com/lib/pq) as our library, the only workaround seems to be to remove the `PGSERVICEFILE` environment variable.

---

<div class="post-metadata">

**Author:** ![agonzalez](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@agonzalez](https://discuss.elastic.co/u/agonzalez)\
**Post date:** [October 5, 2016, 4:43pm UTC](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020/18 "2016-10-05T16:43:45Z")

</div>

I edited /etc/init.d/metricbeat and added:

unset -v PGSERVICEFILE  
unset -v PGSYSCONFDIR

Now i am getting other message error:

QueryStats: pq: unsupported sslmode "allow"; only "require" (default), "verify-full", "verify-ca", and "disable" supported

Any idea?

---

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [October 5, 2016, 5:07pm UTC](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020/19 "2016-10-05T17:07:38Z")

</div>

That's probably caused by having `PGSSLMODE=allow` in your environment. I'd unset that one as well. It appears the the Golang lib/pq doesn't agree with the C libpq on what the options are for this setting.

[Ref: conn.go](https://github.com/lib/pq/blob/55196ec83d60d789e27b2627549bf00974a70084/conn.go#L1815-L1816)  
[libpq docs](https://www.postgresql.org/docs/8.4/static/libpq-connect.html)

---

<div class="post-metadata">

**Author:** ![agonzalez](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@agonzalez](https://discuss.elastic.co/u/agonzalez)\
**Post date:** [October 5, 2016, 5:31pm UTC](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020/20 "2016-10-05T17:31:39Z")

</div>

thanks! that worked i am getting now the metrics.

Shouldnt you include by default in the metricbeat init.d the commands to unset the vars?

Is there an easy way to extend it to collect other info from postgresql? like runing a QUERY and sending the result to elk?

[Next page](https://discuss.elastic.co/t/metricset-postgresql-bgwriter-is-not-registered-module-not-found/61020.md?page=2)
