Skip to content

Commit

Permalink
Merge pull request #87 from zotoio/feature/metrics
Browse files Browse the repository at this point in the history
Feature/metrics
  • Loading branch information
Neko-Design authored Apr 4, 2018
2 parents 3b53744 + e29f3e8 commit 45b698b
Show file tree
Hide file tree
Showing 13 changed files with 600 additions and 35 deletions.
2 changes: 2 additions & 0 deletions .envExample
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ GTM_SONAR_JAVA_BINARIES=target
GTM_SONAR_MODULES=
GTM_TASK_CONFIG_DEFAULT_URL=
GTM_TASK_CONFIG_DEFAULT_MESSAGE_PATH=
GTM_DYNAMO_TABLE_EVENTS=GtmEvents
GTM_AWS_VPC_ID=<redacted>
166 changes: 144 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@
"bunyan-logstash-tcp": "^1.0.0",
"cwlogs-writable": "^1.0.0",
"dockerode": "^2.5.3",
"dynamodb-stream": "^0.1.3",
"elasticsearch": "^14.2.2",
"express": "^4.16.2",
"express-nunjucks": "^2.2.3",
"express-sse": "^0.4.1",
Expand All @@ -130,10 +132,12 @@
"sqs-consumer": "^3.8.0",
"systemjs": "^0.21.0",
"teamcity-rest-api": "0.0.8",
"tempus-fugit": "^2.3.1",
"travis-ci": "^2.1.1",
"uuid": "^3.1.0",
"webpack": "^4.0.0",
"xml2js": "^0.4.19",
"yamljs": "^0.3.0"
"yamljs": "^0.3.0",
"zlib": "^1.0.5"
}
}
44 changes: 43 additions & 1 deletion serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ provider:
environment:
GTM_GITHUB_WEBHOOK_SECRET: ${env:GTM_GITHUB_WEBHOOK_SECRET}


iamRoleStatements:
- Effect: Allow
Action:
Expand All @@ -30,6 +29,12 @@ provider:
Resource:
Fn::GetAtt: [ ResultsQueue, Arn ]

- Effect: Allow
Action:
- dynamodb:UpdateItem
Resource:
Fn::GetAtt: [ EventsTable, Arn ]


package:
individually: true
Expand Down Expand Up @@ -66,6 +71,21 @@ functions:
events:
- sns: ${env:GTM_SNS_RESULTS_TOPIC}

gtmGithubMetricCapture:
handler: dist/src/serverless/gtmGithubMetricCapture/gtmGithubMetricCapture.handler
environment:
DYNAMO_DB_TABLE_EVENTS:
Ref: EventsTable

package:
include:
- dist/src/serverless/gtmGithubMetricCapture/**

events:
- cloudwatchLog:
logGroup: 'gtmAgent'
filter: '{$.resultType != ""}'

resources:
Resources:
PendingQueue:
Expand All @@ -82,6 +102,28 @@ resources:
MessageRetentionPeriod: 1209600
VisibilityTimeout: 7200

EventsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: GtmEvents
AttributeDefinitions:
- AttributeName: ghEventId
AttributeType: S
KeySchema:
- AttributeName: ghEventId
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
StreamSpecification:
StreamViewType: NEW_IMAGE

# DynamoVpcEndpoint:
# Type: AWS::EC2::VPCEndpoint
# Properties:
# ServiceName: com.amazonaws.${env:GTM_AWS_REGION}.dynamodb
# VpcId: ${env:GTM_AWS_VPC_ID}

custom:
dotenv:
path: .env
2 changes: 2 additions & 0 deletions src/agent/Agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import 'babel-polyfill';
import { default as AgentLogger } from './AgentLogger';
import { default as AgentMetrics } from './AgentMetrics';
import { default as express } from 'express';
import { default as bodyParser } from 'body-parser';
import { default as expressNunjucks } from 'express-nunjucks';
Expand Down Expand Up @@ -59,6 +60,7 @@ export class Agent {
this.setup();
this.configureRoutes();
this.consumeQueue();
AgentMetrics.configureRoutes(app);
}

/**
Expand Down
Loading

0 comments on commit 45b698b

Please sign in to comment.