consul-sd-cloudrun

module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: Apache-2.0

README

Consul Service Discovery for Cloud Run

build Go Reference Go Report Card

A Consul discovery agent that enumerates Cloud Run services and registers them with Consul.

Run

Run Consul, Prometheus and cAdvisor:

docker-compose up

Then:

# Use user's default account
export GOOGLE_APPLICATION_CREDENTIALS="${HOME}/.config/gcloud/application_default_credentials.json"

# Convert list of Projects into comma-separated list
# Includes trailing comma
PROJECTS=$(\
  gcloud projects list \
  --format='csv[terminator=","](projectId)') \
&& echo ${PROJECTS}

go run ./cmd \
--project_ids=${PROJECTS}

Consul

http://localhost:8500/ui/dc1/services

Debugging

Deregister services:

ID=...

curl \
--request PUT \
localhost:8500/v1/agent/service/deregister/${ID}

Relabeling

relabeling

Notes

The consul service that is registered (by default) with the Consul agent expects to be scraped as /v1/agent/metrics but this disagrees with the metrics endpoints of the Cloud Run services.

consul service

Want to exclude the consul service.

Using relabel_config to drop the consul service:

relabel_configs:
- source_labels:
  - __meta_consul_service_port
  regex: "8300"
  action: drop

Here's the Prometheus configuration that scrapes the consul service if you decide you want it:

scrape_configs:
  # Consul
  - job_name: consul
    metrics_path: "/v1/agent/metrics"
    params:
      format:
        - "prometheus"
    consul_sd_configs:
      - server: consul:8500
        datacenter: dc1

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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