refactor(observability): drop file-SD writer for http_sd_configs
Slice 4 of observability-service-registry. Removes the shared-file Prometheus bridge; external Prometheus now consumes node-exporter targets via http_sd_configs against GET /api/monitoring/prometheus-targets. - services/targets.py: removed write_prometheus_targets() (the file writer) and its json/Path/get_settings imports; updated module docstring. build_node_exporter_targets() is unchanged and still powers the HTTP endpoint. - main.py: removed the startup write_prometheus_targets call. - routers/settings.py: removed the _write_prometheus_targets helper and its three post machine create/update/delete call sites + the now-unused targets import. - config.py: removed the prometheus_file_sd_dir field. - docker-compose.yml / docker-compose.dev.yml: removed the PROMETHEUS_FILE_SD_DIR backend env var. - tests: removed TestWritePrometheusTargets + the write_prometheus_targets import in test_targets.py; rewrote the two TestSettingsMachines tests to assert machines appear/disappear from /api/monitoring/prometheus-targets (the surviving HTTP path) instead of the removed file-writer side effect. ruff clean; 239 backend tests pass.
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
"""Tests for Prometheus file-based service discovery target generation."""
|
||||
"""Tests for Prometheus Node Exporter target discovery."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from media_library_viewer_api.services.settings_store import SettingsStore
|
||||
from media_library_viewer_api.services.targets import (
|
||||
build_node_exporter_targets,
|
||||
write_prometheus_targets,
|
||||
)
|
||||
from media_library_viewer_api.services.targets import build_node_exporter_targets
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -88,22 +85,3 @@ class TestBuildNodeExporterTargets:
|
||||
}
|
||||
)
|
||||
assert build_node_exporter_targets(store) == []
|
||||
|
||||
|
||||
class TestWritePrometheusTargets:
|
||||
def test_writes_valid_json(self, store: SettingsStore, tmp_path: Path):
|
||||
store.upsert_machine(
|
||||
{
|
||||
"name": "remote1",
|
||||
"mode": "ssh",
|
||||
"host": "10.0.0.5",
|
||||
"username": "u",
|
||||
"node_exporter_enabled": True,
|
||||
"node_exporter_port": 9200,
|
||||
}
|
||||
)
|
||||
file_path = write_prometheus_targets(store, tmp_path)
|
||||
assert file_path.exists()
|
||||
assert file_path.name == "node_exporter_targets.json"
|
||||
targets = build_node_exporter_targets(store)
|
||||
assert len(targets) == 1
|
||||
|
||||
Reference in New Issue
Block a user