Sign inSign up

pdffiller/filebeat-consul

By pdffiller

Updated over 4 years ago

filebeat client configured via consul-template

Image
0

100K+

pdffiller/filebeat-consul repository overview

filebeat-consul

Filebeat configuring via Consul

Environment Variables
NameDescriptionDefault
SERVICE_KV_PATHThe path to filebeat folder with config KV in consul"filebeat"
CONSUL_TOKENThe consul acl token. See https://www.consul.io/docs/guides/acl.html#acl-agent-token
CONSUL_HTTP_ADDRThe consul URLhttp://172.17.0.1:8500
CLUSTER_NAMEThe additional subfolders in KV path for different filebit instancesecs-cluster
SERVICE_ENVThe additional prefix to elasticsearch indexnamestage
Mount Points

/var/log/ logs

Visual diagram

Configure the cleaner
NameDescription
logs_TTLTime in min. If during the specified time the file is not changed, it is deleted
Sample configure cleaner (put consul KV via bash script)
#!/bin/bash

SERVICE_KV_PATH="filebeat"
CONSUL_SERVER_URL="http://localhost:8500"

curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/config/logs_TTL <<< "180"
Configure the output
NameDescription
es_hostThe elasticsearch addres
es_portThe elasticsearch port
Sample configure output (put consul KV via bash script)
#!/bin/bash

SERVICE_KV_PATH="filebeat"
CONSUL_SERVER_URL="http://localhost:8500"

curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/config/es_host <<< "localhost"
curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/config/es_port <<< "9200"
Configure inputs
NameDescriptionMandatoryDefault
typeThe Filebeat Input type. Example: dockernolog
doc_typeThe value for fileds document_typeyes
index_prefixThe elasticsearch index prefix. Result elasticsearch prefix like "SERVICE_ENV-%{[fields.index_prefix]}-%{+yyyy.MM.dd}"if type log: yes
jsonBoolean value. Set true if log in json formatyes
pathThe parsing file mask (for docker use: /var/lib/docker/containers)yes
Sample configure inputs (put consul KV via bash script)
#!/bin/bash

CLUSTER_NAME="ecs-cluster"
SERVICE_KV_PATH="filebeat"
CONSUL_SERVER_URL="http://localhost:8500"

curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/${CLUSTER_NAME}/container-1-nginx-access/doc_type <<< "container-1-nginx-access"
curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/${CLUSTER_NAME}/container-1-nginx-access/index_prefix <<< "nginx-access"
curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/${CLUSTER_NAME}/container-1-nginx-access/json <<< "1"
curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/${CLUSTER_NAME}/container-1-nginx-access/path <<< "/var/log/container_1/nginx/*.json"

curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/${CLUSTER_NAME}/container-1-nginx-error/doc_type <<< "container-1-nginx-error"
curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/${CLUSTER_NAME}/container-1-nginx-error/index_prefix <<< "nginx-error"
curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/${CLUSTER_NAME}/container-1-nginx-error/json <<< "0"
curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/${CLUSTER_NAME}/container-1-nginx-error/path <<< "/var/log/container_1/nginx/*.log"


curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/${CLUSTER_NAME}/container-2-nginx-access/doc_type <<< "container-2-nginx-access"
curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/${CLUSTER_NAME}/container-2-nginx-access/index_prefix <<< "nginx-access"
curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/${CLUSTER_NAME}/container-2-nginx-access/json <<< "1"
curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/${CLUSTER_NAME}/container-2-nginx-access/path <<< "/var/log/container_1/nginx/*.json"

curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/${CLUSTER_NAME}/container-2-nginx-error/doc_type <<< "container-2-nginx-error"
curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/${CLUSTER_NAME}/container-2-nginx-error/index_prefix <<< "nginx-error"
curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/${CLUSTER_NAME}/container-2-nginx-error/json <<< "0"
curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/${CLUSTER_NAME}/container-2-nginx-error/path <<< "/var/log/container_2/nginx/*.log"

#### docker test 
curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/${CLUSTER_NAME}/container-1-nginx-docker/type <<< "docker"
curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/${CLUSTER_NAME}/container-1-docker/doc_type <<< "container-1-nginx-docker"
curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/${CLUSTER_NAME}/container-1-docker/index_prefix <<< "nginx-docker"
curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/${CLUSTER_NAME}/container-1-docker/json <<< "1"
curl -X PUT -d @- ${CONSUL_SERVER_URL}/v1/kv/${SERVICE_KV_PATH}/${CLUSTER_NAME}/container-1-docker/path <<< "/var/lib/docker/containers"

sample keys used filebeat-consul

curl --header "X-Consul-Token: 1234sampletoken" "http://localhost:8500/v1/kv/filebeat?keys"
[
    "filebeat/config/es_host",
    "filebeat/config/es_port",
    "filebeat/config/logs_TTL",

    "filebeat/ecs-cluster/container-1-nginx-access/doc_type",
    "filebeat/ecs-cluster/container-1-nginx-access/index_prefix",
    "filebeat/ecs-cluster/container-1-nginx-access/json",
    "filebeat/ecs-cluster/container-1-nginx-access/path",

    "filebeat/ecs-cluster/container-1-nginx-error/doc_type",
    "filebeat/ecs-cluster/container-1-nginx-error/index_prefix",
    "filebeat/ecs-cluster/container-1-nginx-error/json",
    "filebeat/ecs-cluster/container-1-nginx-error/path",

    "filebeat/ecs-cluster/container-2-nginx-access/doc_type",
    "filebeat/ecs-cluster/container-2-nginx-access/index_prefix",
    "filebeat/ecs-cluster/container-2-nginx-access/json",
    "filebeat/ecs-cluster/container-2-nginx-access/path",

    "filebeat/ecs-cluster/container-2-nginx-error/doc_type",
    "filebeat/ecs-cluster/container-2-nginx-error/index_prefix",
    "filebeat/ecs-cluster/container-2-nginx-error/json",
    "filebeat/ecs-cluster/container-2-nginx-error/path"
]
additional build parameters
NameDescriptionDefault
FILEBEAT_VERSIONThe filebeat version6.7.1
CONSUL_TEMPLATE_VERSIONThe consul-template version0.22.0
ALPINE_GLIBC_PACKAGE_VERSIONThe glibc version2.23-r1

Filebeat Reference

Consul Documentation

pdffillerdocker/filebeat-consul is licensed under the MIT License

Tag summary

Content type

Image

Digest

Size

38.4 MB

Last updated

over 4 years ago

docker pull pdffiller/filebeat-consul:2.1.1