Git Product home page Git Product logo

clickstream-logging's Introduction

API Gateway - Kinesis Logging

This repository is for guide how to log API Gateway requests to S3 using Kinesis

Running this tutorial will provision below architecture on your AWS Account

Running this repository may cost you to provision AWS resources

Prerequisites

  • awscli
  • Nodejs 18+
  • Python 3.11
  • AWS Account and Locally configured AWS credential

Installation

Install project dependencies

$ npm i

Install cdk in global context and run cdk init if you did not initailize cdk yet.

$ npm i -g [email protected]
$ cdk init
$ cdk bootstrap

Deploy CDK Stacks on AWS

$ cdk deploy "*" --require-approval never

Usage

  1. Invoke API Gateway endpoint with some data (I used HTTPie)
$ http post https://act1cqfmhh.execute-api.ap-northeast-2.amazonaws.com/dev/\?path\=/items/323\&param1\=value1\&param2\=value2 text=hihi dodo=dada

HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 133
Content-Type: application/json
Date: Mon, 27 Jul 2020 09:50:34 GMT
X-Amzn-Trace-Id: Root=1-5f1ea36a-2e0004ffc4872e731c05c655
x-amz-apigw-id: QU54lHRnIE0FVug=
x-amzn-RequestId: 7b0c6ced-54f2-41a6-b6eb-67c34757f4ee

{
    "EncryptionType": "KMS",
    "SequenceNumber": "49609269679743302945603165999532102289236812540189605890",
    "ShardId": "shardId-000000000000"
}
  1. Open S3 bucket to check if your data is stored well
{"params": {"param1": "value1","param2": "value2","path": "\/items\/323"},"body": {"text":"hihi","dodo":"dada"},"stage": "dev","http_method": "POST","request_id": "7343872d-76d9-43cd-acf3-d67c414d06aa","resource_path": "/","resource_id": "qycjw0slz9","request_time": "28/Jul/2020:01:31:24 +0000","source_ip": "54.239.119.16","user_agent": "HTTPie/2.1.0"}
...
  1. Check out S3 stored logs

  1. Query S3 with Amazon Athena using Glue Crawler (with just few clicks)

Cleanup Resource

Remove all resources used in this tutorial.

$ cdk destroy "*"

clickstream-logging's People

Contributors

dependabot[bot] avatar haandol avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.