Skip to content

Commit

Permalink
Merge pull request #36 from intergral/windows-config-encoding
Browse files Browse the repository at this point in the history
Use UTF8 encoding for Grafana Agent config when installing on Windows
  • Loading branch information
ibalal-intergral authored Feb 12, 2024
2 parents 2947640 + 62d194a commit 3a3b770
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 Down Expand Up @@ -489,7 +489,7 @@ targets = [
forward_to = [prometheus.remote_write.default.receiver]
}
"@ | Out-File -FilePath $CONFIG -Append
"@ | Out-File -FilePath $CONFIG -Append -encoding utf8
}
else
{
Expand All @@ -503,7 +503,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 @@ -530,7 +530,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 @@ -556,7 +556,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 @@ -621,7 +621,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 @@ -686,7 +686,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 @@ -750,7 +750,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 @@ -760,21 +760,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 @@ -783,7 +783,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 @@ -798,15 +798,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 @@ -816,7 +816,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 3a3b770

Please sign in to comment.