title: Reading timestamp using DStream API in Spark Straming from Kafka
body: <p>I want to read the values from a Kafka topic with Spark streaming using Python. I am using the DStream API using the <code>spark-streaming-kafka-0-8</code> support (although deprecated). My code is the following:</p>
  
  <pre><code>from pyspark import SparkContext, SparkConf
  from pyspark.streaming import StreamingContext
  from pyspark.streaming.kafka import KafkaUtils
  
  # Local SparkContext and StreamingContext (batch interval of 5 seconds)
  sc = SparkContext(master="local[*]",
                    appName="Kafka-DStream-StdOut",
                    conf=SparkConf()
                    .set("spark.jars.packages", "org.apache.spark:spark-streaming-kafka-0-8_2.11:2.4.5"))
  ssc = StreamingContext(sc, 5)
  
  # Input: DStream from Apache Kafka
  stream = KafkaUtils.createStream(
      ssc, "localhost:2181", "spark-streaming-consumer", {"test-topic": 1})
  
  # Output: show stream in the console
  stream.pprint()
  
  ssc.start()
  ssc.awaitTermination()
  </code></pre>
  
  <p>The problem is that I only receive the key and the value stored in Kafka, but not the timestamp. I see something like this in the console when sending random numbers each second from a Kafka producer (code <a href="https://github.com/bonigarcia/spark-examples/blob/master/kafka/kafka-rnd_int_producer.py" rel="nofollow noreferrer">here</a>):</p>
  
  <pre><code>-------------------------------------------
  Time: 2020-04-30 17:12:10
  -------------------------------------------
  (None, '69')
  (None, '68')
  (None, '6')
  (None, '25')
  (None, '73')
  </code></pre>
  
  <p>Is there any way to read the timestamp in Spark using this approach?</p>