Skip to content

Instantly share code, notes, and snippets.

@wesleyjin
Created August 1, 2019 23:07
Show Gist options
  • Select an option

  • Save wesleyjin/02987e7173a47dd7b980baf2e870f918 to your computer and use it in GitHub Desktop.

Select an option

Save wesleyjin/02987e7173a47dd7b980baf2e870f918 to your computer and use it in GitHub Desktop.
Installing datadog-agent on an EC2 instance to tail log files

How to install DataDog agent on an EC2 instance to tail log files

(ubuntu)

  1. Use curl to install the agent onto the machine using the API key here: https://app.datadoghq.com/account/settings#agent/aws

  2. Clean up any packages that you want to clean up from the installation (the installation logging will tell you what commands to run)

  3. Start the service by running: sudo service datadog-agent start and check status by running sudo service datadog-agent status. Proceed if service is healthy and running.

    • For a full list of commands, see usage docs.
  4. Enable logs in your DataDog config file located at /etc/datadog-agent/datadog.yaml

    logs_enabled: true
    
    • (Optional): Set the hostname in the config in order to easily filter out your new log events
  5. Check to make sure that the instance can send outbound communication over port 10516

  6. Create a new directory at the root of the agent's config directory. For this example, we will create a new log source for ovenschedule:

    cd /etc/datadog-agent/conf.d
    mkdir ovenschedule.d/
    
  7. Create a new config file conf.yaml in this new folder:

    cd ovenschedule.d
    vi conf.yaml
    
  8. Add the following to your config required (using ovenschedule as example):

    logs:
      - type: file
        path: /home/sg-ovenschedule-loader/logs/*.log
        service: ovenschedule
        source: custom
    
  9. Restart the DataDog agent sudo service datadog-agent restart.

  10. Check the status of the files you are now logging by running sudo service datadog-agent status and verify that the log files you wish to tail to Datadog is under the "checks" section

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment