directory search
Compose About versions and upgrading (Compose) ASP.NET Core + SQL Server on Linux (Compose) CLI environment variables (Compose) Command-line completion (Compose) Compose(组成) Compose command-line reference(组合命令行参考) Control startup order (Compose) Django and PostgreSQL (Compose) Docker stacks and distributed application bundles (Compose) docker-compose build(docker-compose构建) docker-compose bundle docker-compose config docker-compose create docker-compose down docker-compose events docker-compose exec docker-compose help docker-compose images docker-compose kill docker-compose logs docker-compose pause docker-compose port docker-compose ps docker-compose pull docker-compose push docker-compose restart docker-compose rm docker-compose run docker-compose scale docker-compose start docker-compose stop docker-compose top docker-compose unpause docker-compose up Environment file (Compose) Environment variables in Compose Extend services in Compose Frequently asked questions (Compose) Getting started (Compose) Install Compose Link environment variables (deprecated) (Compose) Networking in Compose Overview of Docker Compose Overview of docker-compose CLI Quickstart: Compose and WordPress Rails and PostgreSQL (Compose) Sample apps with Compose Using Compose in production Using Compose with Swarm Engine .NET Core application (Engine) About images, containers, and storage drivers (Engine) Add nodes to the swarm (Engine) Apply custom metadata (Engine) Apply rolling updates (Engine) apt-cacher-ng Best practices for writing Dockerfiles (Engine) Binaries (Engine) Bind container ports to the host (Engine) Breaking changes (Engine) Build your own bridge (Engine) Configure container DNS (Engine) Configure container DNS in user-defined networks (Engine) CouchDB (Engine) Create a base image (Engine) Create a swarm (Engine) Customize the docker0 bridge (Engine) Debian (Engine) Default bridge network Delete the service (Engine) Deploy a service (Engine) Deploy services to a swarm (Engine) Deprecated Engine features Docker container networking (Engine) Docker overview (Engine) Docker run reference (Engine) Dockerfile reference (Engine) Dockerize an application Drain a node (Engine) Engine FAQ (Engine) Fedora (Engine) Get started (Engine) Get started with macvlan network driver (Engine) Get started with multi-host networking (Engine) How nodes work (Engine) How services work (Engine) Image management (Engine) Inspect the service (Engine) Install Docker (Engine) IPv6 with Docker (Engine) Join nodes to a swarm (Engine) Legacy container links (Engine) Lock your swarm (Engine) Manage nodes in a swarm (Engine) Manage sensitive data with Docker secrets (Engine) Manage swarm security with PKI (Engine) Manage swarm service networks (Engine) Migrate to Engine 1.10 Optional Linux post-installation steps (Engine) Overview (Engine) PostgreSQL (Engine) Raft consensus in swarm mode (Engine) Riak (Engine) Run Docker Engine in swarm mode Scale the service (Engine) SDKs (Engine) Select a storage driver (Engine) Set up for the tutorial (Engine) SSHd (Engine) Storage driver overview (Engine) Store service configuration data (Engine) Swarm administration guide (Engine) Swarm mode key concepts (Engine) Swarm mode overlay network security model (Engine) Swarm mode overview (Engine) Understand container communication (Engine) Use multi-stage builds (Engine) Use swarm mode routing mesh (Engine) Use the AUFS storage driver (Engine) Use the Btrfs storage driver (Engine) Use the Device mapper storage driver (Engine) Use the OverlayFS storage driver (Engine) Use the VFS storage driver (Engine) Use the ZFS storage driver (Engine) Engine: Admin Guide Amazon CloudWatch logs logging driver (Engine) Bind mounts (Engine) Collect Docker metrics with Prometheus (Engine) Configuring and running Docker (Engine) Configuring logging drivers (Engine) Control and configure Docker with systemd (Engine) ETW logging driver (Engine) Fluentd logging driver (Engine) Format command and log output (Engine) Google Cloud logging driver (Engine) Graylog Extended Format (GELF) logging driver (Engine) Journald logging driver (Engine) JSON File logging driver (Engine) Keep containers alive during daemon downtime (Engine) Limit a container's resources (Engine) Link via an ambassador container (Engine) Log tags for logging driver (Engine) Logentries logging driver (Engine) PowerShell DSC usage (Engine) Prune unused Docker objects (Engine) Run multiple services in a container (Engine) Runtime metrics (Engine) Splunk logging driver (Engine) Start containers automatically (Engine) Storage overview (Engine) Syslog logging driver (Engine) tmpfs mounts Troubleshoot volume problems (Engine) Use a logging driver plugin (Engine) Using Ansible (Engine) Using Chef (Engine) Using Puppet (Engine) View a container's logs (Engine) Volumes (Engine) Engine: CLI Daemon CLI reference (dockerd) (Engine) docker docker attach docker build docker checkpoint docker checkpoint create docker checkpoint ls docker checkpoint rm docker commit docker config docker config create docker config inspect docker config ls docker config rm docker container docker container attach docker container commit docker container cp docker container create docker container diff docker container exec docker container export docker container inspect docker container kill docker container logs docker container ls docker container pause docker container port docker container prune docker container rename docker container restart docker container rm docker container run docker container start docker container stats docker container stop docker container top docker container unpause docker container update docker container wait docker cp docker create docker deploy docker diff docker events docker exec docker export docker history docker image docker image build docker image history docker image import docker image inspect docker image load docker image ls docker image prune docker image pull docker image push docker image rm docker image save docker image tag docker images docker import docker info docker inspect docker kill docker load docker login docker logout docker logs docker network docker network connect docker network create docker network disconnect docker network inspect docker network ls docker network prune docker network rm docker node docker node demote docker node inspect docker node ls docker node promote docker node ps docker node rm docker node update docker pause docker plugin docker plugin create docker plugin disable docker plugin enable docker plugin inspect docker plugin install docker plugin ls docker plugin push docker plugin rm docker plugin set docker plugin upgrade docker port docker ps docker pull docker push docker rename docker restart docker rm docker rmi docker run docker save docker search docker secret docker secret create docker secret inspect docker secret ls docker secret rm docker service docker service create docker service inspect docker service logs docker service ls docker service ps docker service rm docker service scale docker service update docker stack docker stack deploy docker stack ls docker stack ps docker stack rm docker stack services docker start docker stats docker stop docker swarm docker swarm ca docker swarm init docker swarm join docker swarm join-token docker swarm leave docker swarm unlock docker swarm unlock-key docker swarm update docker system docker system df docker system events docker system info docker system prune docker tag docker top docker unpause docker update docker version docker volume docker volume create docker volume inspect docker volume ls docker volume prune docker volume rm docker wait Use the Docker command line (Engine) Engine: Extend Access authorization plugin (Engine) Docker log driver plugins Docker network driver plugins (Engine) Extending Engine with plugins Managed plugin system (Engine) Plugin configuration (Engine) Plugins API (Engine) Volume plugins (Engine) Engine: Security AppArmor security profiles for Docker (Engine) Automation with content trust (Engine) Content trust in Docker (Engine) Delegations for content trust (Engine) Deploying Notary (Engine) Docker security (Engine) Docker security non-events (Engine) Isolate containers with a user namespace (Engine) Manage keys for content trust (Engine) Play in a content trust sandbox (Engine) Protect the Docker daemon socket (Engine) Seccomp security profiles for Docker (Engine) Secure Engine Use trusted images Using certificates for repository client verification (Engine) Engine: Tutorials Engine tutorials Network containers (Engine) Get Started Part 1: Orientation Part 2: Containers Part 3: Services Part 4: Swarms Part 5: Stacks Part 6: Deploy your app Machine Amazon Web Services (Machine) Digital Ocean (Machine) docker-machine active docker-machine config docker-machine create docker-machine env docker-machine help docker-machine inspect docker-machine ip docker-machine kill docker-machine ls docker-machine provision docker-machine regenerate-certs docker-machine restart docker-machine rm docker-machine scp docker-machine ssh docker-machine start docker-machine status docker-machine stop docker-machine upgrade docker-machine url Driver options and operating system defaults (Machine) Drivers overview (Machine) Exoscale (Machine) Generic (Machine) Get started with a local VM (Machine) Google Compute Engine (Machine) IBM Softlayer (Machine) Install Machine Machine Machine CLI overview Machine command-line completion Machine concepts and help Machine overview Microsoft Azure (Machine) Microsoft Hyper-V (Machine) Migrate from Boot2Docker to Machine OpenStack (Machine) Oracle VirtualBox (Machine) Provision AWS EC2 instances (Machine) Provision Digital Ocean Droplets (Machine) Provision hosts in the cloud (Machine) Rackspace (Machine) VMware Fusion (Machine) VMware vCloud Air (Machine) VMware vSphere (Machine) Notary Client configuration (Notary) Common Server and signer configurations (Notary) Getting started with Notary Notary changelog Notary configuration files Running a Notary service Server configuration (Notary) Signer configuration (Notary) Understand the service architecture (Notary) Use the Notary client
characters

