ngrok inspection API returns UTC timestamps while dashboard shows local time
0 reputation · 04 Sept 2024, 22:07 UTC
0 reputation · 04 Sept 2024, 22:07 UTC
Goal: Ensure that timestamp data returned by ngrok’s inspection API and log output can be interpreted consistently across different regional time zones without requiring each consumer to apply custom conversion logic.
Constraints: The inspection API (GET /api/requests) and ngrok log files always emit timestamps in ISO‑8601 format ending with “Z”, indicating UTC. No configuration flag or yaml setting exists to shift this output to a local zone, and the web dashboard’s local‑time display relies solely on browser‑side JavaScript, which may be unavailable when logs are consumed programmatically or when scripting is disabled.
Questions: Is there a way to configure ngrok to emit timestamps in a specific time zone via its API or configuration file? Does ngrok plan to expose a timezone offset parameter in the inspection API? How can consumers reliably convert the UTC timestamps to local time without depending on browser JavaScript?
There is currently no configuration flag, YAML setting, or API parameter that allows ngrok to emit timestamps in a specific local time zone. The inspection API (/api/requests) and log files are designed to provide a universal source of truth by strictly using UTC (ISO-8601 format ending in “Z”).
The discrepancy between the API and the dashboard is a result of where the data transformation occurs:
Since the server-side output cannot be changed, consumers must handle the conversion in their own processing logic. Because the API uses the ISO-8601 standard, most modern languages can parse these strings natively without manual regex.
from datetime import datetime
import pytz
# Example API timestamp
utc_time_str = "2026-10-19T09:02:26Z"
# Parse UTC string and localize to a specific zone
utc_dt = datetime.fromisoformat(utc_time_str.replace('Z', '+00:00'))
local_tz = pytz.timezone('America/New_York')
local_dt = utc_dt.astimezone(local_tz)
print(local_dt.strftime('%Y-%m-%d %H:%M:%S %Z'))
const utcDate = new Date("2026-10-19T09:02:26Z");
// Convert to a specific locale string
console.log(utcDate.toLocaleString("en-US", { timeZone: "America/New_York" }));
To verify that your conversion logic is accurate, you can perform a side-by-side check:
GET /api/requests and note the timestamp of a specific request.Diagnostic Detail: Are you consuming these logs via a third-party SIEM or log aggregator? If so, the conversion should typically be handled at the ingestion layer (e.g., Logstash or Fluentd) rather than in the script fetching the API data.
Use comments to ask for clarification. Post a solution as an answer.
35,775 reputation · 05 Sept 2024, 04:33 UTC
It is important to clarify that the Z suffix in the Inspection API's ISO-8601 timestamps explicitly denotes UTC (Zero offset). Because this is a server-side standard for the API, modifying the local system clock of the machine running the ngrok agent will not alter the timestamps generated by the remote API server.
When implementing a conversion layer, avoid manual string slicing of the timestamp. Instead, use standard libraries that handle IANA timezone databases to account for Daylight Saving Time (DST) transitions, which the ngrok dashboard handles automatically via the browser's Intl API. For example:
datetime.fromisoformat() can parse these strings directly.Date object natively parses ISO-8601 UTC strings.This approach ensures that logs remain consistent even if the consuming script is moved across different regional servers.