I have a requirement to read kafka msgs and push to loki. I see a example repo on github for this and trying to implement grafana kafka example on my local. Created grafana cloud account to push logs to loki.
So far, all container are up and running, however, promtail is unable to push logs to loki. Here is the error msg:
2024-05-24 11:37:52 level=warn ts=2024-05-24T16:37:52.604389637Z caller=client.go:419 component=client host=<loki host> msg="error sending batch, will retry" status=-1 tenant= error="Post \"https://<loki host>/loki/api/v1/push\": tls: failed to verify certificate: x509: certificate signed by unknown authority"
Below are configs from promtail config and docker compose files:
promtail-config:
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /tmp/promtail-positions.yaml
clients:
- url: ${GRAFANA_LOGS_WRITE_URL}
basic_auth:
username: ${USER_NAME}
password: ${PASSWORD}
scrape_configs:
- job_name: varlogs
static_configs:
- targets:
- localhost
labels:
job: varlogs
__path__: /var/log/*.log
- job_name: kafka
kafka:
brokers:
- kafka_broker:9092
group_id: grafana_group
topics:
- grafana
labels:
job: kafka
host: ${HOSTNAME:promtail}
relabel_configs:
- action: replace
source_labels:
- __meta_kafka_topic
target_label: topic
- action: replace
source_labels:
- __meta_kafka_partition
target_label: partition
- action: replace
source_labels:
- __meta_kafka_group_id
target_label: group
docker-compose:
# promtail consumes messages from a kafka topic and remote writes them to Grafana Logs
promtail:
image: grafana/promtail:3.0.0
depends_on:
- kafka_broker
deploy:
replicas: 2
restart: always
volumes:
- /var/log:/var/log
- ./:/etc/promtail/
command: [-config.expand-env=true, -config.file=/etc/promtail/config.yml]
Appreciate your help to resolve. Thank you