badresponsecodeerror,:error=>“获取了响应代码‘401’,正在url处联系elasticsearch

ecfdbz9o  于 2021-06-14  发布在  ElasticSearch
关注(0)|答案(1)|浏览(1163)

我用logstashlogstash:7.9.1 image 当我启动docker compose时,我遇到了这个错误,我不知道该怎么办(我试图使我的logstash配置错误,并将其连接到错误的弹性端口,但我的docker仍然连接到9200,因此我认为它没有从我的logstash配置读取数据)请帮助我!!!!我的错误:

[logstash.licensechecker.licensereader] Attempted to resurrect connection to dead ES instance, but got an error. {:url=>"http://elasticsearch:9200/", :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::BadResponseCodeError, :error=>"Got response code '401' contacting Elasticsearch at URL 'http://elasticsearch:9200/'"}

我的 Docker :

zookeeper:
    image: wurstmeister/zookeeper:3.4.6
    container_name: zookeeper
    ports:
      - 2181:2181
    networks:
      - bardz

  kafka:

    image: wurstmeister/kafka:2.11-1.1.0
    container_name: kafka
    depends_on:
      - zookeeper
    environment:
      KAFKA_ADVERTISED_HOST_NAME: kafka
      KAFKA_CREATE_TOPICS: logs-topic:1:1
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181

    ports:
      - 9092:9092
    volumes:
      - kofka-volume:/var/run/docker.sock
    networks:
      - bardz

  elasticsearch:
    build:
      context: elk/elasticsearch/
      args:
        ELK_VERSION: "7.9.1"
    volumes:
      - type: bind
        source: ./elk/elasticsearch/config/elasticsearch.yml
        target: /usr/share/elasticsearch/config/elasticsearch.yml
        read_only: true
      - type: volume
        source: elasticsearch
        target: /usr/share/elasticsearch/data
    ports:
      - "9200:9200"
      - "9300:9300"
    environment:
      ES_JAVA_OPTS: "-Xmx256m -Xms256m"
      ELASTIC_PASSWORD: changeme
      # Use single node discovery in order to disable production mode and avoid bootstrap checks
      # see https://www.elastic.co/guide/en/elasticsearch/reference/current/bootstrap-checks.html
      discovery.type: single-node
    networks:
      - bardz

  logstash:
    image: logstash:7.9.1
    restart: on-failure
    ports:
      - "5000:5000/tcp"
      - "5000:5000/udp"
      - "9600:9600"
    volumes:
      - logstash_data:/bitnami
      - ./elk/logstash/logstash-kafka.conf:/opt/bitnami/logstash/config/logstash-kafka.conf
    environment:
      LOGSTASH_CONF_FILENAME: logstash-kafka.conf
    networks:
      - bardz
    depends_on:
      - elasticsearch

networks:
  bardz:
    external: true
    driver: bridge

volumes:
  elasticsearch:
  zipkin-volume:
  kofka-volume:
  logstash_data:

我的日志存储配置:

input {
    kafka {
        bootstrap_servers => "kafka:9092"
        topics => ["logs-topic"]
    }
}

output {
    elasticsearch {
        hosts => ["elasticsearch:9200"]
        user => elastic
        password => changeme
        index => "logs-topic"
        workers => 1
    }
}
44u64gxh

44u64gxh1#

您使用的密码错误 elastic 7.9中的用户 changemepassword 如es贡献文档中所示,但我尝试过,这似乎只适用于从源代码运行es的情况。
不管怎样,你得到401意味着未经授权的访问,你可以在这里了解更多,
由于您不是从源代码运行es代码,建议您按照本线程中提到的步骤更改密码,并且在docker中运行密码时,您需要进入docker conatainer中 docker exec -it <cont-id> /bin/bash 然后运行线程中提到的命令来设置您自己的密码。

相关问题