Skip to content

Instantly share code, notes, and snippets.

@aruaam
Last active October 28, 2023 10:38
Show Gist options
  • Save aruaam/f1ae9017c128b914ccaec0ac335332d7 to your computer and use it in GitHub Desktop.
Save aruaam/f1ae9017c128b914ccaec0ac335332d7 to your computer and use it in GitHub Desktop.
How to configure the Grafana Flow agent on a Windows host with remote path storage
logging {
level = "info"
}
discovery.http "path_targets" {
url = "target_url_to_get_log_paths"
}
discovery.relabel "paths" {
targets = discovery.http.path_targets.targets
// Relabel for local.file_match component
rule {
source_labels = ["__address__"]
target_label = "__path__"
action = "replace"
}
// Drop unneeded labels
rule {
regex = "__meta_url"
action = "labeldrop"
}
rule {
regex = "__address__"
action = "labeldrop"
}
}
local.file_match "logs" {
path_targets = discovery.relabel.paths.output
}
loki.source.file "files" {
targets = local.file_match.logs.targets
forward_to = [loki.write.loki.receiver]
}
loki.write "loki" {
endpoint {
url = "http://loki_server:3100/loki/api/v1/push"
}
}
/* JSON response which should be returned to discovery.http component
[
{
"targets": [
"C:/folder_1/logs/*.log",
"C:/folder_2/logs/app_1/main/*.log",
"D:/folder_3/*.log"
]
}
]
*/
@aruaam
Copy link
Author

aruaam commented Oct 28, 2023

Took me a while to figure out this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment