From 61718dba123c6f4746f9373a5e9ad5fbbfa2aaa0 Mon Sep 17 00:00:00 2001 From: localhost Date: Mon, 18 Nov 2024 10:27:34 +0800 Subject: [PATCH] chore: add otlp logs demo for grafana alloy (#61) * chore: add otlp logs and rename vector ingestion readme * Apply suggestions from code review Co-authored-by: Ning Sun --------- Co-authored-by: Ning Sun --- grafana-alloy/config.alloy.tpl | 25 +++++++++++++++++++++++++ grafana-alloy/docker-compose.yml | 3 ++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/grafana-alloy/config.alloy.tpl b/grafana-alloy/config.alloy.tpl index 3f41e04..4e76f12 100644 --- a/grafana-alloy/config.alloy.tpl +++ b/grafana-alloy/config.alloy.tpl @@ -63,7 +63,32 @@ otelcol.exporter.otlphttp "greptimedb" { } } +otelcol.exporter.otlphttp "greptimedb_logs" { + client { + 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", + } + auth = otelcol.auth.basic.credentials.handler + } +} + otelcol.auth.basic "credentials" { username = "${GREPTIME_USERNAME}" password = "${GREPTIME_PASSWORD}" } + +loki.source.file "greptime" { + targets = [ + {__path__ = "/tmp/foo.txt"}, + ] + forward_to = [otelcol.receiver.loki.greptime.receiver] +} + +otelcol.receiver.loki "greptime" { + output { + logs = [otelcol.exporter.otlphttp.greptimedb_logs.input] + } +} \ No newline at end of file diff --git a/grafana-alloy/docker-compose.yml b/grafana-alloy/docker-compose.yml index eedaa45..8654dc1 100644 --- a/grafana-alloy/docker-compose.yml +++ b/grafana-alloy/docker-compose.yml @@ -11,7 +11,7 @@ services: init: true greptimedb: - image: docker.io/greptime/greptimedb:v0.10.0-nightly-20241007 + image: docker.io/greptime/greptimedb:v0.10.0-nightly-20241104 command: standalone start --http-addr=0.0.0.0:4000 --rpc-addr=0.0.0.0:4001 --mysql-addr=0.0.0.0:4002 --postgres-addr 0.0.0.0:4003 ports: - 4000:4000 @@ -44,6 +44,7 @@ services: - demo-network volumes: - config:/etc/alloy + - ./foo.txt:/tmp/foo.txt depends_on: envsubst: condition: service_completed_successfully