# Monitoring Architecture **Stack:** Prometheus + Grafana + Loki + Tempo + Alertmanager + OpenTelemetry Collector **Cluster:** single-node MicroK8s on `art0` **Namespaces:** - `fetcherpay` — app workloads and custom Prometheus/blackbox/MySQL/Redis exporters - `observability` — kube-prometheus-stack (Grafana, K8s Prometheus, Loki, Tempo, Alertmanager, node-exporter, kube-state-metrics) --- ## Data flow ``` Applications / Websites / Host │ ├──► Blackbox exporter ──► FetcherPay Prometheus ├──► MySQL exporter ─────► FetcherPay Prometheus ├──► Redis exporter ─────► FetcherPay Prometheus ├──► OTel Collector ─────► FetcherPay Prometheus (remote write) │ │ │ ├── metrics dashboards │ └── Alertmanager rules │ ├──► OTel Collector ─────► Tempo (traces) └──► OTel Collector ─────► Loki (logs) Kube-prometheus-stack (observability namespace) │ ├──► K8s Prometheus ─────► Grafana + Alertmanager ├──► node-exporter ─────► K8s Prometheus └──► kube-state-metrics ─► K8s Prometheus ``` --- ## What is monitored where ### FetcherPay Prometheus (`prometheus.fetcherpay:9090`) | Job | Source | Metrics | |-----|--------|---------| | `prometheus` | itself | Prometheus health / remote-write stats | | `blackbox-http` | 18 HTTPS endpoints | `probe_success`, `probe_duration_seconds`, SSL expiry | | `mysql` | host MySQL via `mysql-exporter:9104` | `mysql_*` connections, queries, replication | | `redis` | Redis via `redis-exporter:9121` | `redis_*` memory, clients, hit ratio | | `node-exporter` | K8s node-exporter | CPU / memory / disk / network (duplicates K8s prom) | | `kube-state-metrics` | K8s kube-state-metrics | cluster-level pod/deployment/service state | | `otel-collector` | OTel collector self-metrics | `otelcol_*` exporter throughput, queue size | ### K8s Observability Prometheus (`kube-prom-stack-kube-prome-prometheus.observability:9090`) | Job | Source | Metrics | |-----|--------|---------| | `kubernetes-apiservers` | API server | K8s control plane | | `kubernetes-cAdvisor` | kubelet | container resource usage | | `kubernetes-nodes` | kubelet | node metrics | | `kubernetes-pods` | pod service discovery | any pod with prometheus.io annotations | | `kube-state-metrics` | kube-state-metrics | object state | | `node-exporter` | node-exporter | hardware/OS metrics | ### Loki (`loki.observability:3100`) - Receives logs via OTel Collector `otlp_http/loki` exporter. - Labels: `cluster`, `job`, `namespace`, `pod`, `container` (when available). ### Tempo (`tempo.observability:4317` gRPC, `3100` HTTP) - Receives traces via OTel Collector `otlp_grpc/tempo` exporter. - Supports Jaeger/Zipkin/OTLP receivers on the collector. --- ## Kubernetes manifests All manifests live in `hermes-mcp/monitoring/`: | File | Deploys | |------|---------| | `opentelemetry-collector.yaml` | OTel collector Deployment/ConfigMap/Service in `observability` | | `prometheus-deployment.yaml` | FetcherPay Prometheus Deployment in `fetcherpay` | | `prometheus-config.yaml` | ConfigMap mounted into FetcherPay Prometheus | | `blackbox-exporter.yaml` | Blackbox exporter in `fetcherpay` | | `mysql-exporter.yaml` | MySQL exporter (hostNetwork) in `fetcherpay` | | `redis-exporter.yaml` | Redis exporter in `fetcherpay` | | `grafana-deployment.yaml` | Custom Grafana with SMTP env vars | | `alertmanager-config.yaml` | Alertmanager config (email + Slack) | --- ## Networking and ports | Service | Namespace | Ports | Notes | |---------|-----------|-------|-------| | `prometheus` | `fetcherpay` | 9090 | ClusterIP; remote-write enabled | | `blackbox-exporter` | `fetcherpay` | 9115 | ClusterIP | | `mysql-exporter` | `fetcherpay` | 9104 | ClusterIP; uses `hostNetwork: true` to reach host MySQL | | `redis-exporter` | `fetcherpay` | 9121 | ClusterIP | | `otel-collector` | `observability` | 4317, 4318, 14250, 14268, 9411, 8888 | OTLP/Jaeger/Zipkin/metrics | | `kube-prom-stack-grafana` | `observability` | 3000 | ClusterIP; exposed via ingress | | `kube-prom-stack-kube-prome-prometheus` | `observability` | 9090 | ClusterIP | | `loki` | `observability` | 3100 | ClusterIP | | `tempo` | `observability` | 3100, 4317 | ClusterIP | | `nginx-ingress-microk8s` | `ingress` | 80, 443, 10254 | `hostNetwork: true` edge router | --- ## Notes for AI agents - FetcherPay Prometheus is the source of truth for custom app/site/infrastructure health. - K8s Prometheus is the source of truth for cluster/node/container metrics. - Grafana dashboards can pull from both; the health overview dashboard uses both. - Loki/Tempo are fed by the OTel collector, not directly by apps. - The `kubelet` TLS cert on `art0` does not include `104.190.60.129`, so `kubectl exec`, `port-forward`, and `logs` may fail. Use `--insecure-skip-tls-verify-backend=true` for logs, or `kubectl proxy` for HTTP health checks.