Elastic Logging Plugin usage examples

edit

Elastic Logging Plugin usage examples

edit

This functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.

The following examples show common configurations for the Elastic Logging Plugin.

Send Docker logs to Elasticsearch

edit

Docker run command:

docker run --log-driver=elastic/elastic-logging-plugin:7.8.1 \
           --log-opt output.elasticsearch.hosts="myhost:9200" \
           --log-opt output.elasticsearch.protocol="https" \
           --log-opt output.elasticsearch.username="myusername" \
           --log-opt output.elasticsearch.password="mypassword" \
           --log-opt output.elasticsearch.index="elastic-log-driver-%{+yyyy.MM.dd}" \
           -it debian:jessie /bin/bash

Daemon configuration:

{
  "log-driver" : "elastic/elastic-logging-plugin:7.8.1",
  "log-opts" : {
    "output.elasticsearch.hosts" : "myhost:9200",
    "output.elasticsearch.protocol" : "https",
    "output.elasticsearch.username" : "myusername",
    "output.elasticsearch.password" : "mypassword",
    "output.elasticsearch.index" : "elastic-log-driver-%{+yyyy.MM.dd}"
  }
}

Send Docker logs to Elasticsearch Service on Elastic Cloud

edit

Docker run command:

docker run --log-driver=elastic/elastic-logging-plugin:7.8.1 \
           --log-opt cloud.id="MyElasticStack:daMbY2VudHJhbDekZ2NwLmN4b3VkLmVzLmliJDVkYmQwtGJiYjs0NTRiN4Q5ODJmNGUwm1IxZmFkNjM5JDFiNjdkMDE4MTgxMTQzNTM5ZGFiYWJjZmY0OWIyYWE5" \
           --log-opt cloud.auth="myusername:mypassword" \
           --log-opt output.elasticsearch.index="elastic-log-driver-%{+yyyy.MM.dd}" \
           -it debian:jessie /bin/bash

Daemon configuration:

{
  "log-driver" : "elastic/elastic-logging-plugin:7.8.1",
  "log-opts" : {
    "cloud.id" : "MyElasticStack:daMbY2VudHJhbDekZ2NwLmN4b3VkLmVzLmliJDVkYmQwtGJiYjs0NTRiN4Q5ODJmNGUwm1IxZmFkNjM5JDFiNjdkMDE4MTgxMTQzNTM5ZGFiYWJjZmY0OWIyYWE5",
    "cloud.auth" : "myusername:mypassword",
    "output.elasticsearch.index" : "elastic-log-driver-%{+yyyy.MM.dd}"
  }
}

Send Docker logs to Logstash

edit

Docker run command:

docker run --log-driver=elastic/elastic-logging-plugin:7.8.1 \
           --log-opt output.logstash.hosts="myhost:5044" \
           -it debian:jessie /bin/bash

Daemon configuration:

{
  "log-driver" : "elastic/elastic-logging-plugin:7.8.1",
  "log-opts" : {
    "output.logstash.hosts" : "myhost:5044"
  }
}