GithubHelp home page GithubHelp logo

isabella232 / prometheus-packet-sd Goto Github PK

View Code? Open in Web Editor NEW

This project forked from packethost/prometheus-packet-sd

0.0 0.0 0.0 8.43 MB

Prometheus service discovery for Equinix Metal.

Home Page: https://metal.equinix.com

License: Apache License 2.0

Go 94.64% Makefile 4.56% Dockerfile 0.80%

prometheus-packet-sd's Introduction

A service discovery for the Equinix Metal platform compatible with Prometheus.

It's based on the Scaleway adapter.

This repository is Experimental meaning that it's based on untested ideas or techniques and not yet established or finalized or involves a radically new and innovative style! This means that support is best effort (at best!) and we strongly encourage you to NOT use this in production.

How it works

This service gets the list of servers from the Packet API and generates a file which is compatible with the Prometheus file_sd mechanism.

Pre-requisites

You need your Equinix Metal Auth token. You can create the token in the Equinix Metal web app, click on your profile photo and navigate to "API Keys".

Make sure the Equinix Metal Auth Token is in envvar PACKET_AUTH_TOKEN.

Running it

With docker

First, export your PACKET_AUTH_TOKEN to an environment variable and then:

$ docker run -e PACKET_AUTH_TOKEN -v ${PWD}:/tmp quay.io/packet/prometheus-packet-sd --output.file=/tmp/packet.json

.. file packet.json cointaining device labels will appear in current directory.

With the binary from Github Releases

Download the binary from the Releases page.

$ ./prometheus-packet-sd

.. device labels will be in ./packet.json

If you only want to scrape a single project, you can pass project ID:

$ ./prometheus-packet-sd --packet.projectid 508b7fd3-0df2-4837-b0df-65aaf09f642a

You can also pass the project ID in envvar PACKET_PROJECT_ID.

The program runs a Prometheus registry itself, and reports histogram of Equinix Metal API request duration, and number of API failures. See the main.go for the exact label names. If you want to scrape this from a running, docker container, you should expose the port, i.e. add -p 9465:9465 to the docker run command.

Integration with Prometheus

Here is a Prometheus scrape_config snippet that configures Prometheus to scrape node_exporter assuming that it is deployed on all your Equinix Metal servers, and listening on port 9100.

- job_name: node

  # Assuming that prometheus and prometheus-packet-sd are started from the same directory.
  file_sd_configs:
  - files: [ "./packet.json" ]

  # The relabeling does the following:
  # - overwrite the scrape address with the node_exporter's port.
  # - strip leading commas from the tags label.
  # - save the facility label
  # - save the instance label
  relabel_configs:
  - source_labels: [__meta_packet_public_ipv4]
    replacement: "${1}:9100"
    target_label: __address__
  - source_labels: [__meta_packet_tags]
    regex: ",(.+),"
    target_label: tags
  - source_labels: [__meta_packet_facility]
    target_label: facility
  - source_labels: [__meta_packet_hostname]
    target_label: instance

The following meta labels are available on targets during relabeling at the moment:

  • __meta_packet_billing_cycle
  • __meta_packet_device_id
  • __meta_packet_facility
  • __meta_packet_hostname
  • __meta_packet_operating_system
  • __meta_packet_organization_name
  • __meta_packet_plan
  • __meta_packet_private_ipv4
  • __meta_packet_project_id
  • __meta_packet_project_name
  • __meta_packet_public_ipv4
  • __meta_packet_public_ipv6
  • __meta_packet_short_id
  • __meta_packet_state
  • `__meta_packet_switch_uuid
  • __meta_packet_tags

Contributing

PRs and issues are welcome.

License

Apache License 2.0, see LICENSE.

prometheus-packet-sd's People

Contributors

grahamc avatar rainleander avatar t0mk 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.