Skip to content

Commit 004639a

Browse files
committed
Add prometheus endpoint in infra
1 parent 093a3ef commit 004639a

File tree

7 files changed

+41
-51
lines changed

7 files changed

+41
-51
lines changed

mithril-infra/assets/docker/docker-compose-monitoring.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ services:
1212
command:
1313
- --config.file=/etc/prometheus/prometheus.yml
1414
volumes:
15-
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
15+
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
16+
labels:
17+
- 'traefik.enable=true'
18+
- 'traefik.http.routers.prometheus.rule=Host(`${PROMETHEUS_HOST}`)'
19+
- 'traefik.http.routers.prometheus.tls=true'
20+
- 'traefik.http.routers.prometheus.tls.certresolver=lets-encrypt'
1621

1722
promtail:
1823
image: grafana/promtail:1.4.1
@@ -22,7 +27,7 @@ services:
2227
- all
2328
volumes:
2429
- /var/lib/docker/containers:/var/lib/docker/containers
25-
- ./promtail-config.yml:/etc/promtail/promtail-config.yml
30+
- ./promtail/promtail-config.yml:/etc/promtail/promtail-config.yml
2631
command: -config.file=/etc/promtail/promtail-config.yml
2732

2833
networks:

mithril-infra/assets/docker/prometheus.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
global:
2+
scrape_interval: 15s
3+
evaluation_interval: 15s
4+
5+
rule_files:
6+
# - "first_rules.yml"
7+
# - "second_rules.yml"
8+
9+
scrape_configs:
10+
- job_name: 'prometheus'
11+
static_configs:
12+
- targets: ['prometheus:9090']
13+
14+
- job_name: 'reverse-proxy'
15+
static_configs:
16+
- targets: ['reverse-proxy:8680']
17+
File renamed without changes.

mithril-infra/main.dns.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ resource "google_dns_record_set" "mithril-signer-endpoint" {
2323
rrdatas = [google_compute_address.mithril-external-address.address]
2424
}
2525

26+
resource "google_dns_record_set" "prometheus-endpoint" {
27+
name = "prometheus.${google_dns_managed_zone.mithril-api-zone.dns_name}"
28+
managed_zone = google_dns_managed_zone.mithril-api-zone.name
29+
type = "A"
30+
ttl = 300
31+
rrdatas = [google_compute_address.mithril-external-address.address]
32+
}
33+
2634
locals {
2735
mithril_aggregator_host = trimsuffix(google_dns_record_set.mithril-aggregator-endpoint.name, ".")
2836
mithril_aggregator_endpoint_url = format("https://%s%s/aggregator", local.mithril_aggregator_credentials, local.mithril_aggregator_host)
@@ -33,4 +41,7 @@ locals {
3341
mithril_signers_endpoint_url = [for key, signer in var.mithril_signers :
3442
format("https://%s", "mithril-signer-${key}.${trimsuffix(google_dns_managed_zone.mithril-api-zone.dns_name, ".")}")
3543
]
44+
prometheus_host = trimsuffix(google_dns_record_set.prometheus-endpoint.name, ".")
45+
prometheus_endpoint_url = format("https://%s", "prometheus.${trimsuffix(google_dns_managed_zone.mithril-api-zone.dns_name, ".")}")
46+
3647
}

mithril-infra/mithril.monitoring.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ resource "null_resource" "mithril_monitoring" {
55
]
66

77
triggers = {
8+
image_id = var.mithril_image_id,
89
vm_instance = google_compute_instance.vm_instance.id
910
}
1011

@@ -17,6 +18,7 @@ resource "null_resource" "mithril_monitoring" {
1718

1819
provisioner "remote-exec" {
1920
inline = [
21+
"export PROMETHEUS_HOST=${local.prometheus_host}",
2022
"docker-compose -f /home/curry/docker/docker-compose-monitoring.yaml --profile all up -d",
2123
]
2224
}

mithril-infra/output.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ output "mithril_signers_endpoint_url" {
1010
value = local.mithril_signers_endpoint_url
1111
}
1212

13+
output "prometheus_endpoint_url" {
14+
value = local.prometheus_endpoint_url
15+
}
16+
1317
output "storage_bucket" {
1418
value = google_storage_bucket.cloud_storage.name
1519
}

0 commit comments

Comments
 (0)