github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/e2e/metrics/input/prometheus.nomad (about) 1 job "prometheus" { 2 datacenters = ["dc1", "dc2"] 3 type = "service" 4 5 constraint { 6 attribute = "${attr.kernel.name}" 7 value = "linux" 8 } 9 10 group "monitoring" { 11 count = 1 12 13 restart { 14 attempts = 2 15 interval = "30m" 16 delay = "15s" 17 mode = "fail" 18 } 19 20 ephemeral_disk { 21 size = 300 22 } 23 24 network { 25 port "prometheus_ui" { 26 to = 9090 27 } 28 } 29 30 task "prometheus" { 31 template { 32 change_mode = "noop" 33 destination = "local/prometheus.yml" 34 35 data = <<EOH 36 --- 37 global: 38 scrape_interval: 5s 39 evaluation_interval: 5s 40 41 scrape_configs: 42 43 - job_name: 'nomad_metrics' 44 45 consul_sd_configs: 46 - server: '{{ env "NOMAD_IP_prometheus_ui" }}:8500' 47 services: ['nomad-client', 'nomad'] 48 49 relabel_configs: 50 - source_labels: ['__meta_consul_tags'] 51 regex: '(.*)http(.*)' 52 action: keep 53 54 scrape_interval: 5s 55 metrics_path: /v1/metrics 56 params: 57 format: ['prometheus'] 58 EOH 59 } 60 61 driver = "docker" 62 63 config { 64 image = "prom/prometheus:latest" 65 66 volumes = [ 67 "local/prometheus.yml:/etc/prometheus/prometheus.yml", 68 ] 69 70 ports = ["prometheus_ui"] 71 } 72 73 service { 74 name = "prometheus" 75 tags = ["urlprefix-/"] 76 port = "prometheus_ui" 77 78 check { 79 name = "prometheus_ui port alive" 80 type = "http" 81 path = "/-/healthy" 82 interval = "10s" 83 timeout = "2s" 84 } 85 } 86 } 87 } 88 }