没有使用docker-compose创建的logstash sincedb文件

时间:2019-07-25 14:02:40

标签: amazon-ec2 docker-compose logstash

我在AWS EC2(AMI)实例上有一个运行docker-compose的logstash实例。我已经将一个文件夹作为卷安装到了容器中。我有logstash管道配置,可将sincedb文件写入已安装的文件夹中。管道正在运行,但不会为sincedb文件编写任何内容。

相同的配置适用于我的本地计算机,但不适用于EC2。我检查了用户是否有权通过在该文件夹中创建文件来写该文件夹(例如:vi测试)。

Docker撰写配置:

version: "2"
services:
  logstash:
    image: docker.elastic.co/logstash/logstash:7.2.0
    volumes:
      - ./logstash/pipeline/:/usr/share/logstash/pipeline/
      - ./logstash/settings/logstash.yml:/usr/share/logstash/config/logstash.yml
      - ../data/:/usr/data/:rw
      - ./logstash/templates/:/usr/share/logstash/templates/
    container_name: logstash
    ports:
      - 9600:9600
    env_file:
      - ../env/.env.logstash

Logstash输入:

input{
  s3 {
    access_key_id => "${AWS_ACCESS_KEY}"
    bucket => "xyz-bucket"
    secret_access_key => "${AWS_SECRET_KEY}"
    region => "eu-west-1"
    prefix => "logs/"
    type => "log"
    codec => "json"
    sincedb_path => "/usr/data/log-sincedb.file"
  }
}

1 个答案:

答案 0 :(得分:0)

我已解决此问题。必须在docker-compose服务配置中显式添加user:root。

version: "2"
services:
  logstash:
    image: docker.elastic.co/logstash/logstash:7.2.0
    user: root
    volumes:
      - ./logstash/pipeline/:/usr/share/logstash/pipeline/
      - ./logstash/settings/logstash.yml:/usr/share/logstash/config/logstash.yml
      - ../data/:/usr/data/:rw
      - ./logstash/templates/:/usr/share/logstash/templates/
    container_name: logstash
    ports:
      - 9600:9600
    env_file:
      - ../env/.env.logstash