Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use UTF8 encoding for Grafana Agent config when installing on Windows #36

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading