Stream ApacheFlink:如何在摄取时间模式下获取事件的时间戳?

Stream ApacheFlink:如何在摄取时间模式下获取事件的时间戳?,stream,apache-flink,flink-streaming,Stream,Apache Flink,Flink Streaming,我想知道是否有可能通过使用Flink的摄入时间模式获得记录的时间戳。考虑以下flink代码示例() 默认情况下,等级和薪水都不包含时间戳字段。然而,由于Flink允许使用“ingestionTime”将挂钟时间戳分配给数据流中的记录,所以有可能在运行时获得这样的时间戳吗?例如,以下是我正在尝试做的: val oldDatastream = env.addSource... // Using ingestion time val newDatastream = oldDatastream.map

我想知道是否有可能通过使用Flink的摄入时间模式获得记录的时间戳。考虑以下flink代码示例()

默认情况下,等级和薪水都不包含时间戳字段。然而,由于Flink允许使用“ingestionTime”将挂钟时间戳分配给数据流中的记录,所以有可能在运行时获得这样的时间戳吗?例如,以下是我正在尝试做的:

val oldDatastream = env.addSource...  // Using ingestion time
val newDatastream = oldDatastream.map{record =>   
    val ts = getRecordTimestamp(record)
    // do some thing with ts
    }

感谢您的帮助。

使用
ProcessFunction
它提供了一个
上下文
,您可以使用它来获取元素的时间戳(无论是摄取、处理还是事件时间)。

使用
ProcessFunction
它提供了一个
上下文
,您可以使用它来获取元素的时间戳(无论是摄入、处理还是活动时间)。

谢谢,这就是我要找的。谢谢,这就是我要找的。
val oldDatastream = env.addSource...  // Using ingestion time
val newDatastream = oldDatastream.map{record =>   
    val ts = getRecordTimestamp(record)
    // do some thing with ts
    }