📙
iLogtail用户手册
1.8.4
1.8.4
  • 关于
    • 什么是iLogtail
    • 发展历史
    • 产品优势
    • 开源协议
    • 社区版和企业版的对比说明
  • 安装
    • 快速开始
    • Docker使用
    • Kubernetes使用
    • 守护进程
    • 发布记录
    • 支持的操作系统
    • 源代码
      • 下载
      • 编译
      • Docker镜像
      • 编译依赖
    • 镜像站
  • 概念
    • 关键概念
    • 数据流水线
  • 配置
    • 采集配置
    • 系统参数
    • 日志
  • 数据流水线
    • 概览
    • 插件版本管理
    • 输入
      • 文本日志
      • 脚本执行数据
      • 容器标准输出
      • 文本日志(debug)
      • MetricInput示例插件
      • 主机Meta数据
      • Mock数据-Metric
      • eBPF网络调用数据
      • 主机监控数据
      • MySQL Binlog
      • GO Profile
      • GPU数据
      • HTTP数据
      • ServiceInput示例插件
      • Journal数据
      • Kafka
      • Mock数据-Service
      • SqlServer 查询数据
      • OTLP数据
      • PostgreSQL 查询数据
      • Syslog数据
    • 处理
      • 添加字段
      • 添加云资产信息
      • 原始数据
      • 数据脱敏
      • 丢弃字段
      • 字段加密
      • 条件字段处理
      • 日志过滤
      • Go时间格式解析
      • Grok
      • Json
      • 日志转SLS Metric
      • 正则
      • 重命名字段
      • 分隔符
      • 键值对
      • 多行切分
      • 字符串替换
    • 聚合
      • 基础
      • 上下文
      • 按Key分组
      • 按GroupMetadata分组
    • 输出
      • Kafka(Deprecated)
      • kafkaV2
      • ClickHouse
      • ElasticSearch
      • SLS
      • 标准输出/文件
      • OTLP日志
      • Pulsar
      • HTTP
      • Loki
    • 加速
      • 分隔符加速
      • Json加速
      • 正则加速
  • 工作原理
    • 文件发现
    • 插件系统
  • 可观测性
    • 日志
  • 开发者指南
    • 开发环境
    • 日志协议
      • 协议转换
      • 增加新的日志协议
      • 协议
        • sls协议
        • 单条协议
    • 代码风格
    • 数据模型
    • 插件开发
      • 开源插件开发引导
      • Checkpoint接口
      • Logger接口
      • 如何开发Input插件
      • 如何开发Processor插件
      • 如何开发Aggregator插件
      • 如何开发Flusher插件
      • 如何生成插件文档
      • 插件文档规范
      • 纯插件模式启动
    • 测试
      • 单元测试
      • E2E测试
    • 代码检查
      • 检查代码规范
      • 检查文件许可证
      • 检查依赖包许可证
  • 贡献指南
    • 贡献指南
    • 开发者
    • 成就
  • 性能测试
    • 容器场景iLogtail与Filebeat性能对比测试
  • 管控工具
    • 使用介绍
    • 通信协议
    • 开发指南
  • Awesome iLogtail
    • 走近iLogtail社区版
    • iLogtail社区版使用入门
    • iLogtail社区版开发者指南
    • iLogtail社区版使用案例
Powered by GitBook
On this page
  • 简介
  • 版本
  • 配置参数
  • 基础参数
  • 生成参数
  1. 数据流水线
  2. 输入

脚本执行数据

Previous文本日志Next容器标准输出

Last updated 1 year ago

简介

input_command插件可以通过配置脚本内容,在agent机器上生成可执行的脚本,并通过指定的cmdpath 执行该脚本,插件会从脚本执行后stdout获得内容进行解析,从而获取脚本内容执行后的信息。

注意:如果需要使用该插件,iLogtail需要在root用户下使用。配置的脚本内容请自查风险。

版本

配置参数

基础参数

参数
类型
是否必选
说明

Type

String

是

插件类型,指定为input_command

ScriptType

String

是

指定脚本内容的类型,目前支持:bash、shell、python2、python3

User

String

是

