liveBook · Manning

Unix timestamp function

As explained in Logs and Telemetry

The unix_timestamp function returns a timestamp as a numeric Unix time value suitable for arithmetic and comparison.

The unix_timestamp() function emits the current event time as a numeric Unix timestamp, making time available alongside selected fields for filtering, comparison, or arithmetic. section 8.3

Use it in a stream query

SELECT unix_timestamp(), count(rand_value) FROM TAG:'random-num' WHERE rand_value > 0; produces a numeric timestamp and counts records whose rand_value exceeds zero. Output shows values such as 1702943626 and COUNT(rand_value)=1. section 8.3

Listing 8.3 Multiple stream processor definitions: query2.conf
[STREAM_TASK]
  name selectTaskWithTag
  exec SELECT record_tag(), rand_value 
 FROM TAG:'random-num';  #1

[STREAM_TASK]
  name selectSumTask
  exec SELECT now(), sum(rand_value) 
 FROM TAG:'random-num';  #2

[STREAM_TASK]
  name selectWhereTask
  exec SELECT unix_timestamp(), 
 count(rand_value) FROM TAG:'random-num' 
 WHERE rand_value > 0;      #3

Inspect the complete query2.conf definition alongside related stream-processing tasks. section 8.3

How Logs and Telemetry covers it

How deep it goes
Defines query usage and shows output values but does not detail function implementation internals.
Examples
Demonstrates unix_timestamp() in a random-number stream query producing integer timestamps and counts.
What it assumes
Assumes familiarity with SELECT statements, tagged streams, WHERE clauses, and aggregate functions.
What you can do after
Apply it via a stream-processing query to emit numeric timestamps with filtered event counts.
How it connects
Connects timestamps with stream processing, SELECT queries, WHERE filtering, and aggregation through count().

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Logs and Telemetry. The section links point to the parts of the book it draws on.