promdev_sd

package module
v0.0.0-...-e721885 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2024 License: BSD-2-Clause Imports: 12 Imported by: 0

README

promdev_sd

Prometheus Service Discovery for local/dev environments using HTTP_SD

Basic Idea

A poor man's Prometheus service discovery.

I'm running tilt or docker-compose or similar as I'm developing my code, and want to hook into an org-wide Prometheus monitoring solution. These are very ephemeral addresses to scrape, but there's a network route from the scraper to my development box. I don't want to add my development box directly to the scrape list. I need a service discovery mechanism that's lightweight and temporary.

Plan

  • Organization runs a promdev_server which exposes:
    • /register/<namespace> -- for new scrape targets to heartbeat against
    • /discovery/<namespace> -- which is a HTTP_SD target added to the Prometheus config
  • Developer has options:
    • Runs promdev_reporter as a process (first goal)
      • It comes up and down with my development servers and simply heartbeats the static set of ports and /metrics endpoints up the chain
    • Integrates promdev_sd as a library (todo!)
      • The process itself, in development mode, heartbeats its own /metrics endpoint against the target promdev_server

Goal

  • Prometheus discovers the temporary development servers and scrapes them (with all appropriate tags).
  • Developer sees metrics show up in the organization's dashboards (Grafana, et al) tagged for themselves.
  • edit->build->run some local calls->see metrics->edit again, shut down for the day, start up again, your dashboard is there for you
  • Going to staging/prod? Then you'll have the same metrics endpoints scraped by the orchestrator via its service discovery (eg, Kubernetes)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	TimeoutPeriod: 2 * time.Minute,
	GCPeriod:      30 * time.Second,
}

Functions

func NewToken

func NewToken() string

Types

type Config

type Config struct {
	TimeoutPeriod time.Duration
	GCPeriod      time.Duration
}

type LabelSet

type LabelSet map[string]string

func (LabelSet) Clone

func (l LabelSet) Clone() LabelSet

func (LabelSet) Hash

func (l LabelSet) Hash() string

type Server

type Server struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewServer

func NewServer(config Config) (*Server, error)

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(hostport string) error

func (*Server) RunGCThread

func (s *Server) RunGCThread(ctx context.Context)

type Target

type Target struct {
	Target       string
	LabelSetHash string
	TouchedAt    time.Time
	Token        string
	Namespace    string
}

type TargetList

type TargetList []TargetSet

type TargetSet

type TargetSet struct {
	Targets []string `json:"targets"`
	Labels  LabelSet `json:"labels"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL