2022-03-03 17:37:49 +00:00
|
|
|
variable "consul_address" {
|
2022-04-13 21:01:14 +00:00
|
|
|
type = string
|
2022-03-03 17:37:49 +00:00
|
|
|
description = "address of consul server for dynamic scraping"
|
|
|
|
}
|
|
|
|
|
2022-03-12 18:07:52 +00:00
|
|
|
# resource "nomad_job" "exporters" {
|
|
|
|
# hcl2 {
|
|
|
|
# enabled = true
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
# jobspec = file("${path.module}/exporters.nomad")
|
|
|
|
# }
|
2022-03-03 17:37:49 +00:00
|
|
|
|
2022-03-13 17:13:19 +00:00
|
|
|
data "consul_nodes" "all-nodes" {
|
|
|
|
query_options {
|
|
|
|
datacenter = "dc1"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-03 17:37:49 +00:00
|
|
|
resource "nomad_job" "prometheus" {
|
|
|
|
hcl2 {
|
|
|
|
enabled = true
|
|
|
|
vars = {
|
2022-03-13 17:13:19 +00:00
|
|
|
# "consul_address" = "${var.consul_address}",
|
|
|
|
# TODO: Should this be a list?
|
|
|
|
"consul_address" = "http://${data.consul_nodes.all-nodes.nodes[0].address}:8500",
|
2022-03-03 17:37:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
jobspec = file("${path.module}/prometheus.nomad")
|
|
|
|
}
|
2022-03-12 18:07:52 +00:00
|
|
|
|
|
|
|
resource "nomad_job" "grafana" {
|
|
|
|
hcl2 {
|
|
|
|
enabled = true
|
|
|
|
}
|
|
|
|
|
2022-07-21 22:54:05 +00:00
|
|
|
jobspec = templatefile("${path.module}/grafana.nomad", {
|
|
|
|
module_path = "${path.module}"
|
|
|
|
})
|
2022-03-12 18:07:52 +00:00
|
|
|
}
|
2022-03-14 22:58:47 +00:00
|
|
|
|
|
|
|
resource "consul_config_entry" "prometheus_intent" {
|
|
|
|
name = "prometheus"
|
|
|
|
kind = "service-intentions"
|
|
|
|
|
|
|
|
config_json = jsonencode({
|
|
|
|
Sources = [
|
|
|
|
{
|
|
|
|
Action = "allow"
|
|
|
|
Name = "grafana"
|
|
|
|
Precedence = 9
|
|
|
|
Type = "consul"
|
|
|
|
},
|
|
|
|
]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
# resource "consul_config_entry" "envoy_prometheus_bind" {
|
|
|
|
# name = "global"
|
|
|
|
# kind = "proxy-defaults"
|
|
|
|
#
|
|
|
|
# config_json = jsonencode({
|
|
|
|
# "envoy_prometheus_bind_addr" = "0.0.0.0:9102"
|
|
|
|
# })
|
|
|
|
# }
|