Original query:

SELECT DISTINCT ON (node_netid, gas_port) * 
FROM gas_all_data WHERE gas_timestamp IN
(
  SELECT MAX(gas_timestamp)
  FROM gas_all_data
  GROUP BY node_netid, gas_port
)
ORDER BY node_netid, gas_port;

Prettified:

SELECT
  DISTINCT ON (
    "node_netid",
    "gas_port"
  )
  *
FROM
  "gas_all_data"
WHERE
  "gas_timestamp" IN (SELECT max("gas_timestamp") FROM "gas_all_data" GROUP BY "node_netid", "gas_port")
ORDER BY
  "node_netid",
  "gas_port"