目录搜索
ComposeAbout 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 bundledocker-compose configdocker-compose createdocker-compose downdocker-compose eventsdocker-compose execdocker-compose helpdocker-compose imagesdocker-compose killdocker-compose logsdocker-compose pausedocker-compose portdocker-compose psdocker-compose pulldocker-compose pushdocker-compose restartdocker-compose rmdocker-compose rundocker-compose scaledocker-compose startdocker-compose stopdocker-compose topdocker-compose unpausedocker-compose upEnvironment file (Compose)Environment variables in ComposeExtend services in ComposeFrequently asked questions (Compose)Getting started (Compose)Install ComposeLink environment variables (deprecated) (Compose)Networking in ComposeOverview of Docker ComposeOverview of docker-compose CLIQuickstart: Compose and WordPressRails and PostgreSQL (Compose)Sample apps with ComposeUsing Compose in productionUsing Compose with SwarmEngine.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-ngBest 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 networkDelete the service (Engine)Deploy a service (Engine)Deploy services to a swarm (Engine)Deprecated Engine featuresDocker container networking (Engine)Docker overview (Engine)Docker run reference (Engine)Dockerfile reference (Engine)Dockerize an applicationDrain a node (Engine)EngineFAQ (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.10Optional Linux post-installation steps (Engine)Overview (Engine)PostgreSQL (Engine)Raft consensus in swarm mode (Engine)Riak (Engine)Run Docker Engine in swarm modeScale 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 GuideAmazon 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 mountsTroubleshoot 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: CLIDaemon CLI reference (dockerd) (Engine)dockerdocker attachdocker builddocker checkpointdocker checkpoint createdocker checkpoint lsdocker checkpoint rmdocker commitdocker configdocker config createdocker config inspectdocker config lsdocker config rmdocker containerdocker container attachdocker container commitdocker container cpdocker container createdocker container diffdocker container execdocker container exportdocker container inspectdocker container killdocker container logsdocker container lsdocker container pausedocker container portdocker container prunedocker container renamedocker container restartdocker container rmdocker container rundocker container startdocker container statsdocker container stopdocker container topdocker container unpausedocker container updatedocker container waitdocker cpdocker createdocker deploydocker diffdocker eventsdocker execdocker exportdocker historydocker imagedocker image builddocker image historydocker image importdocker image inspectdocker image loaddocker image lsdocker image prunedocker image pulldocker image pushdocker image rmdocker image savedocker image tagdocker imagesdocker importdocker infodocker inspectdocker killdocker loaddocker logindocker logoutdocker logsdocker networkdocker network connectdocker network createdocker network disconnectdocker network inspectdocker network lsdocker network prunedocker network rmdocker nodedocker node demotedocker node inspectdocker node lsdocker node promotedocker node psdocker node rmdocker node updatedocker pausedocker plugindocker plugin createdocker plugin disabledocker plugin enabledocker plugin inspectdocker plugin installdocker plugin lsdocker plugin pushdocker plugin rmdocker plugin setdocker plugin upgradedocker portdocker psdocker pulldocker pushdocker renamedocker restartdocker rmdocker rmidocker rundocker savedocker searchdocker secretdocker secret createdocker secret inspectdocker secret lsdocker secret rmdocker servicedocker service createdocker service inspectdocker service logsdocker service lsdocker service psdocker service rmdocker service scaledocker service updatedocker stackdocker stack deploydocker stack lsdocker stack psdocker stack rmdocker stack servicesdocker startdocker statsdocker stopdocker swarmdocker swarm cadocker swarm initdocker swarm joindocker swarm join-tokendocker swarm leavedocker swarm unlockdocker swarm unlock-keydocker swarm updatedocker systemdocker system dfdocker system eventsdocker system infodocker system prunedocker tagdocker topdocker unpausedocker updatedocker versiondocker volumedocker volume createdocker volume inspectdocker volume lsdocker volume prunedocker volume rmdocker waitUse the Docker command line (Engine)Engine: ExtendAccess authorization plugin (Engine)Docker log driver pluginsDocker network driver plugins (Engine)Extending Engine with pluginsManaged plugin system (Engine)Plugin configuration (Engine)Plugins API (Engine)Volume plugins (Engine)Engine: SecurityAppArmor 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 EngineUse trusted imagesUsing certificates for repository client verification (Engine)Engine: TutorialsEngine tutorialsNetwork containers (Engine)Get StartedPart 1: OrientationPart 2: ContainersPart 3: ServicesPart 4: SwarmsPart 5: StacksPart 6: Deploy your appMachineAmazon Web Services (Machine)Digital Ocean (Machine)docker-machine activedocker-machine configdocker-machine createdocker-machine envdocker-machine helpdocker-machine inspectdocker-machine ipdocker-machine killdocker-machine lsdocker-machine provisiondocker-machine regenerate-certsdocker-machine restartdocker-machine rmdocker-machine scpdocker-machine sshdocker-machine startdocker-machine statusdocker-machine stopdocker-machine upgradedocker-machine urlDriver 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 MachineMachineMachine CLI overviewMachine command-line completionMachine concepts and helpMachine overviewMicrosoft Azure (Machine)Microsoft Hyper-V (Machine)Migrate from Boot2Docker to MachineOpenStack (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)NotaryClient configuration (Notary)Common Server and signer configurations (Notary)Getting started with NotaryNotary changelogNotary configuration filesRunning a Notary serviceServer configuration (Notary)Signer configuration (Notary)Understand the service architecture (Notary)Use the Notary client
文字

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

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

上一篇:下一篇: