title: What info can be used to match postgres log and Go application log?
body: <p>I have a go application accesses my database running in k8s. I want to know if there are malicious actors use the same DB secrets the application uses to access the database directly.</p>
  <p>I have the postgres logs so I'm looking at the spec <a href="https://www.postgresql.org/docs/12/runtime-config-logging.html" rel="nofollow noreferrer">https://www.postgresql.org/docs/12/runtime-config-logging.html</a> initially I'm thinking I can log the <strong>IP address and process ID</strong> in the application code for any DB access, and then compare that with those in the postgres log, so the difference must be someone pretending to be the service and access the DB.</p>
  <p>But the problem is the process ID in the postgres log is the database process ID, not the application process ID. While for the other info present in postgres log, such as port number for the DB connection, session ID etc they are not easy to retrieve via Go's <code>sql</code> package.</p>
  <p>What could be the key in addition to IP address that is not easy to impersonate by individual, both application and postgres log would have it?</p>