Kinesis Agent is a standalone Java software program software that provides a simple method to acquire and ship information to Amazon Kinesis Knowledge Streams and Amazon Kinesis Knowledge Firehose. The agent repeatedly displays a set of information and sends new information to the specified vacation spot. The agent handles file rotation, checkpointing, and retry upon failures. It delivers all your information in a dependable, well timed, and easy method. It additionally emits Amazon CloudWatch metrics that can assist you higher monitor and troubleshoot the streaming course of.
This put up describes the steps to ship information from a containerized software to Kinesis Knowledge Firehose utilizing Kinesis Agent. Extra particularly, we present the best way to run Kinesis Agent as a sidecar container for an software working in Amazon Elastic Container Service (Amazon ECS). After the information is in Kinesis Knowledge Firehose, it may be despatched to any supported vacation spot, corresponding to Amazon Easy Storage Service (Amazon S3).
With a purpose to current the important thing factors required for this setup, we assume that you’re acquainted with Amazon ECS and dealing with containers. We additionally keep away from the implementation particulars and packaging strategy of our take a look at information era software, known as the producer.
Answer overview
As depicted within the following determine, we configure a Kinesis Agent container as a sidecar that may learn information created by the producer container. On this occasion, the producer and Kinesis Agent containers share information by way of a bind mount in Amazon ECS.
Stipulations
It’s best to fulfill the next stipulations for the profitable completion of this process:
With these stipulations in place, you possibly can start subsequent step to bundle a Kinesis Agent and your required agent configuration as a container in your native improvement machine.
Create a Kinesis Agent configuration file
We use the Kinesis Agent configuration file to configure the supply and vacation spot, amongst different information switch settings. The next code makes use of the minimal configuration required to learn the contents of information matching /var/log/producer/*.log
and publish them to a Kinesis Knowledge Firehose supply stream referred to as kinesis-agent-demo
:
Create a container picture for Kinesis Agent
To deploy Kinesis Agent as a sidecar in Amazon ECS, you first need to bundle it as a container picture. The container will need to have Kinesis Agent, which
and discover
binaries, and the Kinesis Agent configuration file that you just ready earlier. Its entry level should be configured utilizing the start-aws-kinesis-agent
script. This command is put in once you run the yum set up aws-kinesis-agent
step. The ensuing Dockerfile ought to look as follows:
Run the docker construct
command to construct this container:
After the picture is constructed, it must be pushed to a container registry like Amazon ECR so as to reference it within the subsequent part.
Create an ECS process definition with Kinesis Agent and the appliance container
Now that you’ve got Kinesis Agent packaged as a container picture, you should utilize it in your ECS process definitions to run as sidecar. To try this, you create an ECS process definition along with your software container (referred to as producer
) and Kinesis Agent container. All containers in a process definition are scheduled on the identical container host and due to this fact can share sources corresponding to bind mounts.
Within the following pattern container definition, we use a bind mount referred to as logs_dir
to share a listing between the producer
container and kinesis-agent
container.
You need to use the next template as a place to begin, however make sure you change taskRoleArn
and executionRoleArn
to legitimate IAM roles in your AWS account. On this occasion, the IAM function used for taskRoleArn
will need to have write permissions to Kinesis Knowledge Firehose that you just specified earlier within the agent.json
file. Moreover, guarantee that the ECR picture paths and awslogs-region
are modified as per your AWS account.
Register the duty definition with the next command:
Run a brand new ECS process
Lastly, you possibly can run a brand new ECS process utilizing the duty definition you simply created utilizing the aws ecs run-task
command. When the duty is began, you must be capable to see two containers working beneath that process on the Amazon ECS console.
Conclusion
This put up confirmed how easy it’s to run Kinesis Agent in a containerized setting. Though we used Amazon ECS as our container orchestration service on this put up, you should utilize a Kinesis Agent container in different environments corresponding to Amazon Elastic Kubernetes Service (Amazon EKS).
To be taught extra about utilizing Kinesis Agent, check with Writing to Amazon Kinesis Knowledge Streams Utilizing Kinesis Agent. For extra details about Amazon ECS, check with the Amazon ECS Developer Information.
In regards to the Creator
Buddhike de Silva is a Senior Specialist Options Architect at Amazon Net Companies. Buddhike helps prospects run massive scale streaming analytics workloads on AWS and make the most effective out of their cloud journey.