Am trying to create a simple stream data from a python code, being appended to a log file, and load the streaming data to a Redshift cluster using a Kinesis Agent->Kinesis Firehose.
I confirm that the python code is running fine, creates streaming data which is being appended to a log file. My kinesis agent is started successfully and I verified, and have also done appropriate configurations to pull data from the log file and push it to firehose stream.
The python file is a simple code that logs lat/long positions randomly. This is only to do a sample firehose streaming, and hence used sample data:
latitude = 19.99
longitude = 73.78
file_n = '/tmp/random_lat_lon.log'
def generate_random_data(lat, lon, num_rows, file_name):
with open(file_name, 'w+', 1) as output:
# for _ in xrange(num_rows):
while True:
hex1 = '%012x' % random.randrange(16**12)
flt = float(random.randint(0,100))
dec_lat = random.random()/100
dec_lon = random.random()/100
output.write('%s,%.1f,%.6f,%.6f \n' % (hex1.lower(), flt, lon+dec_lon, lat+dec_lat))
time.sleep(5)
generate_random_data(latitude, longitude, 5, file_n)
Output in the random_lat_lon.log file:
> 83d6c9f7a0be,25.0,73.782042,19.997504
> 18b69c5c5248,25.0,73.788921,19.995153
> 6a0d182996f0,91.0,73.783399,19.998097
> 431ba9e4f38e,0.0,73.781139,19.995481
When I check the kinesis-Agent, I see that its not working, and i am getting the following error trace:
(FileTailer[kinesis:python-stream:/tmp/random_lat_lon.log*]) com.amazon.kinesis.streaming.agent.tailing.FileTailer [ERROR] FileTailer[kinesis:python-stream:/tmp/random_lat_lon.log*]: Error when processing current input file or when tracking its status.
java.lang.IllegalStateException
at com.google.common.base.Preconditions.checkState(Preconditions.java:158)
at com.amazon.kinesis.streaming.agent.tailing.TrackedFileRotationAnalyzer.findCurrentOpenFileAfterTruncate(Unknown Source)
at com.amazon.kinesis.streaming.agent.tailing.SourceFileTracker.updateCurrentFile(Unknown Source)
at com.amazon.kinesis.streaming.agent.tailing.SourceFileTracker.refresh(Unknown Source)
at com.amazon.kinesis.streaming.agent.tailing.FileTailer.updateRecordParser(Unknown Source)
at com.amazon.kinesis.streaming.agent.tailing.FileTailer.processRecords(Unknown Source)
at com.amazon.kinesis.streaming.agent.tailing.FileTailer.runOnce(Unknown Source)
at com.amazon.kinesis.streaming.agent.tailing.FileTailer.run(Unknown Source)
at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:60)
at com.google.common.util.concurrent.Callables$3.run(Callables.java:95)
at java.lang.Thread.run(Thread.java:748)
My kinesis-Agent.json configuration is as follows:
{
"cloudwatch.emitMetrics": true,
"kinesis.endpoint": "https://kinesis.us-east-1.amazonaws.com",
"firehose.endpoint": "",
"flows": [
{
"filePattern": "/tmp/random_lat_lon.log*",
"kinesisStream": "python-stream"
}
]
}
This is my first sample lab experience with Kinesis Firehose (using Python). Am missing something which I couldn't figure out.
Can someone please help with suggestions. Let me know if any details required.
Regards