From 2482a2f819012546d08b03e68bc1a6330b825b5b Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Thu, 1 Dec 2022 23:48:46 +0100 Subject: [PATCH] staging: run prometheus from nixpkgs --- .../app/telemetry/config/prometheus.yml | 12 ++++---- .../app/telemetry/deploy/telemetry.hcl | 30 ++++++++----------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/cluster/staging/app/telemetry/config/prometheus.yml b/cluster/staging/app/telemetry/config/prometheus.yml index e0e786d..0203ca4 100644 --- a/cluster/staging/app/telemetry/config/prometheus.yml +++ b/cluster/staging/app/telemetry/config/prometheus.yml @@ -12,9 +12,9 @@ scrape_configs: services: - 'node-exporter' tls_config: - ca_file: /etc/prometheus/consul.crt - cert_file: /etc/prometheus/consul-client.crt - key_file: /etc/prometheus/consul-client.key + ca_file: /etc/prom/consul.crt + cert_file: /etc/prom/consul-client.crt + key_file: /etc/prom/consul-client.key - job_name: 'garage' authorization: @@ -25,6 +25,6 @@ scrape_configs: services: - 'garage-staging-admin' tls_config: - ca_file: /etc/prometheus/consul.crt - cert_file: /etc/prometheus/consul-client.crt - key_file: /etc/prometheus/consul-client.key + ca_file: /etc/prom/consul.crt + cert_file: /etc/prom/consul-client.crt + key_file: /etc/prom/consul-client.key diff --git a/cluster/staging/app/telemetry/deploy/telemetry.hcl b/cluster/staging/app/telemetry/deploy/telemetry.hcl index 84a15db..f4f4013 100644 --- a/cluster/staging/app/telemetry/deploy/telemetry.hcl +++ b/cluster/staging/app/telemetry/deploy/telemetry.hcl @@ -18,40 +18,39 @@ job "telemetry" { } task "prometheus" { - driver = "docker" + driver = "nix2" config { - image = "prom/prometheus:v2.39.0" - network_mode = "host" - ports = [ "prometheus" ] + nixpkgs = "github:nixos/nixpkgs/nixos-22.11" + packages = [ "#prometheus", "#coreutils", "#findutils", "#bash" ] + command = "prometheus" args = [ - "--config.file=/etc/prometheus/prometheus.yml", + "--config.file=/etc/prom/prometheus.yml", "--storage.tsdb.path=/data", "--storage.tsdb.retention.size=5GB", ] - volumes = [ - "secrets:/etc/prometheus", - "/mnt/ssd/prometheus:/data" - ] + bind = { + "/mnt/ssd/prometheus" = "/data" + } } template { data = file("../config/prometheus.yml") - destination = "secrets/prometheus.yml" + destination = "etc/prom/prometheus.yml" } template { data = "{{ key \"secrets/consul/consul.crt\" }}" - destination = "secrets/consul.crt" + destination = "etc/prom/consul.crt" } template { data = "{{ key \"secrets/consul/consul-client.crt\" }}" - destination = "secrets/consul-client.crt" + destination = "etc/prom/consul-client.crt" } template { data = "{{ key \"secrets/consul/consul-client.key\" }}" - destination = "secrets/consul-client.key" + destination = "etc/prom/consul-client.key" } resources { @@ -60,14 +59,11 @@ job "telemetry" { } service { - port = 9090 - address_mode = "driver" + port = "prometheus" name = "prometheus" check { type = "http" path = "/" - port = 9090 - address_mode = "driver" interval = "60s" timeout = "5s" check_restart {