I am trying to make my logstash report matrics to influxdb but i got authentication failed
Here is my config for logstash.conf:
input {
exec {
command => "echo 'Hello'"
interval => 30
}
}
output {
influxdb {
codec => json
data_points => {}
host => "influxdb2"
port => 8086
user => "admin"
password => "adminPassword"
db => "my-test-bucket"
measurement => "my-logstash"
retention_policy => "30days"
use_event_fields_for_data_points => true
}
stdout { codec => rubydebug }
}
and here is my docker-compose.yml file with $ELK_VERSION=8.2.0 and $INFLUXDB_VERSION=2.2.0
version: '3.8'
services:
logstash:
build:
context: logstash/
args:
ELK_VERSION: $ELK_VERSION
volumes:
- type: bind
source: ./logstash/config/logstash.yml
target: /usr/share/logstash/config/logstash.yml
read_only: true
- type: bind
source: ./logstash/pipeline
target: /usr/share/logstash/pipeline
read_only: true
ports:
- "5000:5000/tcp"
- "5000:5000/udp"
- "9600:9600"
environment:
LS_JAVA_OPTS: "-Xmx256m -Xms256m"
networks:
- logstash-influx
depends_on:
- influxdb2
influxdb2:
build:
context: influxdb2/
args:
INFLUXDB_VERSION: $INFLUXDB_VERSION
volumes:
- type: bind
source: ./influxdb2/data
target: /var/lib/influxdb2
- type: bind
source: ./influxdb2/config
target: /etc/influxdb2
environment:
- DOCKER_INFLUXDB_INIT_MODE=setup
- DOCKER_INFLUXDB_INIT_USERNAME=admin
- DOCKER_INFLUXDB_INIT_PASSWORD=adminPassword
- DOCKER_INFLUXDB_INIT_ORG=my-org
- DOCKER_INFLUXDB_INIT_BUCKET=my-test-bucket
- DOCKER_INFLUXDB_INIT_RETENTION=30d
- DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=tokenValue
restart: always
ports:
- 8083:8083
- 8086:8086
- 8088:8088
privileged: true
networks: [logstash-influx]
networks:
logstash-influx:
driver: bridge
and finally this is what i see in logstash logs:
[logstash.outputs.influxdb][main][01a059db918175277750b48ea961afe2cc3da4cb1ca2db4a7c55835b97214837] Authentication Error while writing to InfluxDB {:exception=>#<InfluxDB::AuthenticationError: > > > >
{"code":"unauthorized","message":"Unauthorized"}>}
{
"message" => "Hello\n",
"@timestamp" => 2022-05-21T03:46:17.408520Z,
"command" => "echo 'Hello'",
"host" => "c432d182d05e",
"@version" => "1"
}
I wonder why it fail in authentication and i am sure i am passing the correct username and password, any idea???