From 433e00a20bc712dbfa618d7e5815b3c1c936fdd1 Mon Sep 17 00:00:00 2001 From: Ben Reedy Date: Wed, 2 Dec 2020 15:10:49 +1000 Subject: [PATCH] Add CI support for textfile collector Signed-off-by: Ben Reedy --- tools/e2e-output.txt | 5 +++++ tools/e2e-textfile.prom | 4 ++++ tools/end-to-end-test.ps1 | 9 +++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 tools/e2e-textfile.prom diff --git a/tools/e2e-output.txt b/tools/e2e-output.txt index 3786c718..6deae597 100644 --- a/tools/e2e-output.txt +++ b/tools/e2e-output.txt @@ -66,6 +66,9 @@ # TYPE process_start_time_seconds gauge # HELP process_virtual_memory_bytes Virtual memory size in bytes. # TYPE process_virtual_memory_bytes gauge +# HELP test_alpha_total Some random metric. +# TYPE test_alpha_total counter +test_alpha_total 42 # HELP windows_cpu_clock_interrupts_total Total number of received and serviced clock tick interrupts # TYPE windows_cpu_clock_interrupts_total counter # HELP windows_cpu_core_frequency_mhz Core frequency in megahertz @@ -214,6 +217,8 @@ windows_exporter_collector_timeout{collector="textfile"} 0 # TYPE windows_system_system_up_time gauge # HELP windows_system_threads Current number of threads (WMI source: PerfOS_System.Threads) # TYPE windows_system_threads gauge +# HELP windows_textfile_mtime_seconds Unixtime mtime of textfiles successfully read. +# TYPE windows_textfile_mtime_seconds gauge # HELP windows_textfile_scrape_error 1 if there was an error opening or reading a file, 0 otherwise # TYPE windows_textfile_scrape_error gauge windows_textfile_scrape_error 0 diff --git a/tools/e2e-textfile.prom b/tools/e2e-textfile.prom new file mode 100644 index 00000000..2231d6d9 --- /dev/null +++ b/tools/e2e-textfile.prom @@ -0,0 +1,4 @@ +# HELP test_alpha_total Some random metric. +# TYPE test_alpha_total counter +test_alpha_total 42 + diff --git a/tools/end-to-end-test.ps1 b/tools/end-to-end-test.ps1 index fba9ce74..54b390d8 100644 --- a/tools/end-to-end-test.ps1 +++ b/tools/end-to-end-test.ps1 @@ -12,15 +12,20 @@ Push-Location $working_dir $temp_dir = Join-Path $env:TEMP $(New-Guid) | ForEach-Object { mkdir $_ } +# Create temporary directory for textfile collector +$textfile_dir = "$($temp_dir)/textfile" +mkdir $textfile_dir | Out-Null +Copy-Item 'e2e-textfile.prom' -Destination "$($textfile_dir)/e2e-textfile.prom" + # Omit dynamic collector information that will change after each run -$skip_re = "^(go_|windows_exporter_build_info|windows_exporter_collector_duration_seconds|windows_exporter_perflib_snapshot_duration_seconds|process_|windows_textfile_mtime_seconds|windows_cpu|windows_cs|windows_logical_disk|windows_net|windows_os|windows_service|windows_system)" +$skip_re = "^(go_|windows_exporter_build_info|windows_exporter_collector_duration_seconds|windows_exporter_perflib_snapshot_duration_seconds|process_|windows_textfile_mtime_seconds|windows_cpu|windows_cs|windows_logical_disk|windows_net|windows_os|windows_service|windows_system|windows_textfile_mtime_seconds)" # Start process in background, awaiting HTTP requests. # Use default collectors, port and address: http://localhost:9182/metrics $exporter_proc = Start-Process ` -PassThru ` -FilePath .\windows_exporter.exe ` - -ArgumentList '--log.level=debug' ` + -ArgumentList "--log.level=debug --collector.textfile.directory=$($textfile_dir)" ` -WindowStyle Hidden ` -RedirectStandardOutput "$($temp_dir)/windows_exporter.log" ` -RedirectStandardError "$($temp_dir)/windows_exporter_error.log"