cybertec-postgresql / pgwatch2

PostgreSQL metrics monitor/dashboard
BSD 3-Clause "New" or "Revised" License
1.82k stars 232 forks source link

General advice sought and feedback on first-time useage errors. #694

Closed laurencefass closed 1 year ago

laurencefass commented 1 year ago

I have a single postgres database in a docker container and I am trying to use pgwatch in the simplest possible way to observe metrics. my db and pgwatch are defined in the same compose file and are visible via their service names.

I cant find a simple, single point of entry in the documentation to enable me to quickly set this up to test it works against my own database (not the test database)

Ive tried various options and all result in a docker log errors. It looks like there may be some hard-coded assumptions on Influx that are incompatible with my attempts at using the daemon only image.

2023-10-02 10:48:49 2023/10/02 09:48:49 ERRO InitAndTestInfluxConnection: SHOW DATABASES failed, retrying in 5s (max 3x)... Post "http://localhost:8086/query?db=pgwatch2&params=null&q=SHOW+DATABASES": dial tcp 127.0.0.1:8086: connect: connection refused

2023-10-02 10:53:20 2023/10/02 09:53:20 CRIT main: Could not initialize InfluxDB Post "http://localhost:8086/query?db=pgwatch2&params=null&q=SHOW+DATABASES": dial tcp 127.0.0.1:8086: connect: connection refused

I am using the daemon as I dont want the additional complexity of databases to get started, yet the errors indicate that this may be hard wired as I not specifying influx anywhere.

My docker compose service definition currently looks like this.

    pgwatch2:
        image: cybertec/pgwatch2-daemon:latest
        container_name: pgwatch2
        restart: unless-stopped
        volumes:
            - ./local_docker/pgwatch2/config.yaml:/etc/pgwatch2-configmap/config.yaml
        environment: 
            # - PW2_CONFIG=/etc/pgwatch2-configmap/config.yaml
            - PW2_ADHOC_CONN_STR=xxxConnectionStringxxx
            - PW2_ADHOC_CONFIG="configName"
        ports:
            - "3010:3000"
            - "8090:8080"
            - "127.0.0.1:5442:5432"

The config file I tried which outputs the same error is as follows (taken straight from your github with my specific credentials inserted). Ive tried this with and without the adhoc settings.

- unique_name:
      events-service 
  dbtype:
      postgres 
  host: postgres # my docker service name
  port: 5432 
  dbname: mydbname
  user: mydbuser
  password: mydbpassword
  sslmode: disable # supported options: disable, require, verify-ca, verify-full
  #  libpq_conn_str: postgresql://user@localhost:5432/postgres  # overrides single connect params. no pwd encryption possible
  stmt_timeout: 10 # in seconds
  is_superuser: false # setting to true will try to auto-create all metric fetching "helpers"
  preset_metrics: minimal # from list of presets defined in "metrics/preset-configs.yaml"
  custom_metrics: # if both preset and custom are specified, custom wins
  preset_metrics_standby: # optional metrics configuration for standby / replica state, v1.8.1+
  custom_metrics_standby:
  dbname_include_pattern: # regex to filter databases to actually monitor for the "continuous" modes
  dbname_exclude_pattern:
  is_enabled: true
  group: default # just for logical grouping of DB hosts or for "sharding", i.e. splitting the workload between many gatherer daemons
  custom_tags: # option to add arbitrary tags (Influx / Postgres storage only) for every stored data row,
      aws_instance_id: i-0af01c0123456789a # for example to fetch data from some other source onto a same Grafana graph
  sslrootcert: ''
  sslcert: ''
  sslkey: ''

What is the minimum configuration required for a quick start to monitor my containerised database. I anticipate this being docker compose service definition and a config yml file. If you can post one as a reply I will be happy to try it and report back any further errors.

Thanks

laurencefass commented 1 year ago

Ive changed the image to use cybertec/pgwatch2-postgres:1.10.0 and using the same confg.yaml and seeing these statup errors in docker log:

Note I have ssl disabled in my config.

Grafana loads with a load of empty metrics, and my dbname is isted in the top lhs selection box, but selecting does not bring metric displays to life.

This is a really simple setup with a single postgres db, but it looks like there's a lot can wrong. Would it be worth providing some simpler configuration in docs under installation to get up and running more quickly?

2023-10-02 13:23:31 Can't load /root/.rnd into RNG
2023-10-02 13:23:31 281472958363264:error:2406F079:random number generator:RAND_load_file:Cannot open file:../crypto/rand/randfile.c:88:Filename=/root/.rnd
2023-10-02 13:23:31 Generating a RSA private key
2023-10-02 13:23:31 ....................................++++
2023-10-02 13:23:32 ........................................................................++++
2023-10-02 13:23:32 writing new private key to '/pgwatch2/persistent-config/self-signed-ssl.key'
2023-10-02 13:23:32 -----
2023-10-02 13:23:32 install: cannot change permissions of 'pg_stat_tmp': No such file or directory

No record or acknowledgement that the config.yaml file is being loaded, and is not reflected in the UI as my db is not listed.

laurencefass commented 1 year ago

Have managed to get basic setup working with lots of tweaking and further ref to docs.

pashagolub commented 1 year ago

Glad to hear you've made it. Yes, learning curve is kinda steep.