You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无需SSH:Elastic Beanstalk上AWS Kinesis Agent的安装配置问询

Awesome question! You can absolutely set up the AWS Kinesis Agent on Elastic Beanstalk without ever SSHing into your instances—Elastic Beanstalk's .ebextensions configuration files are perfect for this. Let's walk through exactly how to do it:

1. Create the .ebextensions Directory

First, make a new folder named .ebextensions at the root of your application source code (don't forget the leading dot—it's a hidden directory). This is where Elastic Beanstalk looks for custom configuration scripts.

2. Add the Kinesis Agent Setup Config File

Inside the .ebextensions folder, create a file called kinesis-agent-setup.config (the name doesn't matter as long as it ends with .config). Paste the following content into it, and adjust the values to match your setup:

# Install the AWS Kinesis Agent via YUM
packages:
  yum:
    aws-kinesis-agent: []

# Deploy the agent's configuration file
files:
  "/etc/aws-kinesis/agent.json":
    mode: "000644"
    owner: root
    group: root
    content: |
      {
        "cloudwatch.emitMetrics": true,
        "flows": [
          {
            "filePattern": "/var/log/httpd/access_log",
            "deliveryStream": "YOUR-KINESIS-STREAM-NAME",
            "dataProcessingOptions": [
              {
                "optionName": "LOGTOJSON",
                "logFormat": "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
              }
            ]
          }
        ]
      }

# Ensure the Kinesis Agent service runs automatically
services:
  sysvinit:
    aws-kinesis-agent:
      enabled: true
      ensureRunning: true
      files:
        - "/etc/aws-kinesis/agent.json"

Key Adjustments You Need to Make:

  • Replace YOUR-KINESIS-STREAM-NAME with the actual name of your Kinesis Data Stream.
  • Update filePattern to point to the log file or directory you want the agent to monitor (e.g., /var/log/nginx/access.log for Nginx, or a custom application log path).
  • Modify the logFormat to match the format of your log files—this ensures the agent parses logs correctly into JSON.
3. Deploy Your Updated Application

Package your application source code (including the .ebextensions directory) into a ZIP file, then deploy it to your Elastic Beanstalk environment.

When Elastic Beanstalk spins up (or updates) your instances, it will automatically:

  1. Install the AWS Kinesis Agent via YUM.
  2. Copy your custom agent.json configuration file to the correct location.
  3. Start the Kinesis Agent service and set it to run on boot.
Important Additional Notes
  • IAM Permissions: Make sure your Elastic Beanstalk instance's IAM role has permissions to write to your Kinesis Data Stream. At minimum, it needs kinesis:PutRecord and kinesis:PutRecords permissions. You can attach the managed policy AmazonKinesisFullAccess (for quick testing) or create a custom policy with least-privilege access.
  • Amazon Linux 2 vs. Amazon Linux AMI: If you're using the older Amazon Linux AMI (not Amazon Linux 2), adjust the services section to use systemd instead of sysvinit:
    services:
      systemd:
        aws-kinesis-agent:
          enabled: true
          ensureRunning: true
          files:
            - "/etc/aws-kinesis/agent.json"
    
  • Multiple Log Flows: You can add more entries to the flows array in agent.json to monitor multiple log files or send data to different Kinesis streams.

内容的提问来源于stack exchange,提问作者AJ222

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 04:19:52