Skip to content

[8.19] [Stack Monitoring] Fix Recent Log Entries timezone (#249016)#249112

Merged
kibanamachine merged 1 commit intoelastic:8.19from
kibanamachine:backport/8.19/pr-249016
Jan 15, 2026
Merged

[8.19] [Stack Monitoring] Fix Recent Log Entries timezone (#249016)#249112
kibanamachine merged 1 commit intoelastic:8.19from
kibanamachine:backport/8.19/pr-249016

Conversation

@kibanamachine
Copy link
Contributor

Backport

This will backport the following commits from main to 8.19:

Questions ?

Please refer to the Backport tool documentation

Closes elastic#120292

## Summary
The Stack Monitoring **Recent Log Entries** table now respects the
Kibana `dateFormat:tz` advanced setting.

## Details
- Fixes `formatDateTimeLocal` to treat `dateFormat:tz` values of
`Browser`/`null`/unset as the browser-guessed timezone
- Keeps explicit timezone values (e.g. `UTC`, `Asia/Seoul`) working as
expected
- Adds unit tests covering explicit timezone, `Browser`, and
default/unset behavior

## Demo

Current locale is UTC+1 (value should be 2:26)

### Before
<img width="1718" height="1407" alt="SCR-20260114-myjp"
src="https://github.com/user-attachments/assets/18659259-1fe1-4341-a5ce-66593bbad868"
/>

### After
<img width="1720" height="1408" alt="SCR-20260114-mymj"
src="https://github.com/user-attachments/assets/db5f5b96-5671-428f-8992-7bd017ce8378"
/>

## Test plan
- `node scripts/jest
x-pack/platform/plugins/private/monitoring/common/formatting.test.ts`
- Manual: change **Stack Management → Advanced Settings → Time zone
(`dateFormat:tz`)** and confirm the Recent Log Entries timestamp updates

## Manual test data (optional)
If you don't already have Stack Monitoring data available locally, you
can create a minimal set of documents via **Kibana → Dev Tools →
Console**.

Pick values for:
- `<ISO_TIMESTAMP>`: an ISO timestamp like `2026-01-14T16:07:52.324Z`
- `<EPOCH_MS>`: the same moment as epoch millis like `1768406872324`

Then run:

1) Create a minimal cluster stats doc (note the `timestamp` field):

```http
POST metrics-elasticsearch.stack_monitoring.cluster_stats-default/_doc?refresh=wait_for
{
  "@timestamp": "<ISO_TIMESTAMP>",
  "timestamp": <EPOCH_MS>,
  "type": "cluster_stats",
  "metricset": { "name": "cluster_stats" },
  "data_stream": { "type": "metrics", "dataset": "elasticsearch.stack_monitoring.cluster_stats", "namespace": "default" },
  "cluster_uuid": "tz-test-cluster",
  "cluster_name": "tz-test-cluster",
  "license": { "status": "active", "type": "trial", "expiry_date_in_millis": 1894665600000 }
}
```

2) Create a minimal Elasticsearch server log doc for the same cluster:

```http
POST logs-elasticsearch.server-default/_doc?refresh=wait_for
{
  "@timestamp": "<ISO_TIMESTAMP>",
  "message": "TZ regression test log entry - should show in browser timezone",
  "service": { "type": "elasticsearch" },
  "event": { "dataset": "elasticsearch.server" },
  "log": { "level": "INFO" },
  "elasticsearch": {
    "cluster": { "uuid": "tz-test-cluster" },
    "node": { "name": "test-node-1" },
    "component": "test-component"
  }
}
```

3) In Kibana:
- Set the time picker to a range that includes `<ISO_TIMESTAMP>` (e.g.
**Last 15 minutes** if you used “now - 5m”)
- Go to **Stack Monitoring → Elasticsearch → Overview** and confirm
**Recent Log Entries** shows the row
- Flip **Stack Management → Advanced Settings → Time zone
(`dateFormat:tz`)** between `Browser` and `UTC` and confirm the
displayed timestamp shifts accordingly

4) Cleanup (optional):

```http
POST metrics-elasticsearch.stack_monitoring.cluster_stats-default/_delete_by_query?refresh=true
{ "query": { "term": { "cluster_uuid": "tz-test-cluster" } } }
```

```http
POST logs-elasticsearch.*-*/_delete_by_query?refresh=true
{ "query": { "term": { "elasticsearch.cluster.uuid": "tz-test-cluster" } } }
```

# Release Note
Fix Stack Monitoring Recent Log Entries timestamps to respect Kibana's
time zone setting (`dateFormat:tz`).

(cherry picked from commit 67cefd4)
@kibanamachine kibanamachine added the backport This PR is a backport of another PR label Jan 14, 2026
@kibanamachine kibanamachine enabled auto-merge (squash) January 14, 2026 22:12
@kibanamachine kibanamachine added the backport This PR is a backport of another PR label Jan 14, 2026
@kibanamachine kibanamachine merged commit 5f319ef into elastic:8.19 Jan 15, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

3 participants