splunk日志驱动程序发送集装箱日志HTTP事件收集器中的Splunk Enterprise和Splunk的云。

用法

要将splunk驱动程序用作默认日志记录驱动程序,请将该键log-driverlog-opt键设置daemon.json为位于/etc/docker/Linux主机或C:\ProgramData\docker\config\daemon.jsonWindows Server 上的文件中的适当值。有关+使用Docker配置的更多信息daemon.json,请参阅+ daemon.json。

以下示例将日志驱动程序设置为splunk

{  "log-driver": "splunk"}

重新启动Docker以使更改生效。

您可以使用以下--log-driver选项来设置特定容器的日志记录驱动程序docker run

docker run --log-driver=splunk ...

Splunk选项

您可以使用该--log-opt NAME=VALUE标志来指定这些额外的Splunk日志记录驱动程序选项:

选项

需要

描述

splunk-token

需要

Splunk HTTP事件收集器令牌。

splunk-url

需要

以下列格式之一指向您的Splunk Enterprise,自助服务Splunk Cloud实例或Splunk云托管群集(包括HTTP Event Collector使用的端口和方案)的路径:https:// your_splunk_instance:8088或https:// input- prd-p-XXXXXXX.cloud.splunk.com:8088或https://http-inputs-XXXXXXXX.splunkcloud.com。

