Giter VIP home page Giter VIP logo

docker_aws_ce_api_prometheus_exporter's Introduction

AWS Cost Explorer Prometheus Exporter

Links

This Python module allows you to run AWS API calls through Boto3 and utilise IAM Role to query the AWS api. It expose the results of api calls as Prometheus metrics. Metrics must be described in YAML. For example:

aws_services_information:
  description: AWS Services running in account
  service: ce
  method: get_cost_and_usage
  method_args: |
    {
      "TimePeriod": {
        "Start": (datetime.now() - timedelta(days=7)).strftime("%Y-%m-%d"),
        "End": datetime.now().strftime("%Y-%m-%d")
      },
      "Granularity": 'MONTHLY',
      "Metrics": ["BlendedCost","UnblendedCost"],
      "GroupBy": [
        {
          "Type": "DIMENSION",
          "Key": "SERVICE"
        }
      ]
    }
  label_names:
    - aws_service_name
    - blended_cost_amount
    - blended_cost_unit
  search: |
    ResultsByTime[].Groups[].{aws_service_name: Keys[0], blended_cost_amount: Metrics.UnblendedCost.Amount, blended_cost_unit: Metrics.UnblendedCost.Unit, value: `1`}

Usage

Running using Docker (on EC2 instance):

# PERIOD_SECONDS in seconds to query AWS API, as AWS cost explorer api cast money every time we use it.
# EC2 should required a instance profile attached to it and 
# Please replace ROLEARN value to with other appropriate role ARN and Trust relationships should have EC2 instance role as Trusted entities.
# 

docker run --network="host" --rm -it -p 9000:9000 -e "APPPORT=9000"  -e "PERIOD_SECONDS=18000" -e "AWS_DEFAULT_REGION=eu-central-1" -e  -e "ROLEARN=arn:aws:iam::111111111:role/iam_role_nitin_test" nitindas/aws-api-prometheus-exporter:latest

Running using Docker (on local):

# PERIOD_SECONDS in seconds to query AWS API, as AWS cost explorer api cast money every time we use it.
# ACCESS and Secret keys are required as environment variable.
# Please replace ROLEARN value to with other appropriate role ARN and Trust relationships should have Account ARN as Trusted entities.
# 

docker run --network="host" --rm -it -p 9000:9000 -e "APPPORT=9000"  -e "PERIOD_SECONDS=18000" -e "AWS_DEFAULT_REGION=eu-central-1" -e  -e "ROLEARN=arn:aws:iam::111111111:role/iam_role_nitin_test" -e "AWS_ACCESS_KEY_ID=****************" -e "AWS_SECRET_ACCESS_KEY=*********************" nitindas/aws-api-prometheus-exporter:latest

docker_aws_ce_api_prometheus_exporter's People

Contributors

nitinda avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

gnk-cloud

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.