运行命令使用的用户名,只支持非Root用户(建议配置最小权限,只给需要关注的目录/文件rwx权限)

ScriptContent

String

是

脚本内容, 支持PlainText和base64加密的内容, 跟ContentEncoding的字段对应, ScriptContent长度不能超过512*1024

ContentEncoding

String

否

脚本内容的文本格式 支持PlainText(纯文本,不编码)|Base64编码 默认:PlainText

LineSplitSep

String

否

脚本输出内容的分隔符,为空时不进行分割,全部作为一条数据返回

CmdPath

String

否

执行脚本命令的路径,如果为空,则使用默认路径。bash、shell、python2、python3对应的默认路径如下: - bash: /usr/bin/bash - shell: /usr/bin/sh - python2: /usr/bin/python2 - python3: /usr/bin/python3

TimeoutMilliSeconds

int

否

执行脚本的超时时间,单位为毫秒,默认为3000ms

IntervalMs

int

否

采集触发频率,也是脚本执行的频率,单位为毫秒,默认为5000ms

Environments

[]string

否

环境变量,默认为os.Environ()的值,如果设置了Environments,则在os.Environ()的基础上追加设置的环境变量

IgnoreError

Bool

否

插件执行出错时是否输出Error日志。如果未添加该参数,则默认使用false,表示不忽略

生成参数

参数
类型
说明

content

String

表示脚本的输出内容

script_md5

String

用于表示 ScriptContent(脚本内容)的 MD5,有助于确定生成日志的脚本内容来源

  • 采集配置1

enable: true
inputs:
  - Type: input_command
    User: test
    ScriptType: shell
    ScriptContent:
      echo -e "test metric commond"
    Environments:
      - "DEBUG=true"
flushers:
  - Type: flusher_sls
    Endpoint: cn-xxxxxx.log.aliyuncs.com
    ProjectName: xxxxxx
    LogstoreName: xxxxxx
  - Type: flusher_stdout
    OnlyStdout: true
  • 输出

{
  "content":"test metric commond",
  "script_md5":"b3ebc535c2e6cead6e2e13b383907245",
  "__time__":"1689677617"
}
  • 采集配置2

enable: true
inputs:
  - Type: input_command
    User: test
    ScriptType: python2
    ScriptContent: |
      print("test input_command 0")
      print("test input_command 1")
      print("test input_command 2")
      print("test input_command 3")
      print("test input_command 4")
      print("test input_command 5")
      print("test input_command 6")
      print("test input_command 7")
      print("test input_command 8")
      print("test input_command 9")
    CmdPath: /usr/bin/python
    Environments:
      - "DEBUG=true"
    TimeoutMilliseconds: 1005
flushers:
  - Type: flusher_sls
    Endpoint: cn-xxxxxx.log.aliyuncs.com
    ProjectName: xxxxxx
    LogstoreName: xxxxxx
  - Type: flusher_stdout
    OnlyStdout: true
  • 输出

{
  "content":"test input_command 0\ntest input_command 1\ntest input_command 2\ntest input_command 3\ntest input_command 4\ntest input_command 5\ntest input_command 6\ntest input_command 7\ntest input_command 8\ntest input_command 9",
  "script_md5":"5d049f5b2943d2d5e5737dddb065c39c",
  "__time__":"1689677656"
}
  • 采集配置3

enable: true
inputs:
  - Type: input_command
    User: test
    ScriptType: python2
    ScriptContent: |
      import os
      print os.environ
    CmdPath: /usr/bin/python
    Environments:
      - "DEBUG=true"
    TimeoutMilliseconds: 1005
flushers:
  - Type: flusher_sls
    Endpoint: cn-xxxxxx.log.aliyuncs.com
    ProjectName: xxxxxx
    LogstoreName: xxxxxx
  - Type: flusher_stdout
    OnlyStdout: true
  • 输出

{
  "content":"{'GOPATH': '/opt/go', 'GOROOT': '/usr/local/go',  'DEBUG': 'true', xxxxx(省略后面内容)}",
  "script_md5":"1444286e16118f7d1bb778738a828273",
  "__time__":"1689677681"
}
Alpha