To ask a good question, you really want to tell people what is the desired output. Illustrate with a table (anonymize as needed), not just code, not a screenshot with output that you think is wrong....
See more...
To ask a good question, you really want to tell people what is the desired output. Illustrate with a table (anonymize as needed), not just code, not a screenshot with output that you think is wrong. (Screenshots are usually less useful anyway.) For example, agent.status.policy_refresh_at UpdateDate UpdateTime host 2024-01-04T10:31:35.529752Z ?? ??? blah Without your actual description, volunteers can speculate UpdateDate (per customary denotation) as 2024-01-04. But what about UpdateTime? Do you want 10:31:35.529752Z? Do you want 10:31:35.529752? Do you want 10:31:35.5 as your initial code would have suggested? (Why truncate to 10 characters? Is there a desired precision?) You also want to let people know your intention with UpdateData and UpdateTime. Are these for display only? Do you intend to perform numerical comparison after this table is established? If not, there is no benefit to convert agent.status.policy_refresh_at to epoch value. If you want UpdateTime to include time zone (the trailing "Z" is a valid timezone, not an idle letter), this should suffice index = xyz
| eval agent.status.policy_refresh_at = split('agent.status.policy_refresh_at', "T")
| eval UpdateDate = mvindex('agent.status.policy_refresh_at', 0)
| eval UpdateTime = mvindex('agent.status.policy_refresh_at', 1) Your sample data will give UpdateDate UpdateTime agent.status.policy_refresh_at host 2024-01-04 10:31:35.529752Z 2024-01-04 10:31:35.529752Z CN**** 2024-01-04 10:31:51.654448Z 2024-01-04 10:31:51.654448Z CN**** 2023-11-26 05:57:47.775675Z 2023-11-26 05:57:47.775675Z gb**** 2024-01-04 10:32:14.416359Z 2024-01-04 10:32:14.416359Z cn**** 2024-01-04 10:30:32.998086Z 2024-01-04 10:30:32.998086Z cn**** If you do not wish timezone to be included (not sure why that is desirable), you can strip it, like index = xyz
| eval agent.status.policy_refresh_at = split('agent.status.policy_refresh_at', "T")
| eval UpdateDate = mvindex('agent.status.policy_refresh_at', 0)
| eval UpdateTime = replace(mvindex('agent.status.policy_refresh_at', 1), "\D$", "") If you want to control precision, you can also limit number of decimals, etc. Here is an emulation you can play with and compare with real data | makeresults format=csv data="agent.status.policy_refresh_at,host
2024-01-04T10:31:35.529752Z,CN****
2024-01-04T10:31:51.654448Z,CN****
2023-11-26T05:57:47.775675Z,gb****
2024-01-04T10:32:14.416359Z,cn****
2024-01-04T10:30:32.998086Z,cn****"
``` data emulation above, equivalent to
index = xyz
```