# Postgresql Module?

**URL:** <https://discuss.elastic.co/t/postgresql-module/150633>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [October 2, 2018, 2:32am UTC](https://discuss.elastic.co/t/postgresql-module/150633 "2018-10-02T02:32:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![killmasta93](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/killmasta93/32/36022_2.png) [@killmasta93](https://discuss.elastic.co/u/killmasta93)\
**Post date:** [October 2, 2018, 2:32am UTC](https://discuss.elastic.co/t/postgresql-module/150633/1 "2018-10-02T02:32:58Z")

</div>

Hi,  
I was wondering if someone could shed some light. currently have Kibana 6 with logstash and elasticsearch. The idea is one VM which has the postgresql to send the logs using filebeat to another VM which has ELK,  
I have activated the module

```
              filebeat modules enable postgresql

```

I was reading jdbc input plugin for Logstash not sure if i would need it? Im somewhat confused how i can get the correct index for it to filter.  
im trying to get the pg\_stat\_activity

also using metricbeat to import the dashboards which i imported it but i see everything besides the postgresql

 ![01](https://us1.discourse-cdn.com/elastic/original/3X/0/d/0d938603e4c7ba4f58383b4f87528a9d87f3c74d.png)

Thank you

---

<div class="post-metadata">

**Author:** ![kvch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kvch/32/72058_2.png) [@kvch](https://discuss.elastic.co/u/kvch)\
**Post date:** [October 2, 2018, 8:50am UTC](https://discuss.elastic.co/t/postgresql-module/150633/2 "2018-10-02T08:50:48Z")

</div>

I assume you are forwarding the events to Logstash. You don't need to use the jdbc plugin. Logstash needs to be configured to read from beats input: [https://www.elastic.co/guide/en/logstash/current/plugins-inputs-beats.html](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-beats.html)

According to the command you have pasted here you enabled the module for Filebeat. You need to run `metricbeat modules enable postgresql`.

Metricbeat does not provide a dashboards for PostgreSQL module.

---

<div class="post-metadata">

**Author:** ![killmasta93](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/killmasta93/32/36022_2.png) [@killmasta93](https://discuss.elastic.co/u/killmasta93)\
**Post date:** [October 2, 2018, 11:19pm UTC](https://discuss.elastic.co/t/postgresql-module/150633/3 "2018-10-02T23:19:55Z")

</div>

Thanks for the reply, when i was going to the dashboard of kibana i saw that postgresql had its own dashboard, not sure why it did not show up. Also the filebeat module i enabled on the VM which has the postgresql and on the metric beat i enabled on the Kibana VM.  
After that on logstash this is my  
02-beats-input.conf

```
 input {
 beats {
  port => 5443
ssl => false
 }
}

```

then my 10-elasticsearch-output.conf

```
       output {
 elasticsearch {
hosts => ["localhost:9200"]
sniffing => true
manage_template => false
index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
document_type => "%{[@metadata][type]}"
  }
}

```

Then on my filebeat which is another vm which has postgresql this is my config  
filebeat.yml

```
https://pastebin.com/tX5fY5Ga

```

now if i understood correctly filebeat would send all the logs from postgresql including inserts and selects?

Currently when i check on discover im getting this

 ![02-012](https://us1.discourse-cdn.com/elastic/original/3X/9/5/954cb21def5d1e2e687ee12162b10e74d0bfd23f.png)

Thank you

EDIT: after reading a long time i realized that metricbeat is what i need to install on the vm that has postgresql and remove the filebeat. now that i have installed metricbeat on the vm that has postgre im sending the data though logstash, the question is should i send it though logstash or elastic?

EDIT2: So after more reading i edited the postgremodule.yml

```
 # Module: postgresql
  # Docs: https://www.elastic.co/guide/en/beats/metricbeat/6.4/metricbeat-module-postgresql.html

  - module: postgresql
  metricsets:
     - database
     - bgwriter
      - activity
     period: 10s
  hosts: ["postgres://localhost:5432"]
   username: postgre
     password: mypassword

```

But i still dont see any metrics on kibana any ideas?

This is what i have im getting

```
     https://pastebin.com/rx1U2PFJ
```

---

<div class="post-metadata">

**Author:** ![kvch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kvch/32/72058_2.png) [@kvch](https://discuss.elastic.co/u/kvch)\
**Post date:** [October 3, 2018, 8:01am UTC](https://discuss.elastic.co/t/postgresql-module/150633/4 "2018-10-03T08:01:52Z")

</div>

Could you please share your full config? The indentation seems to be off.

Have you run `metricbeat setup`? It is supposed to setup everything required by ES/Kibana to show your data.

---

<div class="post-metadata">

**Author:** ![killmasta93](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/killmasta93/32/36022_2.png) [@killmasta93](https://discuss.elastic.co/u/killmasta93)\
**Post date:** [October 5, 2018, 4:15am UTC](https://discuss.elastic.co/t/postgresql-module/150633/5 "2018-10-05T04:15:47Z")

</div>

> [@kvch](#):
>
> `metricbeat setup`

Thanks for the reply, when i try to run

```
            metricbeat setup

```

I get this error

```
           Exiting: Template loading requested but the Elasticsearch output is not configured/enabled

```

im running the metricbeat on the vm that has the postgresql

```
                        ###################### Metricbeat Configuration Example #######################

    # This file is an example configuration file highlighting only the most common
  # options. The metricbeat.reference.yml file from the same directory contains all the
   # supported options with more comments. You can use it as a reference.
    #
      # You can find the full configuration reference here:
     # https://www.elastic.co/guide/en/beats/metricbeat/index.html

         #========================== Modules configuration ============================

     metricbeat.config.modules:
    # Glob pattern for configuration loading
    path: ${path.config}/modules.d/*.yml

    # Set to true to enable config reloading
     reload.enabled: false

     # Period on which files under path should be checked for changes
    #reload.period: 10s

      #==================== Elasticsearch template setting ==========================

 setup.template.settings:
  index.number_of_shards: 1
 index.codec: best_compression
 #_source.enabled: false

 #================================ General =====================================

# The name of the shipper that publishes the network data. It can be used to group
# all the transactions sent by a single shipper in the web interface.
#name:

# The tags of the shipper are included in their own field with each
# transaction published.
#tags: ["service-X", "web-tier"]

# Optional fields that you can specify to add additional information to the
# output.
   #fields:
   # env: staging

  #============================== Dashboards =====================================
  # These settings control loading the sample dashboards to the Kibana index. Loading
   # the dashboards is disabled by default and can be enabled either by setting the
# options here, or by using the `-setup` CLI flag or the `setup` command.
#setup.dashboards.enabled: true

# The URL from where to download the dashboards archive. By default this URL
# has a value which is computed based on the Beat name and version. For released
# versions, this URL points to the dashboard archive on the artifacts.elastic.co
 # website.
#setup.dashboards.url:

 #============================== Kibana =====================================

# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
#setup.kibana:

  # Kibana Host
  # Scheme and port can be left out and will be set to the default (http and 5601)
 # In case you specify and additional path, the scheme is required: http://localhost:5601/path
  # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
 #host: "localhost:5601"

  #============================= Elastic Cloud ==================================

# These settings simplify using metricbeat with the Elastic Cloud (https://cloud.elastic.co/).

# The cloud.id setting overwrites the `output.elasticsearch.hosts` and
# `setup.kibana.host` options.
# You can find the `cloud.id` in the Elastic Cloud web UI.
  #cloud.id:

 # The cloud.auth setting overwrites the `output.elasticsearch.username` and
 # `output.elasticsearch.password` settings. The format is `<user>:<pass>`.
  #cloud.auth:

 #================================ Outputs =====================================

 # Configure what output to use when sending the data collected by the beat.

#-------------------------- Elasticsearch output ------------------------------
  #output.elasticsearch:
 # Array of hosts to connect to.
   # hosts: ["192.168.115.166:9200"]

  # Optional protocol and basic auth credentials.
  #protocol: "https"
 #username: "elastic"
 #password: "changeme"

#----------------------------- Logstash output --------------------------------
 output.logstash:
  # The Logstash hosts
   hosts: ["192.168.115.166:5443"]

  # Optional SSL. By default is off.
 # List of root certificates for HTTPS server verifications
  #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]

  # Certificate for SSL client authentication
 #ssl.certificate: "/etc/pki/client/cert.pem"

  # Client Certificate Key
 #ssl.key: "/etc/pki/client/cert.key"

     #================================ Logging =====================================

 # Sets log level. The default log level is info.
# Available log levels are: error, warning, info, debug
#logging.level: debug

# At debug level, you can selectively enable logging only for some components.
# To enable all selectors use ["*"]. Examples of other selectors are "beat",
# "publish", "service".
#logging.selectors: ["*"]

```

and this my postgresql.yml

```
            - module: postgresql
   metricsets:
    - database
   - bgwriter
    - activity
  period: 10s
  hosts: ["postgres://localhost:5432"]
  username: postgre
  password: mypassword

```

Thank you

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 2, 2018, 6:19am UTC](https://discuss.elastic.co/t/postgresql-module/150633/6 "2018-11-02T06:19:31Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
