GithubHelp home page GithubHelp logo

otani88 / prometheus-msk-discovery Goto Github PK

View Code? Open in Web Editor NEW

This project forked from statsbomb/prometheus-msk-discovery

0.0 0.0 0.0 42 KB

A Prometheus discoverer that scrapes Amazon MSK and a generates file SD configuration file.

License: Apache License 2.0

Dockerfile 2.63% Go 97.37%

prometheus-msk-discovery's Introduction

statsbomb/prometheus-msk-discovery Test Go Report Card

prometheus-msk-discovery

Service discovery for AWS MSK, compatible with Prometheus.

How it works

This service gets a list of MSK clusters in an AWS account and exports each broker to a Prometheus-compatible static config to be used with the file_sd_config mechanism.

Pre-requisites

1) IAM Policy

When using AWS credentials or IAM Roles, the following policy needs to be attached to the role/user being used:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "kafka:ListClusters",
                "kafka:ListNodes"
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}

2) AWS Credentials

  • No special provisions are made to obtain AWS credentials and instead that process is left to the AWS SDK. Credentials will be searched for automatically in the order specified in the documentation.

Running it

Usage of ./prometheus-msk-discovery:
  -filter string
    	a regex pattern to filter cluster names from the results
  -job-prefix string
    	string with which to prefix each job label (default "msk")
  -output string
    	path of the file to write MSK discovery information to (default "msk_file_sd.yml")
  -scrape-interval duration
    	interval at which to scrape the AWS API for MSK cluster information (default 5m0s)

Example output:

$ ./prometheus-msk-discovery -scrape-interval 10s -filter 'primary'
2021/04/04 21:02:55 Writing 1 discovered exporters to msk_file_sd.yml

An example output file can be found here

Integration with kube-prometheus-stack

The Docker image for this project can be used to inject a container into the Prometheus Spec of a kube-prometheus-stack installation by using the following snippet in values.yaml:

prometheus:
  prometheusSpec:
    containers:
      - name: prometheus-msk-discovery
        image: statsbomb/prometheus-msk-discovery:latest
        args:
          - -output
          - /config-out/msk_file_sd.yml
        volumeMounts:
          - name: config-out
            mountPath: /config-out

You'll then need to add something similar to the following to your additionalScrapeConfig:

- job_name: prometheus-msk-discovery
  file_sd_configs:
    - files:
        - /etc/prometheus/config_out/msk_file_sd.yml
  honor_labels: true

Other Kubernetes Setups

If you're not using the kube-prometheus-stack Helm chart then the general idea for running prometheus-msk-discovery is that it needs to be run as a sidecar container alongside the container that is running Prometheus. You'll need to ensure that there is a shared volume mounted to both of the containers in order for Prometheus to be able to read the config file that prometheus-msk-discovery writes.

Building

Building can be done just by using go build

Contributing

Pull requests, issues and suggestions are appreciated.

Credits

License

Apache License 2.0, see LICENSE.

prometheus-msk-discovery's People

Contributors

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