Skip to content

Commit

Permalink
Use UTF8 encoding for Grafana Agent config when installing on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
LMarkie committed Feb 6, 2024
1 parent 709123c commit 62d194a
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions windows/observability-agent-autoconf.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
}

Expand Down Expand Up @@ -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"
}

Expand Down Expand Up @@ -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"
}

Expand All @@ -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
{
Expand All @@ -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"
}
}
Expand All @@ -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"
}

Expand All @@ -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"
}

Expand Down Expand Up @@ -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"
}

Expand Down Expand Up @@ -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"
}

Expand Down Expand Up @@ -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"
}

Expand All @@ -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"
}

Expand All @@ -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") {
Expand All @@ -786,15 +786,15 @@ 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") {
@"
]
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."
Expand All @@ -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"
Expand Down

0 comments on commit 62d194a

Please sign in to comment.