diff --git a/bootstrap/platform/main.tf b/bootstrap/platform/main.tf index 379c432..9d8e79d 100644 --- a/bootstrap/platform/main.tf +++ b/bootstrap/platform/main.tf @@ -1965,7 +1965,7 @@ resource "helm_release" "prometheus_stack" { prometheusSpec = { nodeSelector = local.prometheus_stack_node_selector retention = var.observability.prometheus.retention - additionalScrapeConfigs = yamlencode([ + additionalScrapeConfigs = yamlencode(concat([ { job_name = "rpi-node" static_configs = [ @@ -2042,7 +2042,21 @@ resource "helm_release" "prometheus_stack" { } ] } - ]) + ], var.jeannie_api_metrics_token == "" ? [] : [{ + job_name = "jeannie-api" + metrics_path = "/metrics" + scheme = "https" + static_configs = [{ + targets = [var.jeannie_api_metrics_target] + labels = { + host_group = "automation" + } + }] + authorization = { + type = "Bearer" + credentials = var.jeannie_api_metrics_token + } + }])) resources = { requests = { cpu = "100m" diff --git a/bootstrap/platform/variables.tf b/bootstrap/platform/variables.tf index f65b659..a6e097f 100644 --- a/bootstrap/platform/variables.tf +++ b/bootstrap/platform/variables.tf @@ -254,6 +254,19 @@ variable "jeannie_self_heal_endpoint" { default = "192.168.100.73:18081" } +variable "jeannie_api_metrics_target" { + description = "Host:port scraped by the in-cluster Prometheus for the Debian-hosted Jeannie API metrics endpoint." + type = string + default = "api.lab2025.duckdns.org:443" +} + +variable "jeannie_api_metrics_token" { + description = "Bearer token used by Prometheus to scrape the authenticated Jeannie API metrics endpoint." + type = string + sensitive = true + default = "" +} + variable "prometheus_stack_node_selector" { description = "Node selector applied to kube-prometheus-stack control workloads so they stay off the control plane." type = map(string) diff --git a/docs/jeannie-remote-api.md b/docs/jeannie-remote-api.md index f372e6d..6a7f5c7 100644 --- a/docs/jeannie-remote-api.md +++ b/docs/jeannie-remote-api.md @@ -29,6 +29,8 @@ The authenticated `GET /metrics` endpoint exposes Prometheus-compatible HTTP request counters, request duration totals, and authentication-failure counts. It is served by the Debian API process, so metrics remain available while Kubernetes is stopped; Prometheus may scrape it when the cluster is healthy. +Run the platform pipeline with `JEANNIE_SERVER_TOKEN` set to enable the +authenticated `jeannie-api` scrape job in kube-prometheus-stack. ## Edge API gateway diff --git a/lib/jeannie/env.sh b/lib/jeannie/env.sh index 9e50a75..8a36082 100644 --- a/lib/jeannie/env.sh +++ b/lib/jeannie/env.sh @@ -266,6 +266,8 @@ export_homelab_inventory_tf_vars() { export_if_unset TF_VAR_edge_install_dir "${LAB_EDGE_INSTALL_DIR:-}" export_if_unset TF_VAR_server_name "${LAB_DOMAIN:-}" export_if_unset TF_VAR_additional_server_names "${LAB_ADDITIONAL_SERVER_NAMES_JSON:-}" + export_if_unset TF_VAR_jeannie_api_metrics_target "${LAB_JEANNIE_API_METRICS_TARGET:-api.${LAB_DOMAIN:-lab2025.duckdns.org}:443}" + export_if_unset TF_VAR_jeannie_api_metrics_token "${JEANNIE_SERVER_TOKEN:-${JEANNIE_REMOTE_TOKEN:-}}" export_if_unset TF_VAR_backend_host "${LAB_TRAEFIK_LB_IP:-}" export_if_unset TF_VAR_gitea_backend_host "${LAB_GITEA_BACKEND_HOST:-${LAB_DEBIAN_TAILSCALE_IP:-}}" export_if_unset TF_VAR_gitea_backend_port "${LAB_GITEA_HTTP_PORT:-}" diff --git a/lib/jeannie/pipeline.sh b/lib/jeannie/pipeline.sh index b8dc4a0..344e31a 100644 --- a/lib/jeannie/pipeline.sh +++ b/lib/jeannie/pipeline.sh @@ -227,6 +227,8 @@ export_homelab_inventory_tf_vars() { export_if_unset TF_VAR_edge_install_dir "${LAB_EDGE_INSTALL_DIR:-}" export_if_unset TF_VAR_server_name "${LAB_DOMAIN:-}" export_if_unset TF_VAR_additional_server_names "${LAB_ADDITIONAL_SERVER_NAMES_JSON:-}" + export_if_unset TF_VAR_jeannie_api_metrics_target "${LAB_JEANNIE_API_METRICS_TARGET:-api.${LAB_DOMAIN:-lab2025.duckdns.org}:443}" + export_if_unset TF_VAR_jeannie_api_metrics_token "${JEANNIE_SERVER_TOKEN:-${JEANNIE_REMOTE_TOKEN:-}}" export_if_unset TF_VAR_backend_host "${LAB_TRAEFIK_LB_IP:-}" export_if_unset TF_VAR_gitea_backend_host "${LAB_DEBIAN_TAILSCALE_IP:-}" export_if_unset TF_VAR_gitea_backend_port "${LAB_GITEA_HTTP_PORT:-}"