Code Monkey home page Code Monkey logo

buildkite-agent-metrics's Introduction

Buildkite Agent Metrics

A command-line tool for collecting Buildkite agent metrics, focusing on enabling auto-scaling. Currently AWS Cloudwatch, StatsD and Prometheus are supported.

Build status

Note: Formerly known as buildkite-metrics, but now buildkite-agent-metrics to reflect the focus of the tool.

Installing

Either download the latest binary from Github Releases or install with:

go get github.com/buildkite/buildkite-agent-metrics

Running

Several running modes are supported. All of them require an Agent Registration Token, found on the Buildkite Agents page.

Running as a Daemon

The simplest deployment is to run as a long-running daemon that collects metrics across all queues in an organization.

buildkite-agent-metrics -token abc123 -interval 30s

Restrict it to a single queue with -queue if you're scaling a single cluster of agents:

buildkite-agent-metrics -token abc123 -interval 30s -queue my-queue

Running as an AWS Lambda

An AWS Lambda bundle is created and published as part of the build process.

It's entrypoint is handler.handle, it requires a python2.7 environment and respects the following env vars:

  • BUILDKITE_TOKEN
  • BUILDKITE_BACKEND
  • BUILDKITE_QUEUE
  • BUILDKITE_QUIET
  • BUILDKITE_CLOUDWATCH_DIMENSIONS

Take a look at https://github.com/buildkite/elastic-ci-stack-for-aws/blob/v3.3.0/templates/metrics.yml for examples of usage.

Backends

By default metrics will be submitted to CloudWatch but the backend can be switched to StatsD or Prometheus using the command-line argument -backend statsd or -backend prometheus respectively.

The Cloudwatch backend supports the following arguments:

  • -cloudwatch-dimensions: A optional custom dimension in the form of Key=Value, Key=Value

The StatsD backend supports the following arguments:

  • -statsd-host HOST: The StatsD host and port (defaults to 127.0.0.1:8125).
  • -statsd-tags: Some StatsD servers like the agent provided by Datadog support tags. If specified, metrics will be tagged by queue otherwise metrics will include the queue name in the metric. Only enable this option if you know your StatsD server supports tags.

The Prometheus backend supports the following arguments

  • -prometheus-addr: The local address to listen on (defaults to :8080).
  • -prometheus-path: The path under prometheus-addr to expose metrics on (defaults to /metrics).

Upgrading from v2 to v3

  1. The -org argument is no longer needed
  2. The -token argument is now an Agent Registration Token — the same used in the Buildkite Agent configuration file, and found on the Buildkite Agents page.
  3. Build and pipeline metrics have been removed, focusing on agents and jobs by queue for auto–scaling. If you have a compelling reason to gather build or pipeline metrics please continue to use the previous version or open an issue with details.

Development

You can build and run the binary tool locally with golang installed:

go run *.go -token [buildkite agent registration token]

Currently this will publish metrics to Cloudwatch under the custom metric prefix of Buildkite, using AWS credentials from your environment. The machine will require the cloudwatch:PutMetricData IAM permission.

Metrics

The following metrics are gathered when no specific queue is supplied:

Buildkite > RunningJobsCount
Buildkite > ScheduledJobsCount
Buildkite > UnfinishedJobsCount
Buildkite > IdleAgentsCount
Buildkite > BusyAgentsCount
Buildkite > TotalAgentsCount

Buildkite > (Queue) > RunningJobsCount
Buildkite > (Queue) > ScheduledJobsCount
Buildkite > (Queue) > UnfinishedJobsCount
Buildkite > (Queue) > IdleAgentsCount
Buildkite > (Queue) > BusyAgentsCount
Buildkite > (Queue) > TotalAgentsCount

When a queue is specified, only that queue's metrics are published.

License

See LICENSE.md (MIT)

buildkite-agent-metrics's People

Contributors

lox avatar sj26 avatar toolmantim avatar callumj avatar theist avatar rbvigilante avatar paulolai avatar eliank avatar irabinovitch avatar martinbaillie avatar majolo 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.