GithubHelp home page GithubHelp logo

isabella232 / preemption-exporter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from banzaicloud/preemption-exporter

0.0 0.0 0.0 3.14 MB

Prometheus preemptible instance exporter to monitor GCP instance termination with Hollowtrees

License: Apache License 2.0

Makefile 20.54% Go 72.96% Shell 2.19% Dockerfile 4.31%

preemption-exporter's Introduction

Preemptible instance termination exporter

Prometheus exporters are used to export metrics from third-party systems as Prometheus metrics - this is an exporter to scrape for GCP spot price termination notice on the instance for Hollowtrees.

Preemptible instance lifecycle

Preemptible VMs are Google Compute Engine VM instances that last a maximum of 24 hours and provide no availability guarantees. Preemptible VMs are priced lower than standard Compute Engine VMs and offer the same machine types and options.

Note: reemptible instances require available CPU quotas like regular instances. To avoid preemptible instances consuming the CPU quotas for your regular instances, you can request a special Preemptible CPU quota. After Compute Engine grants you preemptible CPU quota in that region, all preemptible instances will count against that quota. All regular instances will continue to count against the regular CPU quota.

Preemptible instance termination notice

It can be determined if an instance was preempted from inside the instance itself. This is useful if we want to handle a shutdown due to a Compute Engine preeemption differently from a normal shutdown in a shutdown script. To do this, simply check the metadata server for the preempted value in your instance's default instance metadata.

For example, use curl from within your instance to obtain the value for preempted:

curl "http://metadata.google.internal/computeMetadata/v1/instance/preempted" -H "Metadata-Flavor: Google"
TRUE

If this value is TRUE, the instance was preempted by Compute Engine, otherwise it will be FALSE.

Quick start

The project uses the promu Prometheus utility tool. To build the exporter promu needs to be installed. To install promu and build the exporter:

go get github.com/prometheus/promu
promu build

The following options can be configured when starting the exporter:

./preemption-exporter --help
Usage of ./preemption-exporte:
  -bind-addr string
        bind address for the metrics server (default ":9189")
  -log-level string
        log level (default "info")
  -metadata-endpoint string
        metadata endpoint to query (default "http://169.254.169.254/latest/meta-data/")
  -metrics-path string
        path to metrics endpoint (default "/metrics")

Test locally

The GCP instance metadata is available at http://metadata.google.internal/computeMetadata/v1/instance. By default this is the endpoint that is being queried by the exporter but it is quite hard to reproduce a termination notice on a GCP instance for testing, so the meta-data endpoint can be changed in the configuration. There is a test server in the utils directory that can be used to mock the behavior of the metadata endpoint. It listens on port 9092 and provides dummy responses for /id and /scheduling/preempted. It can be started with:

go run util/test_server.go

The exporter can be started with this configuration to query this endpoint locally:

./preemption-exporter --metadata-endpoint http://localhost:9092/computeMetadata/v1/instance/ --log-level debug

Default Hollowtrees node exporters associated to alerts:

preemption-exporter's People

Contributors

matyix avatar ahma avatar martonsereg 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.