Skip to content

spencershepard/Prometheus-HTTP-Push-SD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prometheus HTTP PUSH SD (Service Discovery)

This is a simple HTTP server that you can use to push targets to Prometheus. We can use this to dynamically update prometheus targets without knowing the targets in advance.

/update

Send a POST request to /update with a JSON body containing a single target to add.

{
    "name": "test",
    "mac": "0a:0a:0a:0a:0a:0a",
    "address": "123.45.67.240",
    "labels": {
        "__meta_prometheus_job": "barcode_readers",
        
    }
}

The MAC field can be an arbitrary ID to identify the target.

/targets

This is the endpoint for Prometheus http_sd_config. It will return a list of targets in the format that Prometheus expects.

Setup

Create Docker Container:

docker run -d -p 8000:8000 -e MAX_AGE=300 -e BASIC_AUTH_USER=user -e BASIC_AUTH_PASS=password --name prometheus-http-push-sd spencershepard/prometheus-http-push-sd

Update prometheus.yml

scrape_configs:
  - job_name: 'pushed_scrapes'
    http_sd_configs:
    - url: http://ipaddress:8000/targets
      basic_auth:
          username: username
          password: password

Environment Variables

  • 'MAX_AGE' - The maximum age of a target in seconds.
  • 'BASIC_AUTH_USER' - The basic auth username to use.
  • 'BASIC_AUTH_PASSWORD' - The basic auth password to use.

About

Let services add themselves as Prometheus scrape targets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages