From 62d194a27c669e01bd0bea83df56cfd6731257a3 Mon Sep 17 00:00:00 2001 From: Luke Markie Date: Tue, 6 Feb 2024 08:47:11 +0000 Subject: [PATCH] Use UTF8 encoding for Grafana Agent config when installing on Windows --- windows/observability-agent-autoconf.ps1 | 42 ++++++++++++------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/windows/observability-agent-autoconf.ps1 b/windows/observability-agent-autoconf.ps1 index e3d2470..72ae724 100644 --- a/windows/observability-agent-autoconf.ps1 +++ b/windows/observability-agent-autoconf.ps1 @@ -110,7 +110,7 @@ logging { format = "logfmt" } -"@ | Out-File -FilePath $CONFIG +"@ | Out-File -FilePath $CONFIG -encoding utf8 Write-Output "Prometheus remote write component enabled" # Enable windows exporter component @@ -124,7 +124,7 @@ prometheus.scrape "windows" { forward_to = [prometheus.remote_write.default.receiver] } -"@ | Out-File -FilePath $CONFIG -Append +"@ | Out-File -FilePath $CONFIG -Append -encoding utf8 Write-Output "Windows exporter component enabled" # Enable log exporter component @@ -192,7 +192,7 @@ loki.write "lokiEndpoint" { } } -"@ | Out-File -FilePath $CONFIG -Append +"@ | Out-File -FilePath $CONFIG -Append -encoding utf8 break } elseif ($ans -eq "n") { break @@ -247,7 +247,7 @@ otelcol.exporter.otlphttp "traceEndpoint" { } } -"@ | Out-File -FilePath $CONFIG -Append +"@ | Out-File -FilePath $CONFIG -Append -encoding utf8 break } elseif ($ans -eq "n") { break @@ -319,7 +319,7 @@ targets = prometheus.exporter.mysql.example.targets forward_to = [prometheus.remote_write.default.receiver] } -"@ | Out-File -FilePath $CONFIG -Append +"@ | Out-File -FilePath $CONFIG -Append -encoding utf8 Write-Output "MySQL integration enabled" } @@ -384,7 +384,7 @@ targets = prometheus.exporter.mssql.example.targets forward_to = [prometheus.remote_write.default.receiver] } -"@ | Out-File -FilePath $CONFIG -Append +"@ | Out-File -FilePath $CONFIG -Append -encoding utf8 Write-Output "MSSQL integration enabled" } @@ -453,7 +453,7 @@ targets = prometheus.exporter.postgres.example.targets forward_to = [prometheus.remote_write.default.receiver] } -"@ | Out-File -FilePath $CONFIG -Append +"@ | Out-File -FilePath $CONFIG -Append -encoding utf8 Write-Output "Postgres integration enabled" } @@ -477,7 +477,7 @@ targets = [ forward_to = [prometheus.remote_write.default.receiver] } -"@ | Out-File -FilePath $CONFIG -Append +"@ | Out-File -FilePath $CONFIG -Append -encoding utf8 } else { @@ -491,7 +491,7 @@ targets = [ forward_to = [prometheus.remote_write.default.receiver] } -"@ | Out-File -FilePath $CONFIG -Append +"@ | Out-File -FilePath $CONFIG -Append -encoding utf8 Write-Output "RabbitMQ scrape endpoint added" } } @@ -518,7 +518,7 @@ targets = prometheus.exporter.redis.example.targets forward_to = [prometheus.remote_write.default.receiver] } -"@ | Out-File -FilePath $CONFIG -Append +"@ | Out-File -FilePath $CONFIG -Append -encoding utf8 Write-Output "Redis integration enabled" } @@ -544,7 +544,7 @@ targets = prometheus.exporter.kafka.example.targets forward_to = [prometheus.remote_write.default.receiver] } -"@ | Out-File -FilePath $CONFIG -Append +"@ | Out-File -FilePath $CONFIG -Append -encoding utf8 Write-Output "Kafka integration enabled" } @@ -609,7 +609,7 @@ targets = prometheus.exporter.elasticsearch.example.targets forward_to = [prometheus.remote_write.default.receiver] } -"@ | Out-File -FilePath $CONFIG -Append +"@ | Out-File -FilePath $CONFIG -Append -encoding utf8 Write-Output "Elasticsearch integration enabled" } @@ -674,7 +674,7 @@ targets = prometheus.exporter.mongodb.example.targets forward_to = [prometheus.remote_write.default.receiver] } -"@ | Out-File -FilePath $CONFIG -Append +"@ | Out-File -FilePath $CONFIG -Append -encoding utf8 Write-Output "MongoDB integration enabled" } @@ -738,7 +738,7 @@ targets = prometheus.exporter.oracledb.example.targets forward_to = [prometheus.remote_write.default.receiver] } -"@ | Out-File -FilePath $CONFIG -Append +"@ | Out-File -FilePath $CONFIG -Append -encoding utf8 Write-Output "OracleDB integration enabled" } @@ -748,21 +748,21 @@ if ($env:scrape_targets) { @" prometheus.scrape "endpoints" { targets = [ -"@ | Out-File -FilePath $CONFIG -Append +"@ | Out-File -FilePath $CONFIG -Append -encoding utf8 # Add the jobs and targets to the config for ($i=0; $i -lt $scrapeTargets.Length; $i++) { # Add the endpoint to the config @" {"__address__" = "${scrapeTargets[i]}"}, -"@ | Out-File -FilePath $CONFIG -Append +"@ | Out-File -FilePath $CONFIG -Append -encoding utf8 } @" ] forward_to = [prometheus.remote_write.default.receiver] } -"@ | Out-File -FilePath $CONFIG -Append +"@ | Out-File -FilePath $CONFIG -Append -encoding utf8 Write-Host "Scrape endpoints added" } @@ -771,7 +771,7 @@ while ($true) @" prometheus.scrape "endpoints" { targets = [ -"@ | Out-File -FilePath $CONFIG -Append +"@ | Out-File -FilePath $CONFIG -Append -encoding utf8 $ans = Read-Host "Is there an additional endpoint you would like to scrape? (y/n)" | ForEach-Object { $_.ToLower() } if ($ans -eq "y") { @@ -786,7 +786,7 @@ prometheus.scrape "endpoints" { # Add the endpoint to the config @" {"__address__" = "$endpointTarget"}, -"@ | Out-File -FilePath $CONFIG -Append +"@ | Out-File -FilePath $CONFIG -Append -encoding utf8 } } elseif ($ans -eq "n") { @" @@ -794,7 +794,7 @@ prometheus.scrape "endpoints" { forward_to = [prometheus.remote_write.default.receiver] } -"@ | Out-File -FilePath $CONFIG -Append +"@ | Out-File -FilePath $CONFIG -Append -encoding utf8 break } else { Write-Output "Invalid input. Please enter y or n." @@ -804,7 +804,7 @@ prometheus.scrape "endpoints" { forward_to = [prometheus.remote_write.default.receiver] } -"@ | Out-File -FilePath $CONFIG -Append +"@ | Out-File -FilePath $CONFIG -Append -encoding utf8 break } Write-Output "Config file updated"