# Logstash =\> influxdb authentication failed

**URL:** https://discuss.elastic.co/t/logstash-influxdb-authentication-failed/305323
**Category:** Logstash
**Tags:** docker
**Created:** [May 21, 2022, 3:51am UTC](https://discuss.elastic.co/t/logstash-influxdb-authentication-failed/305323 "2022-05-21T03:51:14Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mibrahim](https://avatars.discourse-cdn.com/v4/letter/m/5daacb/32.png) [@mibrahim](https://discuss.elastic.co/u/mibrahim)
#### Post date: [May 21, 2022, 3:51am UTC](https://discuss.elastic.co/t/logstash-influxdb-authentication-failed/305323/1 "2022-05-21T03:51:14Z")

</div>

**I am trying to make my logstash report matrics to influxdb but i got authentication failed** ☹

**Here is my config for logstash.conf:**

```auto
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_**

```auto
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???**

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [June 18, 2022, 3:51am UTC](https://discuss.elastic.co/t/logstash-influxdb-authentication-failed/305323/2 "2022-06-18T03:51:39Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
