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

PostgreSQL Instance with password containing *=* doesn't work with pmm-agent

    XMLWordPrintable

    Details

      Description

      Password format for the instance on which the issue was discovered was something like this: 
      JK87Exs_=kUYE5Si

      Passing the password with quotes, without quotes doesn't have have any impact, it still errors out on PMM-agent log, Dashboards show no data, only QAN works. 

      impact on user: Dashboards don't show any data, exporter status is running, QAN works
       

      Steps to Recreate:

      1) setup PostgreSQL 12.x with a dedicated pmm_user something like this: 

      CREATE USER pmm_user WITH SUPERUSER ENCRYPTED PASSWORD 'JK87Exs_=kUYE5Si'; 

      2) Setup pmm-agent `dev-latest` or `2.9.0`

      3) Make sure connection to postgresql works with the user created in step 1

      3) add postgresql instance for monitoring: 

      pmm-admin add postgresql pg12 --username=pmm_user --password=JK87Exs_=kUYE5Si 127.0.0.1:5432

      4) check pmm-agent logs: 

      May 06 12:50:33 lalit-ThinkPad-T480 pmm-agent[1223]: INFO[2020-05-06T12:50:33.094+05:30] time="2020-05-06T12:50:33+05:30" level=error msg="Error opening connection to database (postgres://pmm_user:PASSWORD_REMOVED@127.0.0.1:5432/postgres?connect_timeout=1&sslmode=disable): malformed dsn \"connect_timeout=1 dbname=postgres host=127.0.0.1 password=*** port=5432 sslmode=disable user=pmm_user\"" source="postgres_exporter.go:1396" agentID=/agent_id/b223a0a8-ba3e-4188-9a52-44021b99ae28 component=agent-process type=postgres_exporter

      5) try removing and connecting the same instance for monitoring using single and double quotes on the password field with pmm-admin add command, still the same error. 

      6) pmm-agent status returns "Running" status while postgresql dashboards have "N/A"  for this service. 

      7) QAN shows data for this instance, even though we have error in pmm-agent log. 

      Issue from Reporter: 

      I encounter an issue with posgresql servers v12, pmm agent complains about a malformed dsn :

      Apr 16 11:57:44 postgres.test postgres[81415]: [8-1] 2020-04-16 11:57:44.214 CEST [81415] LOG:  connection received: host=192.168.0.2 port=40606
      Apr 16 11:57:44 postgres.test postgres[81415]: [9-1] 2020-04-16 11:57:44.216 CEST [81415] LOG:  connection authorized: user=pmm_user database=postgres
      Apr 16 11:57:44 postgres.test pmm-agent: #033[36mINFO#033[0m[2020-04-16T11:57:44.223+02:00] time="2020-04-16T11:57:44+02:00" level=info msg="Starting postgres_exporter (version=, branch=, revision=)" source="postgres_exporter.go:1457"  #033[36magentID#033[0m=/agent_id/68a5e0df-8eac-46c7-a740-831450a3e5f4 #033[36mcomponent#033[0m=agent-process #033[36mtype#033[0m=postgres_exporter
      Apr 16 11:57:44 postgres.test pmm-agent: #033[36mINFO#033[0m[2020-04-16T11:57:44.223+02:00] time="2020-04-16T11:57:44+02:00" level=info msg="Build context (go=go1.13.8, user=, date=)" source="postgres_exporter.go:1458"  #033[36magentID#033[0m=/agent_id/68a5e0df-8eac-46c7-a740-831450a3e5f4 #033[36mcomponent#033[0m=agent-process #033[36mtype#033[0m=postgres_exporter
      Apr 16 11:57:44 postgres.test pmm-agent: #033[36mINFO#033[0m[2020-04-16T11:57:44.223+02:00] time="2020-04-16T11:57:44+02:00" level=error msg="Error opening connection to database (postgres://[pmm_user:PASSWORD_REMOVED@192.168.0.2:5432/postgres?connect_timeout=1&sslmode=disable|https://forums.percona.com/home/leaving?target=http%3A%2F%2Fpmm_user%3APASSWORD_REMOVED%40192.168.0.2%3A5432%2Fpostgres%3Fconnect_timeout%3D1%26sslmode%3Ddisable]): malformed dsn \"connect_timeout=1 dbname=postgres host=192.168.0.2 password=*** port=5432 sslmode=disable user=pmm_user\"" source="postgres_exporter.go:1396"  #033[36magentID#033[0m=/agent_id/68a5e0df-8eac-46c7-a740-831450a3e5f4 #033[36mcomponent#033[0m=agent-process #033[36mtype#033[0m=postgres_exporter
      

      I can establish a connection by using the connection URI from logs. But i cant check the password effectively sent as it appears as PASSWORD_REMOVED in the logs.

       

        Smart Checklist

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                Unassigned
                Reporter:
                AlexB Alexandre Barth
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                  Dates

                  Created:
                  Updated:

                    Time Tracking

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - Not Specified
                    Not Specified
                    Logged:
                    Time Spent - 1 hour
                    1h