Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jekdD-0005AA-1U for pgsql-general@arkaria.postgresql.org; Fri, 29 May 2020 19:25:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jekdB-0004wj-V6 for pgsql-general@arkaria.postgresql.org; Fri, 29 May 2020 19:25:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jekdB-0004wc-NN for pgsql-general@lists.postgresql.org; Fri, 29 May 2020 19:25:25 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jekd6-0003Wz-1B for pgsql-general@lists.postgresql.org; Fri, 29 May 2020 19:25:24 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 91FEA3146; Fri, 29 May 2020 21:25:16 +0200 (CEST) Date: Fri, 29 May 2020 21:25:16 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: Audit Role Connections Message-ID: <20200529192516.GA31322@hjp.at> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ew6BAiZeqk4r7MaW" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --ew6BAiZeqk4r7MaW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2020-05-29 12:42:47 -0500, Chris Morris wrote: > We're using Heroku's PG, [...] > Other than polling pg_stat_activity (which isn't 100% accurate depending = on > timing), is there a good way to audit connections? To detect which roles = are > being used for connections? Do you have access to the log files? If you log_connections is on, you get messages like these: 2020-05-29 21:00:02 CEST [27995]: [2-1] user=3Dw*****,db=3Dwds,pid=3D27995 = LOG: connection authorized: user=3Dw***** database=3Dwds 2020-05-29 21:00:18 CEST [27995]: [9-1] user=3Dw*****,db=3Dwds,pid=3D27995 = LOG: disconnection: session time: 0:00:15.979 user=3Dw***** database=3Dwds= host=3D[local] 2020-05-29 21:07:14 CEST [7481]: [2-1] user=3Du*****,db=3Dwds,pid=3D7481 LO= G: connection authorized: user=3Du***** database=3Dwds 2020-05-29 21:07:14 CEST [7481]: [7-1] user=3Du*****,db=3Dwds,pid=3D7481 LO= G: disconnection: session time: 0:00:00.016 user=3Du***** database=3Dwds h= ost=3D[local] 2020-05-29 21:10:56 CEST [13918]: [2-1] user=3Dm*******,db=3Dwds,pid=3D1391= 8 LOG: connection authorized: user=3Dm******* database=3Dwds SSL enabled (= protocol=3DTLSv1.2, cipher=3DECDHE-RSA-AES256-GCM-SHA384, bits=3D256, compr= ession=3Doff) 2020-05-29 21:10:56 CEST [13918]: [11-1] user=3Dm*******,db=3Dwds,pid=3D139= 18 LOG: disconnection: session time: 0:00:00.117 user=3Dm******* database= =3Dwds host=3D143.130.**.** port=3D54037 (user names and IP addresses censored for privacy reasons) hp --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --ew6BAiZeqk4r7MaW Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAl7RYZcACgkQ8g5IURL+ KF22gA//Vw3eLtpTfLhLxDAvY3BaQdVrMMn265WtYudF+ch2PLt0qap4X8USxR6I OXsZwhEN8iyr+jI0d5iw58hAeSB3PCGDbaIOlNEMxgExSMSGt0o3s7EqtWVx6XC7 /e32+YwEv6b5VJHwUD689+T9nG+pIM7uuYmzWQfp3j+/+fqy/8nvvzyqAt0Tjn+K TRwgFI+Y8TyPK6QRUVanhSJ/r+bgKGThwp50t3IqUEP/OFrXgOLRKD/waoyWCRhZ eZnEzk+csrm1O7yTC7RlyV+B/+TL+Vj+Q+QLPl5E4fFZNJZAFEfx0cVpU1xp9rfg BzElna4we5U5RZI3x+MXEmWYis/nD2xbe7ZbEtGyOmbzBmszVMGS2niUf51ewfHI UustJmGaVY+48JjX5GYc4ESVUedvxsjSjhgI5GVxOY1IjyAPLaSyroiCMSxq5n4x wKG/HfraRs+mYiPeZ5QotO+wOod4rSV2Iay56vs3pCyYhqY9Oewmc0l0KNb6CmUl cVY6oGO8Z6D/kIHoHUPoJgL5Zy8QOuE8lHxNgdgH6/6JCxp+S4G0AOgA5xs7CrcU Pt51PKOptTeQ/FVJUYREoE1xpIcNtHSU2AurohICLtO/RKhk2poD3jMP0aco3I/k 3gFqsFlR38rEYmaQMfbhhmbUn1BXJya6U2DbDJOWvYk0sdQ8yng= =POsC -----END PGP SIGNATURE----- --ew6BAiZeqk4r7MaW--