Commit 44972de2 authored by Cameron McFarland's avatar Cameron McFarland

Got some basic local logging working and added the TF listener, load balancer, and target group.

parent 57f04888
......@@ -43,15 +43,19 @@ IAM Policies and Roles:
Need roles/policies to allow proper access to the collectors, enrichers and s3 loaders.
ECS Tasks need a IAM role to allow access to things? Yes.
## Launch Config Changes and Production Instances
Updating the launch config will apply to new systems coming up in the
auto-scaling group. But existing EC2 instances won't be changed. You will
have to rotate them manually to have them replaced.
## Runbook Material
### Logs
You should find logs for any node to be in **/snowplow/logs**.
[ec2-user@ip-10-32-0-206 ~]$ curl http://localhost:8000/health
OK[ec2-user@ip-10-32-0-206 ~]$
Enricher:
Need an iglu resolver config. Is it ok to use the public repo? Need to figure this out.
Also might need a dynamoDB to store stream state. The enricher will make it's own table. This is actually required since hand-making it seems to not work.
Enricher is working? OMG.
Debugging: -Dorg.slf4j.simpleLogger.defaultLogLevel=debug
Testing an event: curl http://34.227.92.217:8000/i\?e\=pv
......@@ -59,22 +63,6 @@ Testing an event: curl http://34.227.92.217:8000/i\?e\=pv
S3Loader:
"I realize now my folly: the app name needs to be different between the enricher and loader ergo the 2 dynamoDB tables were conflicting. Everything makes so much sense now…"
EC2 Autoscaling Stuff:
Need three target groups. These define the health checks we need to use to determine if something is healthy.
Need three auto-scaling groups.
Logging:
-Dlog4j.configuration=file:/snowplow/bin/log4j.properties
```
log4j.rootLogger=INFO, FILE
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=/snowplow/logs/log.out
log4j.appender.FILE.ImmediateFlush=true
log4j.appender.FILE.Threshold=debug
log4j.appender.FILE.Append=false
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
```
Last steps:
Are we using the right SSH key?
Did we clean up everything we made for testing?
......@@ -7,6 +7,7 @@ groupadd snowplow
adduser --system --gid snowplow snowplow
mkdir -p /snowplow
mkdir -p /snowplow/config
mkdir -p /snowplow/logs
## Install SnowPlow Kinesis Collector
mkdir -p /tmp/build
cd /tmp/build
......@@ -115,4 +116,4 @@ akka {
EOF
chown -R snowplow:snowplow /snowplow
## Star the collector service
su snowplow -g snowplow -c '/usr/bin/java -jar /snowplow/bin/snowplow-stream-collector-kinesis-0.15.0.jar --config /snowplow/config/collector.hocon'
su snowplow -g snowplow -c 'nohup /usr/bin/java -jar /snowplow/bin/snowplow-stream-collector-kinesis-0.15.0.jar --config /snowplow/config/collector.hocon > /snowplow/logs/out.log 2>&1 &'
......@@ -7,6 +7,7 @@ groupadd snowplow
adduser --system --gid snowplow snowplow
mkdir -p /snowplow
mkdir -p /snowplow/config
mkdir -p /snowplow/logs
## Install SnowPlow Kinesis Collector
mkdir -p /tmp/build
cd /tmp/build
......@@ -90,4 +91,4 @@ enrich {
EOF
chown -R snowplow:snowplow /snowplow
## Star the collector service
su snowplow -g snowplow -c '/usr/bin/java -jar /snowplow/bin/snowplow-stream-enrich-kinesis-0.21.0.jar --config /snowplow/config/enricher.hocon --resolver file:/snowplow/config/iglu_resolver.json'
su snowplow -g snowplow -c 'nohup /usr/bin/java -jar /snowplow/bin/snowplow-stream-enrich-kinesis-0.21.0.jar --config /snowplow/config/enricher.hocon --resolver file:/snowplow/config/iglu_resolver.json > /snowplow/logs/out.log 2>&1 &'
......@@ -412,6 +412,7 @@ resource "aws_launch_configuration" "snowplow_collector_launch_config" {
associate_public_ip_address = "true"
enable_monitoring = "false"
iam_instance_profile = "snowplow-collector-role"
key_name = "cmcfarland"
security_groups = [
"${aws_security_group.snowplow_security_group.id}",
......@@ -430,6 +431,7 @@ resource "aws_launch_configuration" "snowplow_enricher_launch_config" {
associate_public_ip_address = "true"
enable_monitoring = "false"
iam_instance_profile = "snowplow-enricher-role"
key_name = "cmcfarland"
security_groups = [
"${aws_security_group.snowplow_security_group.id}",
......@@ -448,6 +450,7 @@ resource "aws_launch_configuration" "snowplow_s3loader_launch_config" {
associate_public_ip_address = "true"
enable_monitoring = "false"
iam_instance_profile = "snowplow-s3loader-role"
key_name = "cmcfarland"
security_groups = [
"${aws_security_group.snowplow_security_group.id}",
......@@ -460,12 +463,28 @@ resource "aws_launch_configuration" "snowplow_s3loader_launch_config" {
}
}
// EC2 Target Group
resource "aws_lb_target_group" "snowplow_collector_lb_target_group" {
name = "SnowPlowNLBTargetGroup"
port = 8000
protocol = "TCP"
vpc_id = "${aws_vpc.snowplow_vpc.id}"
tags = {
environment = "SnowPlow"
}
}
// EC2 Auto Scaling Groups
resource "aws_autoscaling_group" "snowplow_collector_autoscaling_group" {
launch_configuration = "${aws_launch_configuration.snowplow_collector_launch_config.id}"
max_size = "3"
min_size = "3"
target_group_arns = [
"${aws_lb_target_group.snowplow_collector_lb_target_group.id}",
]
tag {
key = "environment"
value = "SnowPlow"
......@@ -514,3 +533,33 @@ resource "aws_autoscaling_group" "snowplow_s3loader_autoscaling_group" {
propagate_at_launch = true
}
}
// EC2 Load Balancer
resource "aws_lb" "snowplow_lb" {
name = "SnowPlowNLB"
internal = false
load_balancer_type = "network"
subnets = [
"${aws_subnet.snowplow_subnet_1.id}",
"${aws_subnet.snowplow_subnet_2.id}",
"${aws_subnet.snowplow_subnet_3.id}",
]
tags = {
environment = "SnowPlow"
}
}
resource "aws_lb_listener" "snowplow_collector_lb_listener" {
load_balancer_arn = "${aws_lb.snowplow_lb.arn}"
port = "443"
protocol = "TLS"
ssl_policy = "ELBSecurityPolicy-2016-08"
certificate_arn = "arn:aws:acm:us-east-1:855262394183:certificate/1d954bfe-8b8d-46f2-a678-5a3e53cc6225"
default_action {
type = "forward"
target_group_arn = "${aws_lb_target_group.snowplow_collector_lb_target_group.arn}"
}
}
......@@ -7,6 +7,7 @@ groupadd snowplow
adduser --system --gid snowplow snowplow
mkdir -p /snowplow
mkdir -p /snowplow/config
mkdir -p /snowplow/logs
## Install SnowPlow Kinesis Collector
mkdir -p /tmp/build
cd /tmp/build
......@@ -14,6 +15,16 @@ wget -q http://dl.bintray.com/snowplow/snowplow-generic/snowplow_s3_loader_0.6.0
unzip -d /snowplow/bin snowplow_s3_loader_0.6.0.zip
cd /tmp
rm -rf /tmp/build
## Need a logging config
cat > /snowplow/bin/log4j.properties <<EOX
log4j.rootLogger=INFO, FILE
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=/snowplow/logs/log.out
log4j.appender.FILE.ImmediateFlush=true
log4j.appender.FILE.Threshold=debug
log4j.appender.FILE.Append=false
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
EOX
## Need to copy in a config
cat > /snowplow/config/s3loader.hocon <<EOF
source = "kinesis"
......@@ -58,4 +69,4 @@ s3 {
EOF
chown -R snowplow:snowplow /snowplow
## Star the collector service
su snowplow -g snowplow -c '/usr/bin/java -jar /snowplow/bin/snowplow-s3-loader-0.6.0.jar --config /snowplow/config/s3loader.hocon'
su snowplow -g snowplow -c '/usr/bin/java -Dlog4j.configuration=file:/snowplow/bin/log4j.properties -jar /snowplow/bin/snowplow-s3-loader-0.6.0.jar --config /snowplow/config/s3loader.hocon'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment