Gets the second of a timestamp field.
Parameter | Type | Required | Default Value | Description |
---|---|---|---|---|
as | string | optional[a] | _second | The name of the output field. |
field [b] | string | optional[a] | @timestamp | The name of the input field. |
timezone | string | optional[a] | The time offset to use, for example, -01:00 . If not specified, the query's offset will be used. | |
timezoneField | string | optional[a] | @timezone | The name of the field containing the timezone to use, if not specified the query's timezone will be used. This is ignored if the timezone parameter is passed as well. If this is not defined the timezone offset of the query will be used. |
[a] Optional parameters use their default value unless explicitly set. |
Hide omitted argument names for this function
Omitted Argument NamesThe argument name for
field
can be omitted; the following forms of this function are equivalent:logscale Syntaxtime:second("value")
and:
logscale Syntaxtime:second(field="value")
These examples show basic structure only.
time:second()
Examples
Click
next to an example below to get the full details.Extract Second From Timestamp
Get the second from a timestamp using the
time:second()
function
Query
time:second(timestamp, as=second)
Introduction
In this example, the time:second()
function is used
to extract the seconds from a specific timestamp 2025-08-27
08:51:51.312
, demonstrating how to get the second value from a
datetime.
Step-by-Step
Starting with the source repository events.
- logscale
time:second(timestamp, as=second)
Extracts the seconds from the @timestamp field and returns the result in a new field named second. If the
as
parameter is not specified, the result is returned in a field named _second as default. Event Result set.
Summary and Results
The query is used to extract the seconds from a timestamp, which is useful for analyzing events at a second-level granularity.
This query is useful, for example, to analyze per-second patterns, group events by second, or investigate timing patterns within minutes.
Sample output from the incoming example data:
@timestamp | second |
---|---|
2025-08-27 08:51:51.312 | 51 |
The result shows how the time:second()
function
extracts the seconds (in this case 51
) from the
timestamp, indicating it is 51 seconds into the minute.
For visualizing this data, consider using a Bar Chart widget to show
event distribution across seconds, or a Heat Map widget to display
activity patterns within minutes. The time:second()
function is often used with other time functions like
time:minute()
and
time:millisecond()
for precise time analysis.