splunk-source

可选的

事件源。

splunk-sourcetype

可选的

事件源类型。

splunk-index

可选的

事件索引。

splunk-capath

可选的

根证书的路径。

Splunk-caname

可选的

用于验证服务器证书的名称; 默认情况下将使用splunk-url的主机名。

splunk-insecureskipverify

可选的

忽略服务器证书验证。

splunk-format

可选的

消息格式。可以是内联,json或raw。默认为内联。

splunk-verify-connection

可选的

在开始时验证,该docker可以连接到Splunk服务器。默认为true。

Splunk-gzip

可选的

启用/禁用gzip压缩以将事件发送到Splunk Enterprise或Splunk Cloud实例。默认为false。

splunk-gzip-level

可选的

设置gzip的压缩级别。有效值为-1(默认),0(不压缩),1(最佳速度)... 9(最佳压缩)。默认为DefaultCompression。

tag

可选的

为消息指定标签,解释某些标记。默认值是{{.ID}}(容器ID的12个字符)。请参阅日志标记选项文档以定制日志标记格式。

labels

可选的

如果这些标签是为容器指定的,则应在消息中包含标签的键的逗号分隔列表。

env

可选的

如果为容器指定了这些变量,则应该在消息中包含环境变量的键的逗号分隔列表。

env-regex

可选的

与env类似且兼容。一个正则表达式来匹配与日志相关的环境变量。用于高级日志标记选项。

如果labelenv键之间存在冲突,env则优先。这两个选项都将附加字段添加到日志消息的属性中。

以下是为Splunk Enterprise实例指定的日志记录选项的示例。该实例本地安装在运行Docker守护程序的同一台机器上。根证书和通用名称的路径是使用HTTPS方案指定的。这用于验证。SplunkServerDefaultCert是由Splunk证书自动生成的。

$ docker run --log-driver=splunk \           --log-opt splunk-token=176FCEBF-4CF5-4EDF-91BC-703796522D20 \           --log-opt splunk-url=https://splunkhost:8088 \           --log-opt splunk-capath=/path/to/cert/cacert.pem \           --log-opt splunk-caname=SplunkServerDefaultCert \           --log-opt tag="{{.Name}}/{{.FullID}}" \           --log-opt labels=location \           --log-opt env=TEST \           --env "TEST=false" \           --label location=west \
       your/application

splunk-url托管于云的Splunk Splunk的情况下,是在像格式https://http-inputs-XXXXXXXX.splunkcloud.com,并且不包括端口说明。

消息格式

默认情况下,日志驱动程序将消息发送给inline格式,例如,每条消息将作为字符串嵌入其中。

{    "attrs": {        "env1": "val1",        "label1": "label1"    },    "tag": "MyImage/MyContainer",    "source":  "stdout",    "line": "my message"}{    "attrs": {        "env1": "val1",        "label1": "label1"    },    "tag": "MyImage/MyContainer",    "source":  "stdout",    "line": "{\"foo\": \"bar\"}"}

如果您的消息是JSON对象,您可能希望将它们嵌入到我们发送给Splunk的消息中。通过指定--log-opt splunk-format=json驱动程序将尝试将每一行解析为JSON对象,并将其作为嵌入式对象发送。如果它不能解析它-消息将作为inline.例如

{    "attrs": {        "env1": "val1",        "label1": "label1"    },    "tag": "MyImage/MyContainer",    "source":  "stdout",    "line": "my message"}{    "attrs": {        "env1": "val1",        "label1": "label1"    },    "tag": "MyImage/MyContainer",    "source":  "stdout",    "line": {        "foo": "bar"    }}

第三种格式是raw消息。您可以使用指定它--log-opt splunk-format=raw。属性(环境变量和标签)和标签将作为消息的前缀。例如

MyImage/MyContainer env1=val1 label1=label1 my message
MyImage/MyContainer env1=val1 label1=label1 {"foo": "bar"}

高级选项

Splunk日志记录驱动程序允许您通过为Docker守护进程指定下一个环境变量来配置少数高级选项。

环境变量名称

默认值

描述

SPLUNK_LOGGING_DRIVER_POST_MESSAGES_FREQUENCY

5S

如果没有什么可以批量驱动程序发布消息的频率。您可以将此视为等待更多消息进行批处理的最长时间。

SPLUNK_LOGGING_DRIVER_POST_MESSAGES_BATCH_SIZE

1000

在一批发送驱动程序之前,驱动程序应等待多少个消息。

SPLUNK_LOGGING_DRIVER_BUFFER_MAX

10 * 1000

如果驱动程序无法连接到远程服务器,它可以保存在缓冲区中以便重试的最大消息数量是多少。

SPLUNK_LOGGING_DRIVER_CHANNEL_SIZE

4 * 1000

通道中有多少待处理消息可用于将消息发送给后台记录器工作人员,后者将对这些消息进行批处理。

Previous article: Next article: