From 7ccc47cc5151cf4b6a6846927cf1ebea10e98098 Mon Sep 17 00:00:00 2001 From: Giulio Vian Date: Wed, 16 Jan 2019 13:15:57 +0000 Subject: [PATCH] Added an example for textfile collector Added a practical example for textfile collector using a Powershell snippet that generates a valid file. --- docs/collector.textfile.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/collector.textfile.md b/docs/collector.textfile.md index a1b7d3e2..7c6aef69 100644 --- a/docs/collector.textfile.md +++ b/docs/collector.textfile.md @@ -36,3 +36,21 @@ _This collector does not yet have any useful queries added, we would appreciate ## Alerting examples _This collector does not yet have alerting examples, we would appreciate your help adding them!_ + +# Example use +This Powershell script, when run in the `collector.textfile.directory` (default `C:\Program Files\wmi_exporter\textfile_inputs`), generates a valid `.prom` file that should successfully ingested by wmi_exporter. + +```Powershell +$alpha = 42 +$beta = @{ left=3.1415; right=2.718281828; } + +Set-Content -Path test1.prom -Encoding Ascii -NoNewline -Value "" +Add-Content -Path test1.prom -Encoding Ascii -NoNewline -Value "# HELP test_alpha_total Some random metric.`n" +Add-Content -Path test1.prom -Encoding Ascii -NoNewline -Value "# TYPE test_alpha_total counter`n" +Add-Content -Path test1.prom -Encoding Ascii -NoNewline -Value "test_alpha_total ${alpha}`n" +Add-Content -Path test1.prom -Encoding Ascii -NoNewline -Value "# HELP test_beta_bytes Some other metric.`n" +Add-Content -Path test1.prom -Encoding Ascii -NoNewline -Value "# TYPE test_beta_bytes gauge`n" +foreach ($k in $beta.Keys) { + Add-Content -Path test1.prom -Encoding Ascii -NoNewline -Value "test_beta_bytes{spin=""${k}""} $( $beta[$k] )`n" +} +```