Git Product home page Git Product logo

aws-lambda-telescope-msk's Introduction

aws-lambda-telescope-msk

Brought to you by Telemetry Team

Telescope library for interacting with an MSK/Kafka cluster. This lambda is responsible for fetching metrics about MSK and passing them to Clickhouse. An example usage of the metrics can be seen on the Telescope MSK Grafana Dashboard.

Requirements

Quick start

Install dependencies using Poetry:

make setup

All available interactions with the MSK cluster are packaged as individual Python scripts in bin/. Run each script as poetry run bin/<script.py> prefixed with the desired AWS profile. Example:

aws-profile -p telemetry-mdtp-staging-RoleTelemetryAdministrator poetry run bin/consumer-groups.py --help

Simple Producer Test Lambda

The python script producer.py is used as a lambda function's handler entrypoint. This lambda can be used to test generating messages as a Kafka producer. All it requires is a lambda test payload that defines the target topic and the data to be posted to the topic. For example:

{
  "topic": "logs",
  "data": {
    "data0": "hello",
    "data1": "world"
  }
}

Local development

To run locally the plaintext bootstrap cluster host names must be added to local host IP address:

127.0.0.1       localhost       b-1.msk-cluster.mmfn29.c4.kafka.eu-west-2.amazonaws.com:9092,b-2.msk-cluster.mmfn29.c
4.kafka.eu-west-2.amazonaws.com:9092,b-3.msk-cluster.mmfn29.c4.kafka.eu-west-2.amazonaws.com:9092

Fetch the ip from ecs node on aws console, Then an SSH tunnel must be set up using an the ip to forward the port to localhost:

ssh -L 9092:localhost:9092 10.3.0.191

Once a port is open you can run the standard scripts as above:

aws-profile -p telemetry-mdtp-staging-RoleTelemetryAdministrator \
  poetry run bin/consumer-groups.py --help

Sync and run in ECS

ECS is currently unavailable as of TEL-2300, permissions to run telemetry ecs must be added to the labs security group if wanting to run

export ECS_INSTANCE_IP_ADDRESS=10.3.0.191
ssh $ECS_INSTANCE_IP_ADDRESS
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
./poetry/bin/poetry install
export AWS_DEFAULT_REGION=eu-west-2
python3 .poetry/bin/poetry run python3 bin/consumer-groups.py

Poetry Install on Mac M1 chips

These instructions are taken from this source

  • Install librdkafka using Brew
  • Set environment variables to point at install location
  • Run poetry install/update as appropriate
brew install librdkafka
# Get the version number installed
ls -la /opt/homebrew/Cellar/librdkafka
# Export the file paths
export C_INCLUDE_PATH=/opt/homebrew/Cellar/librdkafka/1.8.2/include
export LIBRARY_PATH=/opt/homebrew/Cellar/librdkafka/1.8.2/lib

License

This code is open source software licensed under the Apache 2.0 License.

aws-lambda-telescope-msk's People

Contributors

timothyfothergill avatar sjpalf avatar crumplepang avatar corinwilkins avatar hmrc-web-operations avatar webit4me avatar gavd avatar matthew-hollick avatar samallwright avatar vitorbrandao avatar

Watchers

 avatar James Cloos avatar  avatar  avatar Craig Edmunds avatar David Goodall avatar  avatar Reeshi Shah avatar Dave Randall avatar  avatar

Forkers

uk-gov-mirror

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.