GithubHelp home page GithubHelp logo

aws_es_checks's Introduction

Custom checks for metrics from elasticsearch using AWS lambda + python 3


! this part of infrastructe uses Serverless framework to deploy resources;


Preparation:

  • install serverless framework: npm install -g serverless

  • install serverless plugins: serverless plugin install -n serverless-python-requirements (Installed to this repo)

Query - to get uniq ID for last 31 days:

GET keepalive*/_search
{
  "size":0,
  "query" : {
    "range" : {
      "machineData.machineTimeUTC" : {
        "gte" : "now-31d"
      }
    }
  },
  "aggs": {
    "machine_ids" : {
      "terms": {
        "field": "machineData.id.keyword",
        "size": 99999
      }
    }
  }
}

Deal with requirements - lambda layers:

Put all function requirements into requirements.txt file in root folder of serverless (same as serverless.yaml file). At this moment I found that only one layer can be built by this plugin (no multi requirements files).

AWS lambda limits for layer size: 50 Mb for updload zip, 250 Mb for unzipped files;

Build layer from requirements:

Following main folder structure: pip install -r requirements_base.txt -t ./base/python/lib/python3.7/site-packages/ (more at https://medium.com/@qtangs/creating-new-aws-lambda-layer-for-python-pandas-library-348b126e9f3e)

Deploy serverless stack to aws:

serverless deploy --aws-profile kibanadev --stage dev serverless deploy --aws-profile kibanadev --stage qa

Update function in AWS after changing (fast deploy):

serverless deploy function --function CreateDynamoDBTable --aws-profile kibanadev serverless deploy function --function MainFunc --aws-profile kibanadev

Remove serverless stack from aws:

serverless remove --aws-profile kibanadev --stage dev

Info for current stack:

serverless info --aws-profile kibanadev --stage dev

aws_es_checks's People

Contributors

vaole 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.