prometheus-http-sd

command module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

README

prometheus-http-sd

Prometheus service discovery using with HTTP API and file_sd_config.

Install

Precompiled binaries

Download from https://github.com/rrreeeyyy/prometheus-http-sd

Docker
docker pull rrreeeyyy/prometheus-http-sd

Usage

  • Run a single API endpoint

    ./prometheus-http-sd --api.url="http://api.example.com/service_discovery.json" --output.file=/path/to/http_sd.json --refresh.interval=60
    
  • Run multiple API endpoints

    ./prometheus-http-sd --api.url="http://api.example.com/foo_service_discovery.json" --output.file=/path/to/http_foo_sd.json --api.url="http://api.example.com/bar_service_discovery.json" --output.file=/path/to/http_bar_sd.json --refresh.interval=60
    

HTTP API format

HTTP API response should be follow prometheus file_sd_config format like below:

[
	{
		"targets": [
			"192.0.2.1:8080",
			"192.0.2.2:8080",
		],
		"labels": {
			"service": "web",
			"role": "role-1"
		}
	},
	{
		"targets": [
			"192.0.3.1:3306"
		],
		"labels": {
			"service": "db",
			"role": "role-2"
		}
	}
]

Example prometheus settings

The part of your prometheus.yml is probably as follows.

  scrape_configs:
    - job_name: 'http_sd'
      file_sd_configs:
        - files:
          - /path/to/http_sd.json

Metrics

  • prometheus_sd_http_http_requests_total
    • labels
      • api_url: target API URL
      • code: http response code

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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