Skip to content

Commit

Permalink
feat: use alloy meta logs as logging example
Browse files Browse the repository at this point in the history
  • Loading branch information
sunng87 committed Nov 25, 2024
1 parent 61718db commit caa7741
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions grafana-alloy/config.alloy.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ otelcol.exporter.otlphttp "greptimedb_logs" {
endpoint = "${GREPTIME_SCHEME:=http}://${GREPTIME_HOST:=greptimedb}:${GREPTIME_PORT:=4000}/v1/otlp/"
headers = {
"X-Greptime-DB-Name" = "${GREPTIME_DB:=public}",
"x-greptime-log-table-name" = "demo_logs",
"x-greptime-log-extract-keys" = "filename",
"x-greptime-log-table-name" = "alloy_meta_logs",
"x-greptime-log-extract-keys" = "hostname",
}
auth = otelcol.auth.basic.credentials.handler
}
Expand All @@ -80,15 +80,26 @@ otelcol.auth.basic "credentials" {
password = "${GREPTIME_PASSWORD}"
}

loki.source.file "greptime" {
targets = [
{__path__ = "/tmp/foo.txt"},
]
forward_to = [otelcol.receiver.loki.greptime.receiver]
otelcol.processor.attributes "enrichment" {
action {
key = "hostname"
value = constants.hostname
action = "insert"
}

output {
logs = [otelcol.exporter.otlphttp.greptimedb_logs.input]
}
}

otelcol.receiver.loki "greptime" {
output {
logs = [otelcol.exporter.otlphttp.greptimedb_logs.input]
logs = [otelcol.processor.attributes.enrichment.input]
}
}
}

logging {
level = "info"
format = "json"
write_to = [otelcol.receiver.loki.greptime.receiver]
}

0 comments on commit caa7741

Please sign in to comment.