Skip to content
This repository has been archived by the owner on Mar 31, 2018. It is now read-only.

elasticsearch 2.x support #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

elasticsearch 2.x support #11

wants to merge 2 commits into from

Conversation

danielcbright
Copy link

Purpose

Currently there is no elasticsearch 2.x.x support in the cloudwatch-logs-subscription-consumer library. This PR is a first step forward towards getting support implemented.

Status

DEPENDS ON: amazon-archives/amazon-kinesis-connectors#63
WORK IN PROGRESS / NEED HELP

Related Issues and PRs

Background

I was enticed to use the cloudwatch-logs-subscription-consumer by @dvassallo one day and went about trying to get it to work with our already implemented elasticsearch 2.0.0 installation in AWS. By figuring out what had changed between the 1.x and 2.x versions of elasticsearch (great reference here) I was then able to go through the amazon-kinesis-connectors code and the cloudwatch-subscription-consumer code and make some changes to support 2.x. I then built a local .jar for amazon-kinesis-connectors after making some pom.xml changes. Followed by changes to cloudwatch-logs-subscription-consumer that fixed ImmutableSettings and re-wrote the ElasticsearchEmitter function to use the methods outlined in the java api doc here.

I was then able to make a successful connection to elasticsearch and see records start coming through. There are still a few things to iron out, they are outlined below. But the hope is, people who really need it can start using the configs in the PR and then soon it will be merged and fully functional.

ToDos

Other Notes

  • This was tested in Centos 6.7 and nowhere else.
  • The amazon-kinesis-connectors library was built locally using Maven, and then very hackily the .jar was copied over the local library .jar and then built against, this is not recommended unless you know what you're doing, which I really didn't until I did it :).

danielcbright and others added 2 commits January 21, 2016 13:50
Use the CloudFormation AWS::Logs::SubscriptionFilter resource
The class ```import org.elasticsearch.common.lang3.StringUtils;``` is
not used in elasticsearch 2.x, it is instead called directly using
```import org.apache.commons.lang3.StringUtils;```. This PR has a new
```src\main\java\com\amazonaws\services\logs\connectors\elasticsearch\CloudWatchLogsElasticsearch2Document.java```
with the changes, as well as a new ```pom.xml``` working example
(working on Centos 6.7).
@analytically
Copy link

👍

@gamefundas
Copy link

Hi Dan, Thanks for your writeup. I managed to get the library compiled as per your suggestions but landed with an issue where in the Kinesis client API tries to query DynamoDB for the Lease information and in my case if fails with a HTTP error "Connection Timeout".

This to me seems like the library cant connect to DynamoDB. However I am able to create table, etc using AWS CLI on the same EC2 machine. So not sure what I am missing. Did you come across this problem?

@danielcbright
Copy link
Author

@gamefundas I didn't run into this specific problem, can you post a Gist link with the full output? I don't have time to look at it today but I can probably get back to you tomorrow.

@gamefundas
Copy link

Dan, I am getting the following exception. Assuming this has to do with Http proxy on my end as the Lease table is created in DynamoDB but the API fails to connect to it. Verified that I have IAM role/privileges on the table, my AWS CLI works on the table from the EC2 instance.

Posted an issue for the kinesis-connector project as I am thinking there is no proxy support at the moment.
amazon-archives/amazon-kinesis-connectors#66

Whats going on in the library is beyond me. So I am hoping if someone responds back. Please let me know if you recognize the problem.

2016-02-20 02:57:10,741 INFO AmazonHttpClient - Unable to execute HTTP request: connect timed out
java.net.SocketTimeoutException: connect timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:656)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:524)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:403)
at com.amazonaws.http.conn.ssl.SdkTLSSocketFactory.connectSocket(SdkTLSSocketFactory.java:118)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:706)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:467)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:302)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.invoke(AmazonDynamoDBClient.java:3240)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.createTable(AmazonDynamoDBClient.java:1047)
at com.amazonaws.services.kinesis.leases.impl.LeaseManager.createLeaseTableIfNotExists(LeaseManager.java:118)
at com.amazonaws.services.kinesis.clientlibrary.lib.worker.KinesisClientLibLeaseCoordinator.initialize(KinesisClientLibLeaseCoordinator.java:173)
at com.amazonaws.services.kinesis.clientlibrary.lib.worker.Worker.initialize(Worker.java:373)
at com.amazonaws.services.kinesis.clientlibrary.lib.worker.Worker.run(Worker.java:317)
at com.amazonaws.services.kinesis.connectors.KinesisConnectorExecutorBase.run(KinesisConnectorExecutorBase.java:95)
at com.amazonaws.services.logs.connectors.samples.elasticsearch.ElasticsearchConnector.main(ElasticsearchConnector.java:38)

@danielcbright
Copy link
Author

@gamefundas are you using sticky sessions for your proxy? I'm not sure if that's the problem but maybe a good place to start, also have you verified you can actually connect through your proxy? I would setup something simple, maybe a Python script that uses boto and see if you can do a simple query to rule out a connectivity issue then go from there, I'm at a loss otherwise :(

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants